Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Project not responding

Im running this code:

#include <iostream>
#include <sstream>
#include <ctime>
#include <string>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

int main()
{
    //create matrix for storage
    Mat feed, feed2;

    //initialize capture
    VideoCapture cap, cap2;
    cap.open("http://192.168.1.128/videostream.asf?user=admin&pwd=");
    cap2.open("http://192.168.1.110/webcam.mjpeg");

    // check if we succeeded
    if (!cap.isOpened()){
        cerr << "Failed to open video capture" << std::endl;
        cout << "cannot open camera";
        return -1;
    }
    if (!cap2.isOpened()){
        cerr << "Failed to open video capture" << std::endl;
        cout << "cannot open camera";
        return -1;
    }

    //create window to show image
    namedWindow("VIDEO", 1); 

    //loop
    while (true){

        //copy webcam stream to image
        cap >> feed;
        cap2 >> feed2;

        resize(feed, feed, Size(1270, 700), 0, 0, INTER_CUBIC);
        resize(feed2, feed2, Size(320, 170), 0, 0, INTER_CUBIC);

        feed2.copyTo(feed(cv::Rect(874,463,feed2.cols, feed2.rows)));
        //small_image.copyTo(big_image(cv::Rect(x,y,small_image.cols, small_image.rows)));


        //webcamstream
        imshow("VIDEO", feed);

        //exit it key pressed
        if (waitKey(30) >= 0){
            break;
        }

        //delay33ms
        waitKey(10);
        //
    }//endloop
}//main

It runs but after a while it always freezes showind the bellow on the cmd windows:

 ***** VIDEOINPUT LIBRARY - 0.1995 - TFW07 *****
 init done [mjpeg @ 0022ec00] error dc
 [mjpeg @ 0022ec00] error y=9 x=28

Would anyone know how I can start debbuging this to see where the issues could be? I'm suspecting on of the stream is not stable enough, it might sending frames that are or get corrupted and I suspect this may be causing some short of issue.

Project not respondingDelay to load and delayed stream

Im running this code:

#include <iostream>
#include <sstream>
#include <ctime>
#include <string>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

int main()
{
    //create matrix for storage
    Mat feed, feed2;

    //initialize capture
    VideoCapture cap, cap2;
    cap.open("http://192.168.1.128/videostream.asf?user=admin&pwd=");
    cap2.open("http://192.168.1.110/webcam.mjpeg");

    // check if we succeeded
    if (!cap.isOpened()){
        cerr << "Failed to open video capture" << std::endl;
        cout << "cannot open camera";
        return -1;
    }
    if (!cap2.isOpened()){
        cerr << "Failed to open video capture" << std::endl;
        cout << "cannot open camera";
        return -1;
    }

    //create window to show image
    namedWindow("VIDEO", 1); 

    //loop
    while (true){

        //copy webcam stream to image
        cap >> feed;
        cap2 >> feed2;

        resize(feed, feed, Size(1270, 700), 0, 0, INTER_CUBIC);
        resize(feed2, feed2, Size(320, 170), 0, 0, INTER_CUBIC);

        feed2.copyTo(feed(cv::Rect(874,463,feed2.cols, feed2.rows)));
        //small_image.copyTo(big_image(cv::Rect(x,y,small_image.cols, small_image.rows)));


        //webcamstream
        imshow("VIDEO", feed);

        //exit it key pressed
        if (waitKey(30) >= 0){
            break;
        }

        //delay33ms
        waitKey(10);
        //
    }//endloop
}//main

It runs but after I've got a while it always freezes showind Raspberry pi with a USB composite capturer running FFMPEG on server with the bellow on the cmd windows:following setup:

/etc/ffserver.conf

 ***** VIDEOINPUT LIBRARY - 0.1995 - TFW07 *****
 init done [mjpeg @ 0022ec00] error dc
 [mjpeg @ 0022ec00] error y=9 x=28
Port 80
BindAddress 0.0.0.0
MaxClients 10
MaxBandwidth 50000
NoDaemon

<Feed webcam.ffm>
file /tmp/webcam.ffm
FileMaxSize 10M
</Feed>

<Stream webcam.mjpeg>
Feed webcam.ffm
#Format mpjpeg
Format avi
VideoSize 320x170
VideoBufferSize 5
VideoFrameRate 10
VideoBitRate 500
VideoQMin 1
VideoQMax 10
</Stream>

Would anyone know how I can start debbuging this to see where and the issues could be? I'm suspecting on command:

ffserver -f /etc/ffserver.conf & ffmpeg -v verbose -r 10 -s 320x170 -f video4lilinux2 -i /dev/video0 http://localhost/webcam.ffm

When I use only one of the stream I can get delays or should I say I have a delay of 5 seconds which is not stable enough, it might sending frames that are or acceptable, but when I have both stream I get corrupted a 20 seconds delay. I have looked around and I suspect this may there seam to be some bugs but looks like 2 years ago.

Is there any way to know what could be causing some short this? and how could I solve it? reducing the size buffer? I've noticed the the one of issue.the stream from an IP camera come without delay