0

I have 2 cameras connected in my windows laptop. When I read 2 camera data in separate threads, instead of default camera (web camera) as device_number = 0, it's getting the data of usb camera as device_number = 0.

Ideally when device_number = 0 should get web cam data and device_number = 1 should get usb cam data. But it's happening in reverse, don't know why.

self.camera_object[device_number] = cv2.VideoCapture(device_number, cv2.CAP_DSHOW)

I'm using Hp laptop and usb cam is also hp. Is this issue related to hardware? Can someone help with this?

van
  • 15
  • 9
  • if you know that usb camera is in index 0 and integrated camera is in index 1 what's the problem? Or does it randomly assign indexes? Just read the camera you want from it's index. – Sembei Norimaki Jan 17 '23 at 09:49
  • even if that is the case, cam 1 is integrated camera and cam 2 should be usb cam know? But its not happening in such way. If I give device index as 1 and 2, the usb cam is not mapped to device index 2 – van Jan 17 '23 at 10:20
  • it depends on the IDs that Windows assigns to the cameras. Probably there is some Windows API to enumerate the connected cameras and opencv should use the same enumeration. In Linux for example you could list the video4linux2 devices from the file system. – Micka Jan 17 '23 at 10:22
  • OpenCV by default in Windows uses (afaik) DirectShow devices. So you would need to get the list of DirectShow devices: https://learn.microsoft.com/en-us/windows/win32/directshow/enumerating-devices-and-filters – Micka Jan 17 '23 at 10:25
  • have a look at: https://stackoverflow.com/a/68402011/2393191 – Micka Jan 17 '23 at 10:27

0 Answers0