0
votes

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?

2

2 Answers

0
votes

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.

0
votes

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.