Raspberry Pi camera not working while trying to run csi_camera.ipynb on the dlinano course

I’m currently going through the dlinano course and just got a new pi camera to test on my nano. I’m able to see that the camera is detected using the command,

!ls -ltrh /dev/video*

crw-rw----+ 1 root video 81, 0 Jul 21 16:12 /dev/video0

But when I run the line,

camera = CSICamera(width=224, height=224)

it freezes.

I tried releasing the camera using,

sudo systemctl restart nvargus-daemon and shutting down and restarting kernels. No results.

I tried running the script to read and display frames from a pi camera using opencv gstreamer from this https://devtalk.nvidia.com/default/topic/1049269/jetson-nano-raspberry-pi-camera-not-working/ and i get the following on the console and it freezes again,


0:00:00.098098414 10904 0x23a62190 FIXME default gstutils.c:3963:gst_pad_create_stream_id_internal:nvarguscamerasrc0:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected…
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3280 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 3280 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 120.000005 fps Duration = 8333333 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

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


I’m suspecting my camera itself to be faulty as many people who reported similar problems in the forums said replacing the camera fixed their issue. But I’d like to confirm if I’m doing it right before replacing the camera and want to try any fixes. Any help will be appreciated.

So I actually ran into this exact issue and what I learned was that JetPack version 4.2 did not come with the Gstreamer flag set to true for the version of OpenCV that Nvidia includes in that release. In order for me to overcome this, I needed to rebuild OpenCV with the “Gstreamer flag set to true” on my board.

As a heads up, it took my jetson nano board approximately 6 hours to fully rebuild it and you also probably want to watch out for the memory consumption that’s involved with the overall process.

I hope this helps!

The following is my OpenCV build information and I think it was built with Gstreamer on judging from this. Do you remember seeing something similar?

General configuration for OpenCV 3.3.1 =====================================
Version control: 3.3.1-2-g31ccdfe11

Timestamp: 2019-02-06T09:45:58Z
Host: Linux 4.9.140-tegra aarch64
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release

CPU/HW features:
Baseline: NEON FP16
required: NEON
disabled: VFPV3

Built as dynamic libs?: YES
C++11: YES
C++ Compiler: /usr/bin/c++ (ver 7.3.0)
C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release):
Linker flags (Debug):
ccache: NO
Precompiled headers: NO
Extra dependencies: dl m pthread rt /usr/lib/aarch64-linux-gnu/libtbb.so
3rdparty dependencies:

OpenCV modules:
To be built: core flann imgproc ml objdetect photo video dnn imgcodecs shape videoio highgui superrests features2d calib3d stitching videostab python2 python3
Disabled: js world
Disabled by dependency: -
Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java viz

GTK+ 2.x: YES (ver 2.24.32)
GThread : YES (ver 2.56.3)
GtkGlExt: NO
OpenGL support: NO
VTK support: NO

Media I/O:
ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver )
WEBP: build (ver encoder: 0x020e)
PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.34)
TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 - 4.0.9)
JPEG 2000: build (ver 1.900.1)

Video I/O:
DC1394 1.x: NO
DC1394 2.x: NO
avcodec: YES (ver 57.107.100)
avformat: YES (ver 57.83.100)
avutil: YES (ver 55.78.100)
swscale: YES (ver 4.8.100)
avresample: NO
base: YES (ver 1.14.1)
video: YES (ver 1.14.1)
app: YES (ver 1.14.1)
riff: YES (ver 1.14.1)
pbutils: YES (ver 1.14.1)
OpenNI: NO
OpenNI PrimeSensor Modules: NO
OpenNI2: NO
GigEVisionSDK: NO
Aravis SDK: NO
UniCap: NO
UniCap ucil: NO
Xine: NO
Intel Media SDK: NO
gPhoto2: NO

Parallel framework: TBB (ver 2017.0 interface 9107)

Trace: YES ()

Other third-party libraries:
Use Intel IPP: NO
Use Intel IPP IW: NO
Use VA: NO
Use Intel VA-API/OpenCL: NO
Use Lapack: NO
Use Eigen: YES (ver 3.3.4)
Use Cuda: NO
Use OpenCL: NO
Use OpenVX: NO
Use custom HAL: YES (carotene (ver 0.0.1))

Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.15)
Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.15rc1)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
packages path: lib/python2.7/dist-packages

Python 3:
Interpreter: /usr/bin/python3 (ver 3.6.7)
Libraries: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (ver 3.6.7)
numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.13.3)
packages path: lib/python3.6/dist-packages

Python (for build): /usr/bin/python2.7

ant: NO
Java wrappers: NO
Java tests: NO

Matlab: Matlab not found or implicitly disabled

Doxygen: NO

Tests and samples:
Tests: YES
Performance tests: YES
C/C++ Examples: YES

Install path: /usr

cvconfig.h is in: /home/nvidia/build_opencv/build

Also, while I tried the command from https://github.com/JetsonHacksNano/CSI-Camera this link,

gst-launch-1.0 nvarguscamerasrc ! ‘video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12’ ! nvvidconv flip-method=0 ! ‘video/x-raw,width=960, height=616’ ! nvvidconv ! nvegltransform ! nveglglessink -e

to test the camera, I got this error:

Setting pipeline to PAUSED …

Using winsys: x11
Pipeline is live and does not need PREROLL …
Got context from element ‘eglglessink0’: gst.egl.EGLDisplay=context, display=(GstEGLDisplay)NULL;
Setting pipeline to PLAYING …
New clock: GstSystemClock
ERROR:/dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvegltransform/gstnvegltransform.c:220:gst_nvegl_transform_decide_allocation: assertion failed: (gst_query_get_n_allocation_pools (query) > 0)
Aborted (core dumped)

Any help is appreciated!

hello saileshprem,

according to your GST messages in comment #1, your camera driver should be loaded hence the sensor capability is reported.
suggest you exclude the other process, could you please access with v4l2 standard controls,
for example,

$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=RG10 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=100

hello saileshprem,
from your OpenCV build information, yes I had something very similar. The Gstreamer flag under the Video I/O section should say “YES”. If it does not say e.g. GStreamer: YES then you need to rebuild the version of OpenCV you want with that flag in the code set to true.

I tried this and nothing prints on the console and no errors too, but is just blank for hours.

My os image is brand new and don’t have any scripts that would be affected anyway so I thought I’ll quickly try this and am building from scratch with the flag ON.

Video I/O:
– DC1394: YES (2.2.5)
– avcodec: YES (57.107.100)
– avformat: YES (57.83.100)
– avutil: YES (55.78.100)
– swscale: YES (4.8.100)
– avresample: YES (3.7.0)
– GStreamer: YES (1.14.4)
– v4l/v4l2: YES (linux/videodev2.h)

This is my Video I/O from the new build info and like you said I can see YES. It’s building now and fingers crossed to see if this will fix!

Update on recompiling opencv with Gstreamer flags, same error message and same responses in all of the above commands/codes mentioned in this thread.

I just installed a fresh dlinano image and tried to run the very first hello_camera code and I’m facing this issue. Any help will be appreciated.

Update. As a quick sanitation check, I tried checking the connection of my CSI camera by pulling the connection and it just came right off. Plugging it back in and making sure its tight and running the code again shows that I can stream the camera. I am sure I did this check before I recompiled opencv so I presume recompilation fixed my issue. Thanks!