How to identify multiple cameras

asked 2014-09-09 16:36:43 -0600

Hello,

I use two cameras at same computer, to capture photos and videos. Each camera is responsible for unique tasks.

I don't have problems to open parallel cameras and capture videos or pictures. For now, I used just index number to open each device:

cv::VideoCapture cap_foo(0);
cv::VideoCapture cap_foo(1);

No problem at this point, all works fine.

However, at first time I don't know which index is from which camera. I need capture a simple picture to discover the position. (LEDs from device aren't available)

The index is the same sequence ever. (good)

Although, some times I get some hardware error from a camera (normally at index 0), as result, OpenCV provide just index 0 to open. So, at this point I need look the video capture to identify which camera is working. (bad)

I tried use the "Device Path" as an unique id for each camera:

cv::VideoCapture cap_first("\\\\?\\usb#vid_045e&pid_074a&mi_00#7&243504bc&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global");
cv::VideoCapture cap_secon("\\\\?\\usb#vid_1871&pid_0f01&mi_00#8&2aa65eb9&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global");

However, I get just an error message: warning: Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:545)

Then, I need a mechanism that informs which camera is connected in which index. How is possible? (Direct Show is an option)

edit retag flag offensive close merge delete

Comments

1

Do you use Windows or Linux? On Linux, you could use udev-rule to map your cameras to /dev/videoX.

FooBar gravatar imageFooBar ( 2014-09-10 01:02:10 -0600 )edit

I use Windows.

Yes, map using file descriptor is a good idea for linux :)

I tried with device path, like \?\usb#vid_045e&pid_074a&mi_00#7&243504bc&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global. However, I only got an error message.

uilianries gravatar imageuilianries ( 2014-09-10 05:59:43 -0600 )edit