Jupyter Labs cannot read from USB Webcam ("Getting Started with AI on Jetson Nano")

I am trying to get my USB Logitech Brio 4K webcam working in the “Getting Started with AI on Jetson Nano” course but am having problems. Here is the output:

Create the camera object¶

First, create a camera object by importing the USBCamera class from the library by executing the following Python code cell. Please note, you can only create one USBCamera instance. Set the capture_device= to the correct number found when you listed the system video devices. If you have /dev/video0, then set capture_device=0. If you have /dev/video1, set capture_device=1 in the code line below.

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)

---------------------------------------------------------------------------
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)
<ipython-input-7-5a6744da9a88> in <module>
      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.

Anyone having the same problems?

Thanks

Partially fixed this I think by installing anything mjpeg, USB UVC, or VLC related. This gets me an image in VLC.

It does not allow me to run the example though, and I get the same error as above.

Following https://github.com/NVIDIA-AI-IOT/jetcam/issues/12 fixed the issue for me.

Thanks, but where is the usb_camera.py file? I do not have it on my system!

To clarify, the local Jupyter webpage is specifying this file:
/usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg/jetcam/usb_camera.py

However, I only have this binary file present:
/usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg

Okay, I unzipped the .egg file (it is just a zip), made the edit to usb_camera.py, copied it back to its place in usr.

But now I see this error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-4-fd9b9853e718> in <module>
----> 1 from jetcam.usb_camera import USBCamera
      2 
      3 #TODO change capture_device if incorrect for your system
      4 camera = USBCamera(width=4096, height=2160, capture_device=0)

ModuleNotFoundError: No module named 'jetcam'

I had to do this:

git clone https://github.com/NVIDIA-AI-IOT/jetcam
cd jetcam
pip3 install ./ --user

And now it works. Yay.

Hi jetsonnvidia,

I have been encountering the same problem as you have, and am currently trying to unzip the py3.6.egg file. I’m having a hard time doing this as I have the following permission error:

PermissionError: [Errno 13] Permission denied: ‘/usr/local/lib/python3.6/dist-packages/EGG-INFO’

How were you able to unzip the file?

Thanks!

Try doing it as root.