I have a task to set resolution by opencv. But my computer has mutiple cameras, when I use opencv code: VideoCapture cap(int deviceIndex). I don't know the index of my device and the index is different on other computers. One solution is open camera one by one and check the resolution. Obviously, it impacts the performance. So is there other way to get my target camera index or initialize videocapture instance with camera name? Thanks in advance.
Asked
Active
Viewed 411 times
0
-
Welcome to Stackoverflow! Can you please elaborate your question having your effort like code or something so that people could get your problem early and help you? Thanks! – Enamul Hassan Apr 22 '16 at 02:57
-
I think enumerating all cameras and checking resolution, name, etc. is the only way you can do it. – Apr 22 '16 at 04:55
-
which OS?;on windows you can try videoInput library which has a lot more options than opencv (which uses videoInput internally but doesnt utilize all functionality) – Micka Apr 22 '16 at 05:38
-
@ZirconiumHacker But on other computer devices, the indexs are different. How to enumerate it? – Allen Apr 22 '16 at 06:24
-
@Micka Actually, I used DirectShow to implement it, but I need opencv to implement it now so that it can run in other platform like Linux. – Allen Apr 22 '16 at 06:28
-
on linux you can use http://stackoverflow.com/questions/4290834/how-to-get-a-list-of-video-capture-devices-web-cameras-on-linux-ubuntu-c – Micka Apr 22 '16 at 07:10