ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS2 cam2image non default video device

asked 2019-11-30 14:55:48 -0500

Poseidonius gravatar image

Hi,

how can I switch the video device when I start up cam2image with ROS2? I hope to find something like

ros2 run image_tools cam2image video0:=video2

Best wishes

Sebastian

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-12-01 06:31:29 -0500

gvdhoorn gravatar image

I don't believe you can (from here):

if (!burger_mode_) {
  // Initialize OpenCV video capture stream.
  // Always open device 0.
  cap.open(0);
  ..
}

The help output also doesn't seem to give the impression this is possible:

Usage:
 -h: This message.
 -r: Reliability QoS setting:
    0 - best effort
    1 - reliable (default)
 -d: Depth of the queue: only honored if used together with 'keep last'. 10 (default)
 -f: Publish frequency in Hz. 30 (default)
 -k: History QoS setting:
    0 - only store up to N samples, configurable via the queue depth (default)
    1 - keep all the samples
 -s: Camera stream:
    0 - Do not show the camera stream
    1 - Show the camera stream
 -x WIDTH and -y HEIGHT. Resolution.
    Please type v4l2-ctl --list-formats-ext
    to obtain a list of valid values.
 -b: produce images of burgers rather than connecting to a camera
 -t TOPIC: use topic TOPIC instead of the default
edit flag offensive delete link more

Comments

Hi gvdhoorn,

Based on the code, you seem to be right. Is there a good reason to connect this statically to video0? Or are other packages avilable with a more flexible interface?

Best wishes!

Sebastian

Poseidonius gravatar image Poseidonius  ( 2019-12-01 13:27:14 -0500 )edit

Is there a good reason to connect this statically to video0?

This package is a demo package, it was never designed to be a generic replacement for something like usb_cam (the ROS 1 pkg).

Or are other packages avilable with a more flexible interface?

No, I don't. I'm sorry.

gvdhoorn gravatar image gvdhoorn  ( 2019-12-01 14:44:01 -0500 )edit
1

Contributing a patch to add a new command line argument to pass the device name should be pretty straight forward.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-12-02 14:41:23 -0500 )edit

That would indeed not be too difficult and would make a great addition.

@Poseidonius: please consider contributing that change. It would appear it would help you and it would help future users as well.

gvdhoorn gravatar image gvdhoorn  ( 2019-12-03 02:18:36 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-11-30 14:55:48 -0500

Seen: 1,395 times

Last updated: Dec 01 '19