I am coding in C++ and using opencv library for most purposes to talk to my usb webcams. I am facing an issue with finding the index of the webcam to pass when I'm interfacing the webcams.
The function that I use to initiate the communication with webcams is
capture = cvCaptureFromCam(index)
The value of index should be a number. I found that the value of index should be one of the digits that show up for the command "lsusb" at the terminal, but I don't have an automatic way of achieving this.
I did not have a problem with this when I used only one cam, but my application calls the need for two or more webcams.
Can somebody please tell me how to find the index of the webcam?