我最近在32位Windows平台上使用Gstreamer 1.15.1编译了Opencv 4.2.0。当我尝试使用Gstreamer后端捕获视频时,视频捕获失败。这是代码和输出:
void main()
{
VideoCapture cap("video/x-raw,format=YUV2,width=640,height=480,framerate=30/1 ! appsink", CAP_GSTREAMER);
//VideoCapture cap(0,CAP_GSTREAMER);
if (!cap.isOpened())
{
cout << "VideoCapture not opened" << endl;
exit(-1);
}
Mat frame;
while (true) {
cap.read(frame);
if (frame.empty())
break;
imshow("output", frame);
if (waitKey(1) == 's')
break;
}
destroyWindow("output");
}
这里是输出:
(testNewOpencv.exe:7392): GStreamer-CRITICAL **: 20:08:16.574: gst_element_make_
from_uri: assertion 'gst_uri_is_valid (uri)' failed
[ WARN:0] global \modules\videoio\src\cap_gstreamer.cpp (713) cv::GStreamerCapture::open OpenCV | GStreamer warning: Error opening bin: no element "video"
[ WARN:0] global \modules\videoio\src\cap_gstreamer.cpp (480) cv::GStreamerCapture::isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
VideoCapture not opened
是否有解决问题的建议?
尝试一下:“ ksvideosrc设备索引= 0!视频比例尺!视频速率!视频/ x原始,宽度= 640,高度= 480,帧速率= 30/1!视频转换!appsink”
为我使用您的代码以及刚刚构建的OpenCV 4.3.0,gstreamer 1.15.1、32位Windows 10,USB网络摄像头为我工作。我对gstreamer不够了解,无法解释管道-我将其与部分搜索结果结合在一起。
我认为ksvideosrc来自gst-plugins-bad。