I am trying to get the hello camera project to work with a USB camera. I’ve tested the camera and it works on other linux machines, shows up as video0, but wont run because of :
R---------------------------------------------------------------------------
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
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
Where do I find usb_camera.py locally, I’m guessing I need to change the dimensions declared inside?
the file location is at /usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg/jetcam/usb_camera.py but I can’t get past the .jetcam-0.0.0-py3.6.egg part in terminal.
Hi @murray, you can change these arguments from the Jupyter notebook as opposed to needing to change the dimensions inside jetcam library:
from jetcam.usb_camera import USBCamera
#TODO change capture_device if incorrect for your system
camera = USBCamera(width=224, height=224, capture_width=640, capture_height=480, capture_device=0)
And if you run the commands below outside of container, it will let you know what image formats your camera supports:
I had previously use, lsusb -s 001:002 -v | egrep “Width|Height” which gave me less detail but the same camera sizes.
Just to be sure I changed the capture to be the same as the camera:
camera = USBCamera(width=640, height=480, capture_width=640, capture_height=480, capture_device=0)
But its still the same error.
So I tried :
guvcview
Opening in BLOCKING MODE
Segmentation fault (core dumped)
cheese
Unable to init server: Could not connect: Connection refused
These all work on Linux Mint machine, ffplay might have a hint with the terminal output?
Input #0, video4linux2,v4l2, from ‘/dev/video1’:B sq= 0B f=0/0
Duration: N/A, start: 36283.717558, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 640x360, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
[swscaler @ 0x7f9918066bc0] deprecated pixel format used, make sure you did set range correctly
Interestingly running v4l2-ctl on a Linux Mint machine gives 2 different video formats and the Nano only has MJPG?
From a Linux Mint machine
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: ‘YUYV’
Name : YUYV 4:2:2
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 176x144
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 320x240
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 352x288
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 640x360
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.100s (10.000 fps)
12.415975] usb 1-2: New USB device found, idVendor=1d6b, idProduct=0104
[ 12.415981] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 12.415985] usb 1-2: Product: Piwebcam
[ 12.415988] usb 1-2: Manufacturer: Show-me Webcam Project
[ 12.415991] usb 1-2: SerialNumber: 100000000d2386db
[ 12.447822] cdc_acm 1-2:2.2: ttyACM0: USB ACM device
[ 12.448211] usbcore: registered new interface driver cdc_acm
[ 12.448215] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[ 12.450630] uvcvideo: Found UVC 1.00 device Piwebcam (1d6b:0104)
[ 12.455437] uvcvideo 1-2:2.0: Entity type for entity Processing 2 was not initialized!
[ 12.463774] uvcvideo 1-2:2.0: Entity type for entity Camera 1 was not initialized!
[ 12.471755] input: Piwebcam as /devices/70090000.xusb/usb1/1-2/1-2:2.0/input/input4
[ 12.471970] usbcore: registered new interface driver uvcvideo
[ 12.471973] USB Video Class driver (1.1.1)
Perhaps a similar issue here but none of these fixes worked @DaneLLL
Reinstalling uvcdynctrl didnt work either.
any idea why its not working on a Nano but does on other Linux machines?
And USBCamera should work with YUV422 format such as YUYV or UYVY. If the camera dies not show YUYV on Jetson Nano, probably certain driver is missing. It looks to be about USB ACM. May try this: Xavier NX not recognizing certain ACM USB device - #8 by DaneLLL
Setting pipeline to PAUSED …
Invalid MIT-MAGIC-COOKIE-1 keyERROR: Pipeline doesn’t want to pause.
ERROR: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: Could not initialise Xv output
Additional debug info:
xvimagesink.c(1773): gst_xv_image_sink_open (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
Could not open display (null)
Setting pipeline to NULL …
Freeing pipeline .
I took a look a the link, but it pointed to another link and I think it was really about rebuilding the kernel?
What part of the link was I supposed to read.
Hi,
You probably don’t set export DISPLAY:=0(or 1), so it shows the error about display. If this works you can try to customize the app to run MJPEG decoding.
Without customizing the app, would need to check why YUYV is not shown. The error in enumeration looks related to ACM, so it might help to enable the configs and rebuild kernel.