如何在OpenCV中打开GSTREAMER管道
我正在尝试使用OpenCV程序中的Gstreamer Pipeline打开 WebM 视频。
我正在Visual Studio 19 Community IDE中使用OpenCV 3.4.1。
#include <opencv2/opencv.hpp>
int main()
{
std::string pipeline = "playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
std::cout << "Using pipeline: \n" << pipeline << "\n";
cv::VideoCapture cap(pipeline, cv::CAP_GSTREAMER);
if (!cap.isOpened()) {
std::cout << "Failed to open camera." << std::endl;
return (-1);
}
cv::namedWindow("CSI Camera", cv::WINDOW_AUTOSIZE);
cv::Mat img;
std::cout << "Hit ESC to exit" << "\n";
while (true)
{
if (!cap.read(img)) {
std::cout << "Capture read error" << std::endl;
break;
}
cv::imshow("CSI Camera", img);
int keycode = cv::waitKey(10) & 0xff;
if (keycode == 27) break;
}
cap.release();
cv::destroyAllWindows();
return 0;
}
我无法打开vieocapture cap
;我该怎么做?
I'm trying to open webm video using GStreamer pipeline in OpenCV program.
I'm using OpenCV 3.4.1 in Visual Studio 19 Community IDE.
#include <opencv2/opencv.hpp>
int main()
{
std::string pipeline = "playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
std::cout << "Using pipeline: \n" << pipeline << "\n";
cv::VideoCapture cap(pipeline, cv::CAP_GSTREAMER);
if (!cap.isOpened()) {
std::cout << "Failed to open camera." << std::endl;
return (-1);
}
cv::namedWindow("CSI Camera", cv::WINDOW_AUTOSIZE);
cv::Mat img;
std::cout << "Hit ESC to exit" << "\n";
while (true)
{
if (!cap.read(img)) {
std::cout << "Capture read error" << std::endl;
break;
}
cv::imshow("CSI Camera", img);
int keycode = cv::waitKey(10) & 0xff;
if (keycode == 27) break;
}
cap.release();
cv::destroyAllWindows();
return 0;
}
I can't open VieoCapture cap
; how do I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
要在CV ::视频贴上使用GSTREAMER管道,它必须以AppSink结束。 AppSink是GSTREAMER元素,允许应用程序(在这种情况下为OpenCV)将缓冲区从管道中取出。
修改管道以如下图:
To use a GStreamer pipeline in a cv::VideoCapture it must end in an appsink. The appsink is a GStreamer element that allows an application (in this case OpenCV) to take buffers out of the pipeline.
Modify your pipeline to look like the following: