I am attempt to use a gstreamer pipeline to pick up frames from nvarguscamerasrc, convert them to rgba, and grab them for processing at the application level using OpenCV.
I have two problems:
- nvvidconv appears to have some strange undocumented constraints on its behaviour.
This pipeline:
gst-launch-1.0 nvarguscamerasrc ! capsfilter caps="video/x-raw(memory:NVMM),width=(int)4032,height=(int)3040,format=(string)NV12,framerate=(fraction)30/1" ! nvvidconv ! capsfilter caps="video/x-raw(memory:NVMM),format=(string)RGBA" ! autovideosink
… crashes with:
ERROR: from element /GstPipeline:pipeline0
/GstNvArgusCameraSrc:nvarguscamerasrc0: Internal data stream error
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0
/GstNvArgusCameraSrc:nvarguscamerasrc0:
streaming stopped, reason not-linked (-1)
Execution ended after 0:00:02.980244275
But when we scale the video down to an arbitrary undocumented limit I found by trial and error:
gst-launch-1.0 nvarguscamerasrc ! capsfilter caps="video/x-raw(memory:NVMM),width=(int)4032,height=(int)3040,format=(string)NV12,framerate=(fraction)30/1" ! nvvidconv ! capsfilter caps="video/x-raw(memory:NVMM),format=(string)RGBA,width=3344,height=2508" ! autovideosink
… we have a working preview.
Why?
- Behaviour appears to differ between “gst-launch-1.0”, and the VideoCapture object
The stream above, while functioning just fine from gst-launch, fails if we run it through an OpenCV VideoCapture object to an appsink:
string pipeline = "nvarguscamerasrc ! capsfilter caps=\"video/x-raw(memory:NVMM),width=(int)4032,height=(int)3040,format=(string)NV12,framerate=(fraction)30/1\" ! nvvidconv ! "
" capsfilter caps=\"video/x-raw(memory:NVMM),format=(string)RGBA,width=3344,height=2508\" ! appsink";
GSTcam::GSTcam(ViewPt screensize):CameraBase(screensize), VideoCapture(pipeline, cv::CAP_GSTREAMER)
{
// do stuff
}
… this doesn’t work at all, with the unhelpful message:
[ 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 nvarguscamerasrc0 reported: Internal data stream error.
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (886) open OpenCV | GStreamer warning: unable to start pipeline
[ 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
“Internal data stream error” isn’t much to go on.
Neither gstreamer nor opencv is actually necessary to my work… I simply need to grab argus frames at full resolution, convert them to RGBA, and pass them to my code as a raw buffer at 30 fps.
But documentation is… sparse.
Can anyone point me in the direction of something helpful?