Ask Your Question

Revision history [back]

Trouble with example - runtime error

I just compiled, and installed opencv on my computer that is running ubuntu, and I am trying to run an example program but I am getting a runtime error. The example is supposed to display video from my web cam.

This is the example.

#include <cv.h>     // Main OpenCV library.
#include <highgui.h>    // OpenCV functions for files and graphical windows.
using namespace cv;
int main(int argc, char* argv[])
{
    Mat img;
    VideoCapture cap;
    cap.open(0);
    namedWindow("window", 1);
    while(1)
    {
        cap >> img;
        imshow("window", img);
        waitKey(33);
    }   
    return 0;
}

It compiles fine, but when I run it, it says...

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

If anyone knows what I'm doing wrong please help.