-1

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))

 
Asky
  • 45
  • 2
  • 7
  • 2
    You can't open the device 100 times. – Klaus D. May 16 '22 at 12:28
  • @Asky. What if you remove if cap is not None and replace this while cap.isOpenewd():? – toyota Supra May 16 '22 at 13:28
  • @KlausD. The code lists the available Cameras IDs instead of typing each time random values to find the right Id of the concerned camera , in my case it gave me the Id of the Pc webcam. (0) I guess the issue is as mentionned paulyang0125, the usb camera is not recognized by the device manager. – Asky May 16 '22 at 13:44
  • @toyotaSupra still gives the Id of the webcam, the issue here is not about the code, even without the code I tried random numbers to detect the USB camera but no number was the right one, so I guess the problem is ( as mentioned Paul ) the camera is not recognized by the system – Asky May 16 '22 at 13:51
  • @KlausD. they're obviously not doing that, but trying to open each of those ID once. – Christoph Rackwitz May 16 '22 at 14:26
  • if your system doesn't even see the camera device, it's not an OpenCV issue. USB UVC works "without drivers", but "USB3 Vision" and other industrial stuff doesn't do that. you've kept the brand and model of your camera a secret, so we can't help you google for this. – Christoph Rackwitz May 16 '22 at 14:26
  • @ChristophRackwitz Thank you for your response. I don't know what you mean by me keeping the model of the camera a secret when I have already mentioned it in my post.. – Asky May 16 '22 at 15:11
  • 1) The camera must connect to an interface card. This is sometimes called a host adapter, a bus controller, or a network interface card (NIC). – toyota Supra May 16 '22 at 15:18
  • 2) In order to achieve the maximum benefits of USB 3.0, the camera must connect to a USB 3.0 PCIe 2.0 card – toyota Supra May 16 '22 at 15:18
  • 3) You must purchase a compatible card. Sorry, Asky. Listen to Christoph – toyota Supra May 16 '22 at 15:20
  • ah, so that was the model? I mistook that, sorry. spec sheet says it's only supporting "USB3 Vision v1.0", so that means it does **not** do UVC, so it's **not a webcam**, the OS doesn't recognize it as a video source, just a non-specific USB device. you need drivers for this thing. if you're lucky, one of the `videoio` backends in OpenCV may support this, even if it's named badly. some of the "proprietary" backends are actually just "USB3 Vision". when in doubt, call the manufacturer. – Christoph Rackwitz May 16 '22 at 20:42
  • try the XIMEA backend. internet rumor says the company has devices that do USB3 Vision, so it might work. – Christoph Rackwitz May 16 '22 at 20:54

1 Answers1

2

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")

paulyang0125
  • 307
  • 2
  • 7
  • Thank you for your quick reply ! I think this is the issue, I didn't find the USB camera as a device neither in Cameras nor in Imaging devices.. I guess I have to install the driver first? I work on Windows for now – Asky May 16 '22 at 13:28
  • @Asky my pleasure! yes, you need the windows driver support. you can also verify vlc media player (http://www.breakthrusoftware.com/html/onlinedocs/kb/videomill/VLC.html) to see if it can pick the USB camera. If vlc doesn't see it, you have to deal with the driver first – paulyang0125 May 16 '22 at 13:49
  • @paulyang0125. Sorry. You have to purchase video card from company. – toyota Supra May 16 '22 at 15:22