Opencv videocapture with CSI camera IMX219

I am trying to use the videocapture functio from opencv2 with a IMX219 CSI camera onboard, but I have been unable to open the camera after many tries.

I have followed code from here: OpenCV Video Capture with GStreamer doesn't work on ROS-melodic - #3 by DaneLLL

trying to use a gstreamer like:

“nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! appsink”

and also from here: https://github.com/JetsonHacksNano/CSI-Camera/blob/master/simple_camera.py

but in both cases the camera fails to open.

Even trying to launch camera from command line using:

gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink

returns an error of:


(gst-launch-1.0:1296): GStreamer-CRITICAL **: 22:53:18.112: gst_mini_object_set_qdata: assertion 'object != NULL' failed

Can anyone point me in the right direction for this?

Hi,
Do you use Raspberry Pi camera v2? By default this camera is supported. If you use other imx219, would need to contact vendor to get support for porting sensor driver.

Hi,

Yes I have the camera v2. When I run some form of:
gst-launch-1.0 nvarguscamerasrc
I can get the camera to launch. It is mainly trying to format a gstreamer that causes problems

Hi,
Please run this and check if you can see camera preview:

$ gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink

Hi, i currently have the same issue with a camera imx219 stereo, and your command line actually worked on my computer, the camera is working, how should i include this in cv2 ? (and also how can i access to my second camera ?)

Running this code returns:

dylan@dylan-desktop:~$ gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:656 Failed to create CaptureSession

(gst-launch-1.0:15659): GStreamer-CRITICAL **: 11:57:01.785: gst_mini_object_set_qdata: assertion 'object != NULL' failed
Got EOS from element "pipeline0".
Execution ended after 0:00:00.011085065

I have tried searching for solutions related to this error but have not found much.

Hi @kevinmaxihu
Please try this sample:
[Gstreamer] nvvidconv, BGR as INPUT - #4 by DaneLLL

Hi @daphilpot01 please clean gstream cache or reboot the system for a try. If either way does not work we would suggest re-flash the system to latest Jetpack 4.6.1. Raspberry Pi camera v2 should work well on default image. It is not expected the command fails.

The command for cleaning cache:

$ rm .cache/gstreamer-1.0/registry.aarch64.bin

Clearing cache did not work

Edit: I have reflashed and checked my version of Jetpack. Still nothing.

Hi @daphilpot01 probably your imx219 is from other vendor?

This one is supported by default:
Buy a Raspberry Pi Camera Module 2 – Raspberry Pi

tried the sample code and it return camera open failed where is the problem ?
and if it can help, this is the output after gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink command :

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: 3264 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: 3264 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: 1640 x 1232 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: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:59.355823799
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
GST_ARGUS: Cleaning up
CONSUMER: Done Success
GST_ARGUS: Done Success
Setting pipeline to NULL ...
Freeing pipeline ...```

I do not believe the problem is with the IMX219.

When I run:
ls /dev/video0
it returns
/dev/video0
so the nano is certainly recognizing the camera.

$ gst-launch-1.0 nvarguscamerasrc sensor-id=<id> ! nvoverlaysink

  1. test this camera to the other HW, ie RP or other Jetson Nano
  2. use any other cameras
    Camera module might be DOA.

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