使用opencv连接到IP摄像头

时间:2016-04-16 10:47:25

标签: c++ opencv ip-camera

我想在Microsoft Visual Studio中使用opencv 2.45使用我的Dynacolor IP摄像头拍照。

我用iSpy找到了它的ip。这是我的代码。

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

这给我一个警告:找不到编解码器参数< ... / ... / modules / highgui / src / cap_ffmpeg_impl.hpp:540&gt ;,而且Camera也为空。

我已经阅读了很多有关此问题的主题,但我无法解决这个问题。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

检查此代码。这个对我有用。请注意地址末尾的“?.mjpg”。我也改变了IP和端口进行测试。

Apr 16 11:39:03 localhost journal: time="2016-04-16T11:39:03.884872524Z" level=info msg="{Action=push, Username=asamba, LoginUID=1001, PID=2125}"
Apr 16 11:39:03 localhost journal: time="2016-04-16T11:39:03.884988574Z" level=error msg="Handler for POST /v1.21/images/asamba/docker-whale/push returned error: Error: Status 403 trying to push repository asamba/docker-whale to official registry: needs to be forced"
Apr 16 11:39:03 localhost journal: time="2016-04-16T11:39:03.885013241Z" level=error msg="HTTP Error" err="Error: Status 403 trying to push repository asamba/docker-whale to official registry: needs to be forced" statusCode=403
Apr 16 11:39:05 localhost journal: time="2016-04-16T11:39:05.420188969Z" level=info msg="{Action=push, Username=asamba, LoginUID=1001, PID=2125}"
Apr 16 11:39:06 localhost kernel: XFS (dm-4): Mounting V4 Filesystem
Apr 16 11:39:06 localhost kernel: XFS (dm-4): Ending clean mount
Apr 16 11:39:07 localhost kernel: XFS (dm-4): Unmounting Filesystem