0

I am trying to write a program in OpenCV that just displays the video from an axis camera, which is a type of ip camera. My problem is that OpenCV gives me an error and crashes.

The error is:

OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /home/pi/opencv-2.4.5/modules/core/src/array.cpp, line 2482
terminate called after throwing an instance of 'cv::Exception'
what(): /home/pi/opencv-2.4.5/modules/core/src/array.cpp:2482: error: (-206) Unrecognized or unsupported array type in function cvGetMat

Aborted

My code is:

#include <opencv2/opencv.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main()
{
    Mat img;
    namedWindow("IMG", CV_WINDOW_AUTOSIZE);

    while(true)
    {
        img = imread("http://10.17.14.11/jpg/image.jpg");

        if(img.empty())cout<<"The image is empty\n";//This cout is printed

        imshow("IMG", img);

        if(waitkey(1) >=0)break;
    }
}

I have tried using a VideoCapture with the address

"http://10.17.14.11/mjpg/video.mjpg" 

but I got the same error. I also put both of these URLs into my web browser and they were valid.

Thank you.

EDIT
Could the reason for VideoCapture not working be that I don't have ffmpeg installed?

bijan311
  • 33
  • 1
  • 5

2 Answers2

0

I guess the function 'imread' only search for files in the current host. You should download the file by other means and then open it using imread.

dieram3
  • 592
  • 3
  • 7
  • That may be the case for imread, but I've seen examples where the VideoCapture class gets the mjpg file from an external location like I've shown above, but it still doesn't work for me. Thanks for your reply – bijan311 Dec 04 '13 at 14:05
0

The error is probably because neither imread or VideoCapture can open remote images. It is easy to check if you try to read a local image instead. At least, I couldn't find anything in the VideoCapture documentation that suggest that remote paths are valid.

If you saw some example, maybe it was using some extended class. It can be very useful to future readers if you find the URL of the example.

ChronoTrigger
  • 8,459
  • 1
  • 36
  • 57
  • Some places I saw the use of an external url is http://answers.opencv.org/question/133/how-do-i-access-an-ip-camera/ and http://stackoverflow.com/questions/17697923/opencv-videocapture-ip-camera-reconnection – bijan311 Dec 04 '13 at 17:40