改变gstreamer管道以输出RGB

2024-05-19 16:11:22 发布

您现在位置:Python中文网/ 问答频道 /正文

你好,

我使用Jetson Nano上的Raspberry Pi照相机v2.1用gstreamer拍摄图像。我有以下gstreamer管道代码:

def gstreamer_pipeline (capture_width=3280, capture_height=2464, display_width=1280, display_height=720, framerate=21, flip_method=0) :   
    return ('nvarguscamerasrc ! ' 
    'video/x-raw(memory:NVMM), '
    'width=(int)%d, height=(int)%d, '
    'format=(string)NV12, framerate=(fraction)%d/1 ! '
    'nvvidconv flip-method=%d ! '
    'video/x-raw, width=(int)%d, height=(int)%d, format=(string)BGRx ! '
    'videoconvert ! '
    'video/x-raw, format=(string)BGR ! appsink'  % (capture_width,capture_height,framerate,flip_method,display_width,display_height))

现在输出BGR格式的图像,但我需要RGB。当我尝试更改格式字符串时,出现以下错误:

OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp, line 887
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:

/home/nvidia/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp:887: error: (-2) GStreamer: unable to start pipeline
 in function cvCaptureFromCAM_GStreamer

所以我的问题是:如何修改管道以正确输出RGB?或者我使用的硬件组合不可能做到这一点

提前谢谢你的回答


Tags: formatrawpipelinevideodisplaywidthopencvmethod