Ask Your Question
0

Trouble with example - runtime error

asked 2012-11-11 21:52:15 -0500

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-11-12 02:42:29 -0500

It seems like the camera is not correctly initialized. Try to debug the code and investigate the 'cap' variable. Are you able to run precompiled samples (like lkdemo) by the way without any problems?

edit flag offensive delete link more

Comments

When I try to run lkdemo it says 'Could not initialize capturing...'

robotnik gravatar imagerobotnik ( 2012-11-12 11:03:45 -0500 )edit

Most of the other sample's work though, and I can compile all of them too. I think you are right about the camera not initializing correctly. Any ideas?

robotnik gravatar imagerobotnik ( 2012-11-12 13:48:09 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2012-11-11 21:52:15 -0500

Seen: 423 times

Last updated: Nov 12 '12