Ask Your Question
0

[SOLVED] Multiple USB camera on a hub question

asked 2018-08-11 10:02:20 -0600

eightcounts gravatar image

updated 2018-08-15 11:39:17 -0600

I am using a powered USB 2.0 hub and I am having problems accessing more than one camera through the hub in my python script.

I don't need simultaneous video feed from each camera. I just need to cycle through each to grab a snapshot.

example:

Activate Cam0

Take picture from Cam0

Disable Cam0

Activate Cam1

Take Picture from Cam1

Disable Cam1

etc.

Do you know how I can fully disconnect from Cam0 so I can access Cam1? Even though I do a release() on Cam0 and Cam1.isOpened() returns true, I get a "can't grab frame. Error: -2147483638" when I try to read() from Cam1.

Thanks in advance.

edit retag flag offensive close merge delete

Comments

In general, accessing multiple USB camera's at the exact same moment, through a single USB hub is a bad habbit. There will always be a delay ... You could try 2 seperate physical busses on your system, which works a bit better, but actually what you need are multiple camera's that are interconnected by a hardware trigger. Thats the only robust solution to get 100% identical moment captures.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-08-17 07:14:09 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-08-15 11:32:51 -0600

eightcounts gravatar image

Fix action:

I created a 2nd python script that will be opened using the subprocess module, specifically the Popen() method. The second script will open the camera, take a picture, save the picture, close the camera, and free up the USB resources when the script terminates. I will be able to cycle through each camera from the first script by passing a cameraindex argument which is received as argv[1] in the second script.

Maybe this will help someone in the future.

edit flag offensive delete link more

Comments

hi, would you mind sharing the code? It seems I need a similar solution. A github link would be ideal :)

guyko gravatar imageguyko ( 2018-09-02 15:16:39 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-08-11 10:02:20 -0600

Seen: 3,152 times

Last updated: Aug 15 '18