Logitech USB camera not working with TX1 through gstreamer and OpenCV

After trying to find an answer in the forums, I decided to ask my own question as I could not find a satisfactory solution. I have a Logitech USB camera (not sure what model it is) and I am trying to capture a video stream with it. I could not get it working with OpenCV (3.4.1) and/or gstreamer. With gstreamer I am trying the following:

gst-launch-1.0 v4l2src device="/dev/video0" ! xvimagesink -e

It gives me the following output and waits, which contains no errors but I don’t see an image either:

Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock

With OpenCV, I try the following:

VideoCapture cap(0); // open the default camera
cap.set(CV_CAP_PROP_FRAME_WIDTH , 640);
cap.set(CV_CAP_PROP_FRAME_HEIGHT , 480);

if(!cap.isOpened()) { // check if we succeeded
    cerr << "Fail to open camera " << endl;
    return -1;
}

This does not report an error either, but keeps printing “select timeout” on the screen every few seconds.

I would appreciate any help in getting to the bottom of this issue.

Thanks,
Oguz

Does your TX1 have the onboard camera ? If yes, /dev/video0 should be the onboard camera, and plugging your USB cam should lead to /dev/video1 to be created (and removed after you unplug it).

If /dev/video1 doesn’t appear after plugging your USB cam, then probably the camera driver is missing.

I don’t have an onboard camera. I verified two things in the mean time.

  1. When my camera is unplugged, I don’t see /dev/video0. When I plug it /dev/video0 appears.
  2. I found my camera model with the “lsusb” command. It is Logitech HD Pro Webcam C920.

Any help is greatly appreciated.
Oguz

As a further comment, I also checked that I can see my camera stream using the VLC application, suggesting that the drivers are not the issue.

Thanks,
Oguz

I solved the issue! My development board onto the which the TX1 is attached had two seemingly identical USB ports (it is a custom development board). Both ports appear to work with a USB keyboard and a mouse. However, I accidentally discovered that the camera works only if plugged to one of these ports.

I am not sure why this is the case as plugging the camera to either of them results in /dev/video0 appearing in my system. If you have guesses I would be happy to hear.

Oguz

Look at “lsusb -t” to see if both ports show as the same mode. There are cases where a camera was designed to work in only one mode…both modes would detect the camera, but only part of the interface would be exposed in other modes. The “5000M” at the end of an “lsusb -t” line is USB3 mode, “480M” is USB2 mode, and slower modes I’d expect for keyboard/mouse, but not for camera.

In both cases (when the camera is plugged to USB1 or USB2) I see the following output from “lsusb -t”:

|__ Port 1: Dev 2, If 0, Class=Video, Driver=uvcvideo, 480M
|__ Port 1: Dev 2, If 1, Class=Video, Driver=uvcvideo, 480M

Not sure if this helps.

Thanks,
Oguz

The C920 is USB2, so 480M is correct for both cases. This camera won’t operate correctly if not in USB2 mode, but seeing as it shows 480M, this is not a reason for failing on one port, yet working on the other port.

Signal quality could get in the way even if the port is working with USB2 speed/settings. A keyboard or mouse will never operate at USB2 speeds, and so signal quality requirements are much lower for these in comparison to the camera. Your ports are doing basically what they should in terms of software…for the port which fails you may want to investigate the signal quality.

Thank you for the explanations.

Oguz