Connect a Raspberry Pi Camera to a Nvidia Nano

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Application

Raspberry Pi

Nvidia Nano

Pi Camera V1

Pi Camera V2

Pi Camera noir

Pre-requisits Knowledge.

Pi OS installed.

Nano OS installed.

Update your OS

Update your Operating System packages.

Follow the link below to update your operating system and packages.

http://brisbaneroboticsclub.id.au/update-and-upgrade-operating-system-linux/

Important notice

There are two versions of the Pi Camera. V1 and V2. The Nvidia nano is ONLY V2 compatible. Be sure you have the correct version for your application.

There are two versions of CSI ports on your device. CSI and CSI2. They correspond to the respective camera versions V1 and V2.

Connect Camera to CSI port

Connect your camera to the Nano or Pi using the camera ribbon.

Be sure to attach the ribbon correctly to your device. See below for the correct ribbon orientation.

Connect V2 Pi camera.
Connect V2 Pi camera.
Connect Pi camera to Raspberry Pi 3B+.
Connect Pi camera to Raspberry Pi 3B+.
Connect Pi camera to Nvidia Nano.
Connect V1 Pi camera noir.

Enable Camera for Raspberry Pi

Enter the following command from the terminal CLI.

sudo raspi-config

Select ‘5 – Interfacing Options’.

Select ‘P1 Camera’ and enable it.

Check Camera is attached.

From the terminal CLI, enter the following commands.

cd /dev
ls

If your camera is attached, you should see ‘video0’. (As shown below).

Success. The camera is working!

Install PiCamera (Rapsberry Pi only)

Follow the link below to install the PiCamera.

https://picamera.readthedocs.io/en/release-1.2/install3.html

Install OpenCV

Enter the command below into the CLI to see if you have OpenCV installed.

python3 -c 'import cv2; print(cv2.__version__)'
Success, version 4.1.1 is installed.

If OpenCV is not installed, use the link below to quick install OpenCV.

http://brisbaneroboticsclub.id.au/install-opencv-on-raspberry-pi/

Github

For a Raspberry Pi, Download out python3 code to run the camera.

sudo git clone https://github.com/brisbaneroboticsclub/Connect-a-Raspberry-Pi-Camera-.git

https://github.com/brisbaneroboticsclub/Connect-a-Raspberry-Pi-Camera-

Success! Github files installed.

To test the camera, enter the following command in the terminal CLI.

python3 TestPiCam.py
Success. The code works!!!

An image should now appear on the screen. Press any key for it to close.

For the Nvidia Nano, use the Jetson Hacks github.

sudo git clone https://github.com/JetsonHacksNano/CSI-Camera.git

cd CSI-Camera

python3 simple_camera.py

An image should now appear on the screen. Press ‘ESC’ for it to close.

Error Messages

Error: Enable camera

mmal: mmal_vc_component_create: failed to create component ‘vc.ril.camera’ (1:ENOMEM)
mmal: mmal_component_create_core: could not create component ‘vc.ril.camera’ (1)
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/picamera/camera.py”, line 456, in _init_camera
self._camera = mo.MMALCamera()
File “/usr/lib/python3/dist-packages/picamera/mmalobj.py”, line 2279, in init
super(MMALCamera, self).init()
File “/usr/lib/python3/dist-packages/picamera/mmalobj.py”, line 633, in init
prefix=”Failed to create MMAL component %s” % self.component_type)
File “/usr/lib/python3/dist-packages/picamera/exc.py”, line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to create MMAL component b’vc.ril.camera’: Out of memory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “TestPiCam.py”, line 10, in
camera = PiCamera()
File “/usr/lib/python3/dist-packages/picamera/camera.py”, line 431, in init
self._init_camera(camera_num, stereo_mode, stereo_decimate)
File “/usr/lib/python3/dist-packages/picamera/camera.py”, line 460, in _init_camera
“Camera is not enabled. Try running ‘sudo raspi-config’ “
picamera.exc.PiCameraError: Camera is not enabled. Try running ‘sudo raspi-config’ and ensure that the camera has been enabled.

Solution: Enable camera

If you have enabled the camera using raspi-config, then this message can also mean the CSI camera ribbon is no installed correctly. Check the ribbon orientation as per the section above.

Error: Gstreamer warning

nvbuf_utils: Could not get EGL display connection
[ WARN:0] global /home/marty/opencv/modules/videoio/src/cap_gstreamer.cpp (711) open OpenCV | GStreamer warning: Error opening bin: no element “nvcamerasrc”
[ WARN:0] global /home/marty/opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[ERROR:0] global /home/marty/opencv/modules/videoio/src/cap.cpp (116) open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.1.1) /home/marty/opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can’t find starting number (in the name of file): nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)120/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videobalance brightness=1, contrast=1.0, hue=1.0, saturation=1.0 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink in function ‘icvExtractPattern’

Solution: Install correct github code. See above.

Did it work for you?

If this tutorial didn’t work for you, please let us know what didn’t work and we’ll try to help you.

Either use the contact form below or register an issue on the respective github issues page.

https://github.com/brisbaneroboticsclub/Connect-a-Raspberry-Pi-Camera-/issues

Contact us

    Please check your spam folder, you will receive an e-mail to confirm your submission.



    Contributors

    Marty

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.