IMX519 Orin Nano Dev Kit Pipeline in OpenCV

I am running 35.3.1 on Orin Nano Dev Kit and trying to run Arducam IMX519 via MIPI interface. I get camera input via

FRAMERATE = 0
gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! "video/x-raw(memory:NVMM),width=4656,height=3496,framerate=$FRAMERATE/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=4656,height=3496,framerate=$FRAMERATE/1" ! nv3dsink 

To run the pipeline in a python script, I replace sink with appsink and add queue but it doesn’t work. On terminal, the following command

gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! "video/x-raw(memory:NVMM),width=4656,height=3496,framerate=$FRAMERATE/1" ! nvvidconv ! "video/x-raw(memory:NVMM),width=4656,height=3496,framerate=$FRAMERATE/1"! queue ! appsink

gives this and hangs ( I am assuming it’s supposed to do that)

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: 4656 x 3496 FR = 10.000000 fps Duration = 100000000 ; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 3840 x 2160 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 13000, max 683709000;

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

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

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

My python code is as follows:

self.cap = cv2.VideoCapture("nvarguscamerasrc sensor-id=0 ! "
        "video/x-raw(memory:NVMM),width=4656,height=3496,framerate=9/1 !"  
        "nvvidconv ! video/x-raw(memory:NVMM),width=4656,height=3496,framerate=9/1 !"
        "queue ! appsink", cv2.CAP_GSTREAMER)

The error I get is

RuntimeError: Failed to open camera!

What things can I try and how to debug the issue? Is this still a camera driver issue or maybe the OpenCV, pipeline configuration problem? Thank you in advance.

So if your opencv installation was not built with gstreamer support i.e.

import cv2
print(cv2.getBuildInformation())

Video I/O:
DC1394:                      NO
FFMPEG:                      NO
  avcodec:                   NO
  avformat:                  NO
  avutil:                    NO
  swscale:                   NO
  avresample:                NO
GStreamer:                   NO   <==THIS
libv4l/libv4l2:              NO
v4l/v4l2:                    linux/videodev2.h

then cv2.videoCapture with gstreamer pipeline string is not going to work.

You might want to install a version of opencv that comes with gstreamer support, or in worst scenario compile opencv yourself.

More info:

@picopotato

Nvidia has its version of OpenCV.
You need to delete OpenCV yourself first, and then install it using the following command

sudo apt install nvidia-opencv-dev
sudo apt install nvidia-opencv

PS: pls be sure OpenCV has been deleted before installation.