Webcams interfacing in Linux

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?

Oh, I'm using FC11 and Logitech Quickcam.
I believe you can find your answer in implemtation of lsusb.
Please find source code for it.
Topic archived. No new replies allowed.