Issues reading camera image from Raspberry Pi Camera v2

Having recently acquired a Jetson Nano B01 Developer Kit I began to work through the Getting Started with AI on Jetson Nano course. I am experiencing issues creating a camera object using the csi_camera.ipynb in the Hello Camera Jupyter Notebook lab. As can be seen from the attached screenshot when running the second code cell to create a camera object I get a RuntimeError stating ‘Could not read image from camera’. The camera is definitely working as I have tested it on one of my Raspberry Pi units and I have tried connecting it to both the camera slots on the Nano B01 board but this makes no difference.

Any ideas?

Not sure, but maybe the 224x224 resolution cannot be achieved.
You may first try with a native resolution of your camera such as 1280x720.

  1. Please have a check if the camera was registered successfully. v4l2-ctl --list-devices
  2. check if camera working well by nvgstcapture-1.0

Resolved the issue. On closer inspection of the code cells for the relevant Jupyter Notebook lab, I realised that the code cell to connect the camera contained code to initialise cameras connected via USB and cameras connected via the dedicated camera connector, with the user required to comment out the lines of code not required.

Which lines of codes should be commented out? I’ve got the exact same problem and I couldn’t quite find the solution.

Hi,

If you are using a Raspberry Pi camera connected via a ribbon connector then you need to comment out the line of code that reads: from jetcam.usb_camera import USBCamera. If you are using a camera that is connected via one of the USB ports then you need to comment out the line of code that reads: from jetcam.csi_camera import CISCamera.

I can’t find these two lines in the notebook ‘csi_camera.ipynb’.

I’ve just taken a closer look at this and in appears that the Getting Started with AI on Jetson Nano course has been revised since I did it. The calls to the camera libraries have now been implemented as two separate Jupyter Notebook code cells, but the same principle applies. You need to run the appropriate module for the type of camera that you are using. If you are using a Raspberry PI camera then you need to run the csi_camera.ipynb module and if you are using a USB camera you need to run the usb_camera.ipynb module. From your screen shot you appear to be running the csi_camera.ipynb module, so if you have a USB camera connected this will not work. If you do have a Raspberry Pi camera connected and this is not working then you will need to ensure that the camera is working correctly. Firstly, are you using a Version 2 Raspberry Pi camera? Because only a Version 2 works with the Nano. Secondly, are you using a B01 Nano with the two camera connectors? If you are then you need to ensure the camera is connected to the connector nearest to the DC power supply barrel, because by default the code points to this connector. You can test if your camera is connected properly by typing the following line into the terminal: ls -l dev/video0. If the camera is working and properly connected it should return a listing indicating that a video device is present.