简体   繁体   中英

connect to IP camera using opencv

I want to take picture with my Dynacolor IP camera using opencv 2.45 in Microsoft Visual Studio.

I've found its ip with iSpy. and here is my code.

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/opencv.hpp"

int main()
{
    cv::VideoCapture vcap;
    const std::string videoStreamAddress = "http://Admin:1234@192.168.0.250:80/cgi-bin/jpg/image.cgi";
    if (!vcap.open(videoStreamAddress))
    {
        printf("Camera is null\n");
        return -1;
    }
    else
    {
        cv::Mat image;
        vcap.read(image);
        cv::imshow("image",image);
    }
    cv::waitKey(100);
    return 0
}

This take me a warning: Could not find codec parameters <.../.../modules/highgui/src/cap_ffmpeg_impl.hpp:540>, and also Camera is null.

I have read many threads about this issue but I couldn't fix this problems.

Any help would be appreciated.

Check this code. It works for me. Note '?.mjpg' at the end of address. I have also changed IP and port for test.

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/opencv.hpp"
#include <cstdio>

int main()
{
    cv::VideoCapture vcap;

    // changed address
    const std::string videoStreamAddress = "http://213.171.96.200/cgi-bin/jpg/image.cgi?.mjpg";
    if (!vcap.open(videoStreamAddress))
    {
        printf("Camera is null\n");
        return -1;
    }
    else
    {
        cv::Mat image;
        vcap.read(image);
        cv::imshow("image",image);
    }
    cv::waitKey(10000);
    return 0;
}

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