Opencv -gst streaming error in xavier agx

we are using qt-opencv to stream mipi camera.

These are commands written

std::string gst_str=“nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1928, height=(int)1088,format=(string)NV12, framerate=(fraction)60/1 ! nvvidconv ! video/x-raw, format=(string)I420 ! videoconvert ! appsink”;

VideoCapture cap(gst_str,cv::CAP_GSTREAMER);

this is the error we are getting

nvbuf_utils: dmabuf_fd -1 mapped entry NOT found
nvbuf_utils: Can not get HW buffer from FD… Exiting…
GStreamer warning: Embedded video playback halted; module nvarguscamerasrc0 reported: TIMEOUT

What are the possible reasons for this error?

The gst command works fine in Terminal we are able to stream using terminal

Most probable reason is that you have another process still using cam or you didn’t release it properly, so argus is unable to serve it.
If not using cam from another shell, then:

  • not sure for recent releases, but at least in old ones using v4l2-ctl for CSI cam without setting control bypass_mode to 0 was fooling nvcamera.
  • I have also seen frequent argus crash reported by Ubuntu when closing opencv application by sending kill signal from Ctrl-C in terminal. argus from gstreamer from opencv seems to need proper video capture release. I achieved that in C++ with signal handling as shared here (second part).

argus daemon should also restart after one minute if you prefer to be patient ;-)

You may also monitor argus messages logged into syslog from another terminal:

tail --follow /var/log/syslog

Thank Honey Patouceul’s suggestion. Besides, please try this python sample:
OpenCV Video Capture with GStreamer doesn't work on ROS-melodic - #3 by DaneLLL
See if it is specific to qt-opencv.