2

Can anyone explain to me why this code below does not work?

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

This code does cannot open the stream...

The code is based on some code in this thread: OpenCV with Network Cameras

The OpenCV 1 code here works without any problem for me.

Thank you very much in advance

Community
  • 1
  • 1
hansdam
  • 127
  • 3
  • 11

1 Answers1

1

I tried to create a new project with Visual Studio 2010 and OpenCV 2.2, instead of OpenCV 2.3.1.

This solved all my problems!

hansdam
  • 127
  • 3
  • 11
  • 1
    Some prebuilt openCV binariess might not contain the network stream libs – Martin Beckett Feb 09 '12 at 20:47
  • 1
    Hi, I've got exactly the same problem with 2.4.3. : I can even open AVI files but not public URLs of cameras such as `http://66.184.211.231/mjpg/video.mjpg`. What could I do, should I recompile the library with a specific support, install another library, simply copy DLLs (that would be lovely)... ? – Mister Mystère May 08 '13 at 23:20