Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用OpenCV VideoWriter保存灰度图像时发生Gstreamer错误_Python_Opencv_Gstreamer - Fatal编程技术网

Python 使用OpenCV VideoWriter保存灰度图像时发生Gstreamer错误

Python 使用OpenCV VideoWriter保存灰度图像时发生Gstreamer错误,python,opencv,gstreamer,Python,Opencv,Gstreamer,我可能错过了一些非常明显的东西,但我似乎无法让这一切顺利进行。 我正在从灰度相机读取帧,然后我想通过OpenCV VideoWriter中的gstreamer编码到H265 这是我的gstreamer管道: gst_out =('appsrc caps=video/x-raw,format=GRAY8,width=1280,height=800,framerate=30/1 ! ' 'videoconvert ! omxh265enc ! video/x-h265, stream-for

我可能错过了一些非常明显的东西,但我似乎无法让这一切顺利进行。 我正在从灰度相机读取帧,然后我想通过OpenCV VideoWriter中的gstreamer编码到H265

这是我的gstreamer管道:

gst_out =('appsrc caps=video/x-raw,format=GRAY8,width=1280,height=800,framerate=30/1 ! '
    'videoconvert ! omxh265enc ! video/x-h265, stream-format=byte-stream ! '
    'h265parse ! filesink location=test.h265 ')

writer= cv2.VideoWriter(gst_out, cv2.CAP_GSTREAMER, 0, 30, (1280, 800), True)
但是当我尝试在其中写入帧时,我得到了错误

[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (1629) writeFrame OpenCV | GStreamer warning: cvWriteFrame() needs images with depth = IPL_DEPTH_8U and nChannels = 3.
我不理解,因为它应该接受GRAY8格式,并且我已经验证了该帧仅作为一个通道。如果我将帧转换为BGR,它可以工作,但这不是我想要的,因为我只需要保存灰度图像,我也不明白为什么在管道中指定GRAY8时它会接受BGR帧


非常感谢您的帮助。

如果您打算创建灰度视频,那么为什么要将
isColor
参数设置为
True
来构建
cv2.VideoWriter
?哦,天哪,您说得对!我知道我在某处犯了一些愚蠢的错误,我现在觉得自己很愚蠢。非常感谢!不用担心,这是常有的事:)