ros-drivers / video_stream_opencv

A package to open video streams and publish them in ROS using the opencv videocapture mechanism
227 stars 159 forks source link

Unable to open V4L devices by device node other than /dev/videoN #4

Closed martonmiklos closed 6 years ago

martonmiklos commented 7 years ago

Sometimes it would be beneficial to open the video devices with other device node than the /dev/videoN because udev populates the /dev/v4l/by-id entries like: /dev/v4l/by-id/usb-CN0CJ3PDPA01_Laptop_Integrated_Webcam_FHD-video-index0

Using these device nodes eliminates the necessity of plugging the cameras in specified order to specified ports in a robot which has multiple USB cameras.

Unfortunately if I pass such a device path as a string I got "Could not open the stream." error.

I have checked the OpenCV code, but unfortunately the OpenCV 2.4.8.3 which is shipped with the Ubuntu 14.04 does not had any feature to specify the V4L2 device manually.

Lately an open method with an apiReference argument added see: https://github.com/opencv/opencv/commit/41d8c4d8790ac46bffec1206daccf5d61fefc0ab

Any suggestions would be highly appreciated with this issue

awesomebytes commented 7 years ago

You can add an udev rule to make your camera named as /dev/yourpreferred name. I googled quickly and found someone explaining a way here: https://askubuntu.com/questions/715333/assign-webcam-to-a-specific-dev-video

If you force it to be called /dev/video42 for example you could effectively use the node (I guess).

Edit: If you get it to work, it would be nice if you reproduce what you did in this issue for future readers :)

martonmiklos commented 7 years ago

Using udev makes sense. I will let you know the results!

martonmiklos commented 7 years ago

FYI: I have just built the latest opencv from git, and it handles v4l device node if I pass it as string even if I pass the by-id device node. I will try to link my node against it and we will see.

awesomebytes commented 6 years ago

Hey @martonmiklos are you ok with me closing this issue?

martonmiklos commented 6 years ago

Hello Sam, Sure.