OpenCV C++ GStreamer Capture Issue

Hello, I am attempting to use OpenCV 4.1.1 to open a capture instance with gstreamer to pull in frames from a MIPI camera attached to my Nvidia jetson NX Dev Kit. The driver for the camera is properly installed, and running GStreamer from the command line using the command below works just fine:

gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! “video/x-raw(memory:NVMM), width=1280, height=800, format=(string)NV12” ! nvvidconv ! “video/x-raw, width=1280, height=800, format=(string)GRAY8” ! videoscale ! video/x-raw, width=800, height=600 ! videoconvert ! xvimagesink

However, when I try and open the camera in OpenCV C++ (version 4.1.1), using the following:
cv::VideoCapture cap(‘nvarguscamerasrc ! “video/x-raw(memory:NVMM), width=1280, height=800, format=(string)NV12” ! nvvidconv ! “video/x-raw, width=1280, height=800, format=(string)GRAY8” ! videoscale ! video/x-raw, width=800, height=600 ! videoconvert ! appsink’, CAP_GSTREAMER);

I get the error:
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (1757) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Cannot identify device ‘/dev/video1936289387’.

The camera is at /dev/video0, how do I get the API to open the proper device ?

Hi,
It looks like gstreamer is not enabled in the OpenCV package. Do you use the package installed through SDKManager?

Hello, yes I installed openCV via the SDK Manager, version 4.1.1 for Jetpack 4.6

Hi,
Please check if you can run this sample:
OpenCV Video Capture with GStreamer doesn't work on ROS-melodic - #3 by DaneLLL

The sample should work well with default OpenCV package. Please give it a try.

Hello, so it turns out I needed double quotes around my string in the function:

cv::VideoCapture cap(“nvarguscamerasrc ! ‘video/x-raw(memory:NVMM), width=(int)1280, height=(int)800,format=(string)NV12, framerate=(fraction)30/1’ ! nvvidconv ! ‘video/x-raw, format=(string)BGRx’ ! videoconvert ! appsink”, CAP_GSTREAMER);

However, the function now produces the error shown here:

OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module1
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
---- imager: No override file found. ----
(NvCamV4l2) Error ModuleNotPresent: V4L2Device not available (in /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function findDevice(), line 256)
(NvCamV4l2) Error ModuleNotPresent: (propagating from /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function initialize(), line 60)
(NvOdmDevice) Error ModuleNotPresent: (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/devices/V4L2SensorViCsi.cpp, function initialize(), line 107)
NvPclDriverInitializeData: Unable to initialize driver v4l2_sensor
NvPclInitializeDrivers: error: Failed to init camera sub module v4l2_sensor
NvPclStartPlatformDrivers: Failed to start module drivers
NvPclStateControllerOpen: Failed ImagerGUID 1. (error 0xA000E)
NvPclOpen: PCL Open Failed. Error: 0xf
SCF: Error BadParameter: Sensor could not be opened. (in src/services/capture/CaptureServiceDeviceSensor.cpp, function getSourceFromGuid(), line 582)
SCF: Error BadParameter: (propagating from src/services/capture/CaptureService.cpp, function addSourceByGuid(), line 437)
SCF: Error BadParameter: (propagating from src/api/CameraDriver.cpp, function addSourceByIndex(), line 305)
SCF: Error BadParameter: (propagating from src/api/CameraDriver.cpp, function getSource(), line 471)
Acquiring SCF Camera device source via index 0 has failed. ---- imager: No override file found. ----
LSC: LSC surface is not based on full res!

(CLD:21151): GStreamer-CRITICAL **: 15:05:25.874: gst_element_make_from_uri: assertion ‘gst_uri_is_valid (uri)’ failed

(CLD:21151): GStreamer-CRITICAL **: 15:05:25.876: gst_element_make_from_uri: assertion ‘gst_uri_is_valid (uri)’ failed
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (711) open OpenCV | GStreamer warning: Error opening bin: syntax error
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

I can open the camera just fine using Gstreamer from the command line, and the Python program that you linked can also open the camera, it is only during the use of OpenCV in C++ where i get an error. The error also only occurs when the source is from nvarguscamsrc and not v4l2src (v4l2src works just fine in C++). I need to use nvarguscamsrc with my camera because it is a MIPI camera. Any ideas on what may be causing this new error?

Hi,
There are OpenCV samples in
Jetson Linux R32.7.1 Release Page | NVIDIA Developer

L4T Driver Package (BSP) Sources

Please check if you can run the samples successfully.

Thank you for the suggestion, running this code worked for me!

1 Like

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