2016-10-12 159 views
0

我正在开发一个程序,捕捉raspicam和流与GStreamer。捕捉raspicam的第一门课程没有问题。但是,下一个课程有一个很大的问题。我创建了总共2个源代码(服务器,客户端)。流数据非常缓慢。我可以有办法改善它吗?使用OpenCV流视频,GStreamer

请帮帮我。

谢谢。

----------- Server.cpp(覆盆子裨,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; 
} 

}

+0

_“我可以有办法改进它吗?”_你可能最好在[SE Code Review](http://codereview.stackexchange.com/)上询问以改进工作代码。 –

+0

嗨,先生!你是如何解决这个问题的?我也有同样的问题。谢谢! –

回答

0

你可能会使用一个UDP流,而不是TCP中获益。查看this link,其中一个视频从rpi流式传输到pc,仅延迟100 ms。