Monday 23 November 2020

Videocapture() with multiple cameras

I have 3 identical cameras running in my system, the only diference between them is the USB port where are plugged. I need to load an specific Python script using OpenCV for each camera, and my code is as simple as:

capture = cv2.VideoCapture(index)

where index equals to 0, 1, 2 respectively in each script. The problem comes when i restart my PC and run the same code, sometimes runs as expected and sometimes 1 or 2 cameras had switch their index (not changing any code or unplugging from USB) so the result is loading the script without the corresponding camera.

For example, if in script2.py the camera index defined was 2, then i restart the PC, and now when running script2.py loads camera with index 0.

Any solutions for this? How can i specify the physical port to VideoCapture() to be always the same? Im running Win10

Thanks in advance



from Videocapture() with multiple cameras

No comments:

Post a Comment