Ask Your Question
0

ROS2 cam2image non default video device

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

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 -0600

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 imagePoseidonius ( 2019-12-01 13:27:14 -0600 )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 imagegvdhoorn ( 2019-12-01 14:44:01 -0600 )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 imageDirk Thomas ( 2019-12-02 14:41:23 -0600 )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 imagegvdhoorn ( 2019-12-03 02:18:36 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 29 times

Last updated: Dec 01