c++ - 使用 OpenCV、GStreamer 流式传输视频

标签 c++ opencv streaming gstreamer

我正在开发一个程序,用于捕获 raspicam 并使用 GStreamer 进行流式传输。第一门类(class),捕获raspicam没有问题。但是,接下来的类(class)就有大问题了。我总共创建了 2 个源代码(服务器、客户端)。流数据非常慢。我能有办法改善吗?

请帮助我。

谢谢。

------------ Server.cpp(Raspberry Pi、Raspbian)----------

cap.set(CAP_PROP_FPS, 30);
cap.open(0);
//  Movie Frame Setup

fps         =   cap.get(CAP_PROP_FPS);
width       =   cap.get(CAP_PROP_FRAME_WIDTH);
height      =   cap.get(CAP_PROP_FRAME_HEIGHT);
cout << "Capture camera with " << fps << " fps, " << width << "x" << height << " px" << 

writer.open("appsrc ! gdppay ! tcpserversink host=192.168.0.29 port=5000", 0, fps, cv::Size(width, height), true);

while(1){
        printf("AA");
        cap >> frame;
        writer << frame;


}

------------ Client.cpp(PC、Ubuntu)----------

Mat test;
String captureString = "tcpclientsrc host=192.168.0.29 port=5000 ! gdpdepay ! appsink";

VideoCapture cap(captureString);//0); 

namedWindow("t");
while(1)
{


    cap >> test;

    imshow("t", test);

    if( waitKey(10) > 0)
        break;
}

}

最佳答案

您可能会受益于使用 udp 流而不是 tcp。查看this link例如,视频从 rpi 流式传输到 PC,延迟仅为 100 毫秒。

关于c++ - 使用 OpenCV、GStreamer 流式传输视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40006284/

相关文章:

c++ - 为什么矩阵没有正确初始化/打印?

amazon-web-services - 使用 SSL 通过 https 重新传输 mp3 流

c++ - 避免 C++ 中重复的子类定义

C++11 `nullptr_t` 返回函数被省略?

c - 如何在opencv中找到图像中每个连通分量的边界像素

python - 带有OpenCV 3的OpenNI2

java - 云流式传输到 Android

ios - 在 iOS 中使用 AVPlayer 进行音频流播放时的播放速度

c++取消引用通过引用传递分配的指针,给出随机值

c++ - 许多功能的相同模板