Ask Your Question

Revision history [back]

Usb splitter used to access multiple cameras

I am running on Mac OS X 10.7 and using OpenCV 2.4 with Python 2.7. I am trying to access two webcams on a single port with a usb splitter because my second port is giving my trouble (see below*).

I bought a usb splitter and have both webcams plugged in but I cannot figure out how to read both cameras from the same port. Ideally I would like to read them simultaneously, but if not I'd like to at least be able to alternate between the two without having to unplug one or the other. The problem is when both are plugged into the usb splitter regardless of position, opencv defaults to the logitech camera so I can never read from the lifecam without unplugging the logitech cam. Does anyone know how to access different ports from a usb splitter?


  • My original code using 2 usb ports fails for some reason even though QuickTime can access either camera on the second usb port

cameraEye = cv2.VideoCapture(1); cameraWorld = cv2.VideoCapture(2);

while True: frameWorldRetVal, frameWorld = cameraWorld.read(); scaledWorld = cv2.resize(frameWorld,None,fx=0.5,fy=0.5); cv2.imshow('TheWorld',scaledWorld); frameEyeRetVal, frameEye = cameraEye.read(); #code to process eye image

The code works fine when I use my friend's computer (also a Mac) and should work fine with mine but apparently my second usb port is faulty because I receive the following error when trying to access the second camera.

Cleaned up camera. OpenCV Error: Assertion failed (ssize.area() > 0) in resize, file /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/opencv-2.4.4/modules/imgproc/src/imgwarp.cpp, line 1725 Traceback (most recent call last): File "gaze-tracker.py", line 768, in <module> scaledWorld = cv2.resize(frameWorld,None,fx=0.5,fy=0.5); cv2.error: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/opencv-2.4.4/modules/imgproc/src/imgwarp.cpp:1725: error: (-215) ssize.area() > 0 in function resize

It's definitely the second port (not the camera) because I've tried tried switching them and all sorts of combinations. QuickTime of course is able to access either camera from this port.

Any suggestions are appreciated!