Unable to create camera object with a Logitech camera

I’m a newcomer in AI trying to enter this field of IT with Jetson nano development kit. I am in the course
Getting Started with AI on Jetson Nano (https://courses.nvidia.com/courses/course-v1:DLI+C-RX-02+V1/course/).
After I have run the Jetson Nano Developer Kit in a headless configuration, I connect the kit with a usb camera (https://www.cnet.com/products/logitech-quickcam-pro-4000-web-camera-series/) and run the “hello_camera” lab.

After running !ls -ltrh /dev/video*, it output
crw-rw----+ 1 root video 81, 0 Jun 14 22:08 /dev/video0 ,which is correct.

But when I want to create camera object by

from jetcam.usb_camera import USBCamera
camera = USBCamera(width=224, height=224, capture_width=640, capture_height=480, capture_device=0)

It returns

[b]---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg/jetcam/usb_camera.py in init(self, *args, **kwargs)
23 if not re:
—> 24 raise RuntimeError(‘Could not read image from camera.’)
25

RuntimeError: Could not read image from camera.

During handling of the above exception, another exception occurred:

RuntimeError Traceback (most recent call last)
in
2 #define DEFAULT_CAMERA 0
3 #TODO change capture_device if incorrect for your system
----> 4 camera = USBCamera(width=224, height=224, capture_width=640, capture_height=480, capture_device=0)

/usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg/jetcam/usb_camera.py in init(self, *args, **kwargs)
26 except:
27 raise RuntimeError(
—> 28 ‘Could not initialize camera. Please see error trace.’)
29
30 atexit.register(self.cap.release)

RuntimeError: Could not initialize camera. Please see error trace.
---------------------------------------------------------------------------[/b]

I have tried to find solution on the forum but null. Is this occurs because of the camera I am using?

Hi,
If your USB camera support UVC driver, you may check
[url]Logitech C930e on Jetson TX1 very slow and choppy video - Jetson TX1 - NVIDIA Developer Forums

Hello, I have get these after running
v4l2-ctl -d /dev/video0 --list-formats-ext

ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: ‘PWC2’ (compressed)
Name : Raw Philips Webcam Type (New)
Size: Discrete 160x120
Size: Discrete 320x240
Size: Discrete 640x480

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'YU12'
    Name        : Planar YUV 4:2:0
            Size: Discrete 160x120
                    Interval: Discrete 0.200s (5.000 fps)
                    Interval: Discrete 0.100s (10.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
                    Interval: Discrete 0.050s (20.000 fps)
                    Interval: Discrete 0.040s (25.000 fps)
                    Interval: Discrete 0.033s (30.000 fps)
            Size: Discrete 320x240
                    Interval: Discrete 0.200s (5.000 fps)
                    Interval: Discrete 0.100s (10.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
                    Interval: Discrete 0.050s (20.000 fps)
                    Interval: Discrete 0.040s (25.000 fps)
                    Interval: Discrete 0.033s (30.000 fps)
            Size: Discrete 640x480
                    Interval: Discrete 0.200s (5.000 fps)
                    Interval: Discrete 0.100s (10.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)

But I get error after run gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvvidconv ! ‘video/x-raw(memory:NVMM),format=NV12’ ! nvoverlaysink

Log:
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.000162087
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

Hi,
https://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/pixfmt-yuv420.html
YU12 should be I420 in gstreamer. Please try

$ export DISPLAY=:0(or 1)
$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=I420,width=640,height=480,framerate=15/1 ! xvimagesink

Thank you. I have tried your code.
After running
$ export DISPLAY=:0
$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=I420,width=640,height=480,framerate=15/1 ! xvimagesink

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

And it stops at (New clock: GstSystemClock) with no reaction.

Hi,
You may firstly check if you can capture in running a ‘v4l2-ctl’ commands.
Or try other USB cameras such as Logitech c930e.