MJPEG网络流到OpenCV 2

时间:2012-02-08 16:17:25

标签: opencv networking stream mjpeg

有人可以向我解释为什么下面这段代码不起作用吗?

#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <iostream>

int main(int, char**) {
    cv::VideoCapture vcap;
    cv::Mat image;

    const std::string videoStreamAddress = "http://hg55.no-ip.org/mjpg/video.mjpg";
    //Yes, this stream does work! Try to paste it into your browser...

    //open the video stream and make sure it's opened
    if(!vcap.open(videoStreamAddress)) {
        std::cout << "Error opening video stream or file" << std::endl;
        return -1;
    }

    for(;;) {
        if(!vcap.read(image)) {
            std::cout << "No frame" << std::endl;
            cv::waitKey();
        }
        cv::imshow("Output Window", image);
        if(cv::waitKey(1) >= 0) break;
    }   
}

此代码无法打开流...

代码基于此主题中的一些代码:OpenCV with Network Cameras

这里的OpenCV 1代码对我没有任何问题。

非常感谢您提前

1 个答案:

答案 0 :(得分:1)

我尝试使用Visual Studio 2010和 OpenCV 2.2 创建一个新项目,而不是OpenCV 2.3.1。

这解决了我所有的问题!

相关问题