How to capture the image of an ip camera with opencv c ++?

1

I have a system where I use opencv and c ++ for vehicle counting. Capturing the image from a video for example

VideoCapture cap(video.pm4);

works fine, but when you want to capture the image from an ip camera

VideoCapture cap("http://ip_address:port/");

does not receive anything. I do not know if the syntax is correct, or do I need some kind of complement ???

Thanks

    
asked by Pablo 02.11.2017 в 02:34
source

1 answer

1

To find out what the error is when opening the camera input, you should do something better:

VideoCapture cap;

cap.open("http://ipaddress:port/video?x.mjpeg");
if (!cap.isOpened())  //si ha fallado, sale
{
    cout << "No se puede abrir la camara" << endl;
    return -1;
}

To capture images you can use a loop like this:

while (1)
{
    Mat imagen;

    bool ok= cap.read(imagen);
    if (!ok) //
    {
         cout << "No se pueden leer imagenes" << endl;
         break;
    }

    imshow("VideoIP", imagen);
}

Make sure the URL of the camera is correct.

  

" link "

The key to the problem is surely there.

    
answered by 02.11.2017 / 15:58
source