c++ - 在 Yocto Linux 中使用 Opencv 的 Gstreamer
问题描述
我有两个在不同处理器上运行的 Yocto 构建,我正在尝试使用 GStreamer 编写 OpenCV 代码,其中一个将发送数据包,另一个将接收。我面临的问题是,在接收器脚本中,程序卡在“VideoCapture”函数中并且没有进一步执行。接收器与HDMI屏幕连接,运行目标文件后显示器没有变化。下面我附上代码。
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
using namespace std;
using namespace cv;
int main(void)
{
cout<<"in main function"<<endl;
const char* gstrec="udpsrc port=5000 ! application/x-rtp,media=video,encoding-name=H264,payload=96,clock-rate=90000,framerate=30/1 ! \
rtpjitterbuffer latency=10 drop-on-latency=TRUE ! rtph264depay ! video/x-h264 ! h264parse ! decodebin ! video/x-raw,\
format=NV12 ! videoconvert ! video/x-raw,format=BGR ! appsink";
cout<<"Gstreamer script running"<<endl;
VideoCapture cap(gstrec,CAP_GSTREAMER);
cout<<"You are out of VideoCapture function"<<endl;
if(!cap.isOpened())
{
cout<<"VideoCapture not opened"<<endl;
exit(-1);
}
cout<<"The videocapture is opened"<<endl;
Mat frame;
for(;;) {
cap.read(frame);
if(frame.empty())
break;
cout<<"In while loop"<<endl;
imshow("Receiver", frame);
if(waitKey(1) == 'r')
break;
}
destroyWindow("Receiver");
return 0;
}
这是输出:
在主函数中
Gstreamer 脚本运行
[信息] bitstreamMode 1,chromaInterleave 0,mapType 0,tiled2LinearEnable 0
请注意,'cout << you are out of videocapture' 语句不会打印在屏幕上,并且连接到接收器的显示器没有显示任何变化。
解决方案
推荐阅读
- javascript - Angular 中的依赖注入组件
- python - 显示值的次数问题
- spring-boot - 将主键映射到 JPA 中的复合键
- python - 遍历字典,搜索副本并将副本列表附加到列表中
- java - RabbitMQ,Spring AMQP - 将不存在的队列订阅为独占或自动删除
- c# - 统一出现错误 IndexOutOfRange 但仍在工作
- r - ggplot2的主效应图
- rasa-nlu - 在 RASA 中使用历史聊天数据的步骤是什么
- rdf - 如何用 rdf/rdfs/owl 声明一个类的实例负责/与一个类的所有实例相关?
- docker - 带有 Docker Compose 文件的 AWS ECS -“外部”Docker 卷