Accessing a USB connected camera

asked 2018-03-07 11:58:48 -0500

MJHanagan gravatar image

updated 2018-03-07 12:00:56 -0500

berak gravatar image

I have an OptixCam Summit Series camera mounted on a microscope and USB connected to my Windows 10 system. The correct driver is installed and the device shows up in the Device Manager under the "Imaging devices" tree as "TCA-9 USB2.0 Camera". When I click on Properties its location is listed as "Port_#0001.Hub_0001". The canned software that came with the camera works so the camera itself is functioning fine.

Now I want to capture the images using Python rather than relying on the canned software.

I successfully installed opencv-python- on my Windows 10 system and I am programming in Python 3.6.2.

I am having trouble figuring out how to get cv2 to "open" this USB camera. I tried the following, all without success:

camera = cv2.VideoCapture(i) # Where i ranged from 0 to 99)
camera = cv2.VideoCapture("TCA-9 USB2.0 Camera")
camera = cv2.VideoCapture("Port_#0001.Hub_0001")

When I tried to capture an image using: All returned [False, None]

Can anyone point me in the right direction to capture an image from this camera?

edit retag flag offensive close merge delete


webcams can only be accessed by index (which is the order, your cam was plugged in to your box), not by name.

e.g. on a laptop with a builtin camera, that one would be index 0, and your usb one index 1

try, if you can access it via mediaplayer / vlc. if not so, it likely does not come with proper dshow drivers (any chance, you can update those ?), and you'd need the manufacturer's sdk to access it (if there's any, and probably not possible from python, though)

berak gravatar imageberak ( 2018-03-07 12:01:54 -0500 )edit

So if this is not a web cam then opencv will not be able to interact with it?

MJHanagan gravatar imageMJHanagan ( 2018-03-07 13:03:54 -0500 )edit

on win, if it does not have drivers either supporting directshow, vfw (or msfs, but theres no support for that builtin by default), you won't be able to use cv2.VideoCapture for this

berak gravatar imageberak ( 2018-03-07 13:40:25 -0500 )edit

"the canned software." -- what is it ? any chance you can use it ? does it have c++ headers/libs at least ?

berak gravatar imageberak ( 2018-03-07 13:41:30 -0500 )edit

The canned software is TSView Version ( Not very good software. I want to automate the image taking and filing process as well as add in a calibrated image magnification bar.

MJHanagan gravatar imageMJHanagan ( 2018-03-07 14:22:15 -0500 )edit

again, check the hints above. if neither vlc or mediaplayer can pick it up, you've got to buy something else. even fails to load. badsoftware indeed ;(

berak gravatar imageberak ( 2018-03-07 15:12:24 -0500 )edit

I cannot "see" the device using MediaPlayer of VLC, so this is not likely to work as originally planned. Looks like I need to go shopping for a new camera.

MJHanagan gravatar imageMJHanagan ( 2018-03-08 10:00:03 -0500 )edit

one last idea: if you have virtualbox or some vm (or a boot cd): try from linux !

berak gravatar imageberak ( 2018-03-08 10:30:20 -0500 )edit

did you get answer?

sivaram_boina gravatar imagesivaram_boina ( 2019-08-30 04:11:44 -0500 )edit

If the camera I am using have a C++ libs/dll, how can that help to connect the camera to OpenCV

IIVirusII gravatar imageIIVirusII ( 2019-11-16 10:56:32 -0500 )edit