简体   繁体   中英

Stream video using OpenCV, GStreamer

I am developing a program that is capturing raspicam and streaming with GStreamer. The first course, capturing raspicam doesn't have problem. But, the next course is have a big problem. I was created a total of 2 of sources code (server, client). Streaming data is very slow. Can I have a way to improve it?

Please, help me.

Thank you.

----------- 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;
}

}

You might benefit from using a udp stream instead of tcp. Check out this link for an example where a video was streamed from rpi to pc with only 100 ms lag.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM