简体   繁体   English

使用opencv连接到IP摄像机

[英]connect to IP camera using opencv

I want to take picture with my Dynacolor IP camera using opencv 2.45 in Microsoft Visual Studio. 我想在Microsoft Visual Studio中使用opencv 2.45用Dynacolor IP摄像机拍照。

I've found its ip with iSpy. 我已经通过iSpy找到了它的IP。 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. 这给我一个警告:找不到编解码器参数<... / ... / modules / highgui / src / cap_ffmpeg_impl.hpp:540>,并且Camera为空。

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. 在地址末尾注意“?.mjpg”。 I have also changed IP and port for test. 我还更改了IP和端口进行测试。

#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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM