Opencv Gstreamer pipeline not working

Hi,

I am using a gstreamer pipeline with nvarguscamerasrc in opencv like this:

GSTREAMER_PIPELINE = "nvarguscamerasrc sensor-mode=0   exposuretimerange='1000000 1000000' wbmode=0 gainrange='1 1' " \
                     "ispdigitalgainrange='1 1' tnr-mode=2 tnr-strength=1.0 ee-mode=2 bufapi-version=1 ! " \
                     "'video/x-raw(memory:NVMM), width=3264, height=2464, format=(string)NV12, framerate=21/1' ! " \
                     "nvvidconv flip_method=2 ! " \
                     "'video/x-raw(memory:NVMM), width=3264, height=2464, format=(string)BGRx framerate=21/1' ! " \
                     "videoconvert ! " \
                     "video/x-raw, format=(string)BGR ! " \
                     "appsink"


def main():
        capture = cv2.VideoCapture(GSTREAMER_PIPELINE, cv2.CAP_GSTREAMER)
        logging.info("Started grabbing images")
        while capture.isOpened():
            ret, frame = capture.read()
            if ret:
                print("frame received")
            else:
                break

But all I get as output is:

                   
GST_ARGUS: NvArgusCameraSrc: Setting Exposure Time Range : '1000000 1000000'                                       
GST_ARGUS: NvArgusCameraSrc: Setting Gain Range : '1 1'                                                            
GST_ARGUS: NvArgusCameraSrc: Setting ISP Digital Gain Range : '1 1'                                                
                                                                                                                   
(python3:22798): GStreamer-CRITICAL **: 07:53:15.430: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)'
 failed                                                                                                            
                                                                                                                   
(python3:22798): GStreamer-CRITICAL **: 07:53:15.432: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)'
 failed            

No “frame received” is printed out. Is the pipeline wrong?

Thanks

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

If yes, you can adapt your gstreamer pipeline to the sample and try again. For comparison, you can also try to run the gstreamer pipeline in gst-launch-1.0 command and replace appsink with fakesink. To check if the pipeline works fine in gst-launch-1.0.

Thanks @DaneLLL,

The working pipeline is

nvarguscamerasrc sensor-mode=0   exposuretimerange='1000000 1000000' wbmode=0 gainrange='1 1' ispdigitalgainrange='1 1' tnr-mode=2 tnr-strength=1.0 ee-mode=2 ! video/x-raw(memory:NVMM), width=(int)3264, height=(int)2464,format=(string)NV12, framerate=(fraction)21/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert !  appsink"

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