IMX477 Camera and the Hello Camera Jupyter Notebook

Hi I’m trying to run the DLI Getting Started with AI Course using my IMX477 Rasp pi HQ camera. I’m using the ribbon cable if that is relevant. I have removed the R8 resistor from the camera board, got the IMX477 driver and tested that the camera can connect and stream using

nvgstcapture-1.0

I have had a good search and while I find people getting the same error I’m not sure the solutions are appropriate in my case.

This is my script that I run, the container tag is checked against the Jetpack version (4.4.1):

echo “sudo docker run --runtime nvidia -it --rm --network host
–volume ~/nvdli-data:/nvdli-nano/data
–volume /tmp/argus_socket:/tmp/argus_socket
–device /dev/video0
nvcr.io/nvidia/dli/dli-nano-ai:v2.0.1-r32.4.4” > docker_dli_run.sh

I feel there is something else I need to do to make it work. When I run the first cell in the Hello Camera notebook to check the camera is available I don’t get an error:

crw-rw---- 1 root video 81, 0 Aug 18 08:43 /dev/video0

But I get an error when I run the second cell in the notebook. The error I get is:


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

RuntimeError: Could not read image from camera.

During handling of the above exception, another exception occurred:

RuntimeError Traceback (most recent call last)
in
1 from jetcam.csi_camera import CSICamera
2
----> 3 camera = CSICamera(width=224, height=224, capture_device=0) # confirm the capture_device number

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

RuntimeError: Could not initialize camera. Please see error trace.

Can anyone advice how I make this notebook work with the HQ camera, I’d like to go through it properly with this camera. Please spoon feed me the information if possible, I’m not very experienced.

Thanks very much

EDIT:
I don’t know if this is relevant but when I check opencv like this:

$ python
Python 2.7.17 (default, Jul 1 2022, 15:56:32)
[GCC 7.5.0] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import cv2
print cv2.version
4.1.1

I have the correct version for Jetpack 4.4.1 but when I do this:

$ ls /etc/nvidia-container-runtime/host-files-for-container.d/
cuda.csv cudnn.csv l4t.csv tensorrt.csv visionworks.csv

I see that I don’t have an opencv.csv.

EDIT 2:
I also see that at the top of my error it says:
/usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg/jetcam/csi_camera.py

I have nothing inside my /usr/local/lib/python3.6/dist-packages/

Hi,
Probably the camera is not successfully terminated so it fails in second run. When it fails, please try the gst-launch-1.0 command and check if the camera is still functioning:

gst-launch-1.0 -e nvarguscamerasrc ! fakesink

Hi, Thanks for the reply

By second run do you mean when I try it through the notebook after having used nvgstcapture-1.0 on the host ? (I have never been able to start the camera in the notebook)

When I run the following command inside and outside the container

gst-launch-1.0 -e nvraguscamerasrc ! fakesink

I get this error:

WARNING: erroneous pipeline: no element “nvraguscamerasrc”

I also tried running this before restarting the container but it made no difference:

sudo systemctl restart nvargus-daemon

Hi,
Sorry there was a typo. It is nvarguscamerasrc. I have corrected it.

Hi ,

Thanks, I ran it outside the container and this is what my terminal says:

$ gst-launch-1.0 -e nvarguscamerasrc ! fakesink
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected…
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 4032 x 3040 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 22.250000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1920 x 1080 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 22.250000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 2592 x 1944 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 22.250000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 2560 x 1440 FR = 40.000000 fps Duration = 25000000 ; Analog Gain range min 1.000000, max 22.250000; Exposure Range min 13000, max 683709000;

GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 1
Output Stream W = 1920 H = 1080
seconds to Run = 0
Frame Rate = 59.999999
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.

What is the next step?

Thanks very much

Hi,
Are you able to run the same command inside container? Looks like the camera is good so it probably misses certain device nodes in the container.

Hi,

This is the error

allow 10 sec for JupyterLab to start @ http://IPaddress:8888 (password dlinano)
JupterLab logging location: /var/log/jupyter.log (inside the container)
root@USER-desktop:/nvdli-nano# gst-launch-1.0 -e nvarguscamerasrc ! fakesink
WARNING: erroneous pipeline: no element “nvarguscamerasrc”

Hi,
Please check if you can use this image directly:
Jetbot camera not working on jupyter notebook - #7 by DaneLLL

If not, would need to manually include the nodes to have NVIDIA plugins. This post may help:
Jupyter Notebook in Jetson Nano - #2 by jaybdub

I have now got rid of the error after running the second cell and I’ve got the widget to appear with the camera stream.

I’m not sure exactly what I did that fixed it but this is the last activities I did, in detail so that other newbies like myself can see it:

First I did tried to get jetcam again as I couldnt find any directories matching the error message’s path “/usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg/jetcam/csi_camera.py”

user@user-desktop:~$ git clone GitHub - NVIDIA-AI-IOT/jetcam: Easy to use Python camera interface for NVIDIA Jetson
fatal: destination path ‘jetcam’ already exists and is not an empty directory.
I went into the jetcam folder where it was located for me and
user@user-desktop:~$ cd jetcam
user@user:~/jetcam$ sudo python3 setup.py install
This installed /usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg, which I didn’t have present on my system.

This file “jetcam-0.0.0-py3.6.egg” was a zip file and I then unzipped it:

user@user-desktop:/usr/local/lib/python3.6/dist-packages$ sudo unzip jetcam-0.0.0-py3.6.egg

Now I had two folders in dist-packages (jetcam and EGG-INFO) plus the jetcam-0.0.0-py3.6.egg zip file. Then I had to delete the zip file in order to create a new directory with the same name

user@user-desktop:/usr/local/lib/python3.6/dist-packages$ sudo unlink jetcam-0.0.0-py3.6.egg

I then made a new directory called jetcam-0.0.0-py3.6.egg

user@user-desktop:/usr/local/lib/python3.6/dist-packages$ sudo mkdir jetcam-0.0.0-py3.6.egg

And moved the jetcam directory to this new directory

user@user-desktop:/usr/local/lib/python3.6/dist-packages$ sudo mv /usr/local/lib/python3.6/dist-packages/jetcam/ /us
r/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg/

Now my csi_camera.py file was in the right directory

I ran $ ./docker_dli_run.sh and inside the container I could successfully run:

gst-launch-1.0 -e nvarguscamerasrc ! fakesink

Without an error. When I went into the notebook I could get past cell two for the first time and get the widget.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.