简体   繁体   中英

USB Camera is not detected by OpenCV Python

I am working on a project that has to detect a USB camera (CM3-U3-13S2C-CS a 1.3 Megapixel USB 3.0 camera), opencv failed to detect the id of the camera I have tried the code below to display the IDS of available cameras but all that openCV detects is the ID of the webcam, the camera is working fine on Labview. I would really appreciate any help !

> import cv2
> 
> openCvVidCapIds = []
> 
> for i in range(100):
>     try:
>         cap = cv2.VideoCapture(i)
>         if cap is not None and cap.isOpened():
>             openCvVidCapIds.append(i)
>         # end if
>     except:
>         pass
>     # end try
> # end for
> 
> print(str(openCvVidCapIds))

 

which OS are you running your OpenCV codes? have you checked if your USB camera is shown up in your OS device layers?

  • for windows, in the Device Manager under the "Imaging devices" tree

  • for Linux, in /dev like "/dev/video1" and "/dev/video2" and then do

    cap = cv2.VideoCapture("/dev/videox")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM