Jetpack 4.5: USB Camera does not work in Cheese and opencv 4.1

Hi,
Hi this refers to
Jetson Xavier NX (Dev Kit Version)
jetpack V4.5
cheese V.3.28.0 (cheese -v)
opencv 4.1.1 (cv.–version)
gstreamer 1.14.5 (output from gst-inspect)

after a fresh install on my Xavier NX using jetpack 4.5 “cheese (V 3.28.0)” and opencv do not recognize my USB Cam.

Cheese gives an Error:
$ cheese
Opening in BLOCKING MODE
Segmentation fault (core dumped)
My usbcam is shown as a device (lsusb)

Opencv 4.1. in python/python3 also gives an error:

import numpy as np
import cv2
cap = cv2.VideoCapture(0)

[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp
(1757) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Device ‘/dev/video0’ is busy
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (886) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

I had no Problems with Jetpack Version 4.1 What could be done to get the usb camera working with cheese or opencv??? - please help.

Thanks in advance

Marius

Hi,
Could you check if you can launch the camera in gstreamer pipeline? Please follow steps in

Jetson Nano FAQ
Q: I have a USB camera. How can I launch it on Jetson Nano?

Thank you for reply.I did:
sudo apt install v4l-utils
installed …
v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: ‘YUYV’
Name : YUYV 4:2:2
Size: Discrete 640x480

(had to use video0, there is no video1)

Wenn I launch one mode(Ex: 640x480p30) in gstreamer command:

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

the camera switches on
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
… then nothing more happens but camera light stays on

=> nirwana?

So since nothing happens I kill the process …
^Chandling interrupt.
Interrupt: Stopping pipeline …
Execution ended after 0:03:35.916485796
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

So I tried with YUYV & video0, but I receive only a warning:

WARNING: erroneous pipeline: could not link v4l2src0 to nvvconv0, neither element can handle caps video/x-raw, format=(string)YUYV, width=(int)640, height=(int)480, framerate=(fraction)30/1

I am stuck here. The new plugin nvv4l2camerasrc , which is mentioned on your given linkleads again to an error which Ido not even understand:
“bash: syntax error near unexpected token `(’” - I checked the copied call several times.

So I do not know how to continue. should I revert to Jetpack 4.4.1 to get a simple Webcam working again ??

Kind regards
Marius

Hi,
Setting YUY2 in gstreamer command is correct. do you see video preview?
Or may try to save to a video file and check if it is playable:

gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=150 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvvidconv ! ‘video/x-raw(memory:NVMM),format=NV12’ ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=a.mp4

Hi back, thanks for reply, here it is late night …, i shall continue tomorrow
your suggestion leads to an error. the cam switches on for a second than (streaming )stops,
no preview:

…marius@xavier-nx:~ gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=150 ! video/x- raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvvidconv ! 'video/x- raw(memory:NVMM),format=NV12' ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=a.mp4 Setting pipeline to PAUSED ... Opening in BLOCKING MODE Opening in BLOCKING MODE Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... New clock: GstSystemClock Redistribute latency... NvMMLiteOpen : Block : BlockType = 4 ===== NVMEDIA: NVENC ===== NvMMLiteBlockCreate : Block : BlockType = 4 H264: Profile = 66, Level = 0 Got EOS from element "pipeline0". Execution ended after 0:00:09.037596385 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ... ...marius@xavier-nx:~

BTW the cam is 1280x720, 22 fps, 768x480, 30 fps. Worked well with “cheese” from previous jetpack (4.4.1).
I think I need some help to construct a correct pipeline.

thank you so much Marius

Hi,
For setting num-buffers=150, it terminates after capturing 150 frames. Looks like it works. So the recorded a.mp4 is invalid?

so hi good morning from here,
yes, I got the desired a.mp4 file.
viewable/valid too, plays in default videoplayer -great!!

But cheese does not work any more? - and how to open the stream in open cv?
thank you for your great help.
Marius

Hi,
Please check the sample:

and run this pipeline:

 v4l2src device=/dev/video0 ! video/x- raw,format=YUY2,width=640,height=480,framerate=30/1 ! videoconvert ! video/x-raw,format=BGR ! appsink

A user has mentioned performance is better with two nvvidconv plugins:

So you may also try

 v4l2src device=/dev/video0 ! video/x- raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvvidconv ! video/x-raw(memory:NVMM),format=BGRx ! nvvidconv ! video/x-raw ! videoconvert ! video/x-raw,format=BGR ! appsink

thank you ok, I shall try your suggestions.

in the meantime I found out I can get at least an output of the webcam on screen by either commands:

  • gst-launch-1.0 autovideosrc ! xvimagesink
  • gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw,width=1280,height=720 ! xvimagesink

probably still need to convert to BGRx for opencv, unfortunately I have to figure out how to do this.

Also why does the “cheese” app not work in Jetpack 4.5, is this a bug ???

Thank you for your help

Marius

1 Like

Thank you @mebc for asking about this, I am running into the same issues.

1 Like

Hi,
Not sure why cheese app does not work. We would suggest use gstreamer or jetson_multimedia_api on Jetson platforms. The two frameworks are tested/verified in each L4T release. Should be with better stability.

Ok, “cheese” does not work with jetpack 4.5 for some reason.
Maybe its a problem with

OpenCV seems to work.

This OpenCV code opens the cam on display0:
#!/usr/bin/python3

import numpy as np
import cv2
ver=cv2.version
width =640
height=480
print(“OpenCV Version :”, ver, width, height, flip)

camset = ‘v4l2src device=/dev/video0 ! video/x-raw,width=’+str(width)+’,height=’+str(height)+’,framerate=30/1 ! videoconvert ! appsink’

cam=cv2.VideoCapture(camset)

while True:
_, frame = cam.read()
cv2.imshow(‘myCam’,frame)
cv2.moveWindow(‘myCam’,0,0)
if cv2.waitKey(1)==ord(‘q’):
break
cam.release()
cv2.destroyAllWindows()
took me some time to understand pipes

so thank you for your help, shall I close this issue?

Marius

Hi,
Good to know it’s working and thanks for sharing the python code.

Yea, I’m seeing the same thing. OpenCV itself seems to work fine, i.e. using cam=cv2.VideoCapture(0) vs setting the pipeline explicitly.

Ryan

Not sure if my issue is really the same but since the JetPack 4.5 upgrade I do not even have the /dev/video0 created although the device is detected (logitech USB webcam).
dmesg output
[ 1299.985912] usb 1-2.4: new high-speed USB device number 6 using tegra-xusb
[ 1300.260144] usb 1-2.4: New USB device found, idVendor=046d, idProduct=081d
[ 1300.260157] usb 1-2.4: New USB device strings: Mfr=0, Product=0, SerialNumber=1
[ 1300.260165] usb 1-2.4: SerialNumber: 49E1F0A0
[ 1300.520179] usb 1-2.4: set resolution quirk: cval->res = 384

usb-devices:
T: Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#= 6 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=046d ProdID=081d Rev=00.10
S: SerialNumber=49E1F0A0
C: #Ifs= 4 Cfg#= 1 Atr=80 MxPwr=500mA
I: If#= 0 Alt= 0 #EPs= 0 Cls=01(audio) Sub=01 Prot=00 Driver=snd-usb-audio
I: If#= 1 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
I: If#= 2 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=(none)
I: If#= 3 Alt= 0 #EPs= 0 Cls=0e(video) Sub=02 Prot=00 Driver=(none)

any idea?

seems also to be for the usb wireless receiver(keyboard and mouse), known issue of the USB ?

T: Bus=01 Lev=02 Prnt=02 Port=02 Cnt=01 Dev#= 5 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=32 #Cfgs= 1
P: Vendor=046d ProdID=c52b Rev=24.10
S: Manufacturer=Logitech
S: Product=USB Receiver
C: #Ifs= 3 Cfg#= 1 Atr=a0 MxPwr=98mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=01 Driver=usbhid
I: If#= 1 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid
I: If#= 2 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid

Cheers
Manu

Hi,
Please apply this and try again:
Jetson/L4T/r32.5.x patches - eLinux.org
[camera] 3rdparty application fails to open with USB camera

1 Like

Thank you very much. This patch made the cheese app work.
Marius