Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::VideoCapture works for webcams but not IP cameras

It had to happen, I'm stuck in the last phase of my project, when I want to use my code which works like a charm on my webcam, on an IP camera. The URL works perfectly in my browser, but nothing comes out with OpenCV... Here is my code:

#include <opencv/highgui.h>

using namespace cv;

int main(int argc, char *argv[])
{
    Mat frame;
    namedWindow("video", 1);
    VideoCapture cap("http://192.168.1.99:99/videostream.cgi?resolution=32&rate=0&user=admin&pwd=password&.mjpg");
    while ( cap.isOpened() )
    {
        cap >> frame;
        if(frame.empty()) break;

        imshow("video", frame);
        if(waitKey(30) >= 0) break;
    }

    return 0;
}

And the compiler settings :

//Added to the .pro file of QtCreator
INCLUDEPATH += C:\\OpenCV243\\release\\include
LIBS += -LC:\\OpenCV243\\release\\lib \
    -lopencv_core243.dll \
    -lopencv_highgui243.dll

I read somewhere that OpenCV had to be compiled with FFMPEG support (please confirm this is the true reason it doesn't work), but I thought version 2.4.3. was ? Also, I don't have FFMPEG libraries installed yet, but the linker doesn't seem to bother. Should I deduce that I can't just install FFMPEG the standard way (compile, then put bin in PATH, and link projects with ffmpeg libraries) ? What should I do ?

Thanks for your help,

Regards, Mister Mystère

cv::VideoCapture works for webcams but not IP cameras

It had to happen, I'm stuck in the last phase of my project, when I want to use my code which works like a charm on my webcam, on an IP camera. The URL works perfectly in my browser, but nothing comes out with OpenCV... Here is my code:

#include <opencv/highgui.h>

using namespace cv;

int main(int argc, char *argv[])
{
    Mat frame;
    namedWindow("video", 1);
    VideoCapture cap("http://192.168.1.99:99/videostream.cgi?resolution=32&rate=0&user=admin&pwd=password&.mjpg");
    while ( cap.isOpened() )
    {
        cap >> frame;
        if(frame.empty()) break;

        imshow("video", frame);
        if(waitKey(30) >= 0) break;
    }

    return 0;
}

And the compiler settings :

//Added to the .pro file of QtCreator
INCLUDEPATH += C:\\OpenCV243\\release\\include
LIBS += -LC:\\OpenCV243\\release\\lib \
    -lopencv_core243.dll \
    -lopencv_highgui243.dll

I read somewhere that OpenCV had to be compiled with FFMPEG support (please confirm this is the true reason it doesn't work), but I thought version 2.4.3. was is apparently already (CMake says "YES, prebuilt binaries") ? Also, I don't have FFMPEG libraries installed yet, but the linker doesn't seem to bother. Should I deduce that I can't just install FFMPEG the standard way (compile, then put bin in PATH, and link projects with ffmpeg libraries) ? What should I do ?

Thanks for your help,

Regards, Mister Mystère

click to hide/show revision 3
Clarified actual questions

cv::VideoCapture works for webcams but not IP cameras

It had to happen, I'm stuck in the last phase of my project, when I want to use my code which works like a charm on my webcam, on an IP camera. The URL works perfectly in my browser, but nothing comes out with OpenCV... Here is my code:

#include <opencv/highgui.h>

using namespace cv;

int main(int argc, char *argv[])
{
    Mat frame;
    namedWindow("video", 1);
    VideoCapture cap("http://192.168.1.99:99/videostream.cgi?resolution=32&rate=0&user=admin&pwd=password&.mjpg");
    while ( cap.isOpened() )
    {
        cap >> frame;
        if(frame.empty()) break;

        imshow("video", frame);
        if(waitKey(30) >= 0) break;
    }

    return 0;
}

And the compiler settings :

//Added to the .pro file of QtCreator
INCLUDEPATH += C:\\OpenCV243\\release\\include
LIBS += -LC:\\OpenCV243\\release\\lib \
    -lopencv_core243.dll \
    -lopencv_highgui243.dll

I read somewhere that OpenCV had to be compiled I've tested opening a .avi file with FFMPEG support (please confirm this is the true reason the same code and it works... But a public IP camera URL like http://66.184.211.231/mjpg/video.mjpg doesn't work), but version 2.4.3. is apparently already (CMake says "YES, prebuilt binaries") ? Also, I don't have FFMPEG libraries installed yet, but the linker doesn't seem to bother. Should I deduce that I can't just install FFMPEG the standard way (compile, ! What's the matter then put bin in PATH, and link projects with ffmpeg libraries) ? What should I do ?

Thanks for your help,

Regards, Mister Mystère