open stream video takes ages

asked 2017-06-14 10:56:15 -0600

johnst gravatar image

Hi everyone! I am about to create a program with Visual Studio 2015, which streams video from an IP camera. The program is written in C++ and runs correctly except a latency problem. Using the code below:

if (!vcap.open(videoStreamAddress)) {
    printf("Error opening video stream or file \n");
}
else {
    if (!vcap.read(image)) {    //capture image
        cv::waitKey();          //if no image captured wait
    }
    else {
        cv::imshow("Output Window", image); //open output window and show the image
        if (cv::waitKey(1) >= 0) break; //wait 1ms if key 1 from keyboard pressed -> break
    }
}

I get a latency at start up. The problem is that the vcap.open(videoStreamAddress)takes about 2-5 minutes to run. After that, I get a nice video stream without any lag. The videoStreamAddress is something like that: http://192.168.1.7:78080. I am using OpenCV v3.1.0. The IP camera is actually a raspberry Pi 3 connected with a USB web cam and running Motion. Streaming from raspberry Pi through web browser runs nice.

Thanks in advance

edit retag flag offensive close merge delete