Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why do I get an error from imread when running my program in eclipse CDT, but not when running from terminal.

Hi guys I have had this problem for a while but I finally want to figure out how to fix it. In eclipse I can have this code:

int main(int argc, char** argv){
    Mat image = imread( argv[1], 0);
    namedWindow("ImageBefore",CV_WINDOW_NORMAL);
    imshow("ImageBefore",image);
}

If I specify argv[1] in eclipse to be "filename.jpg" I get the following error:

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

But if I run the executable from the terminal with

./ProgramName filename.jpg

It runs fine. I can change the code to:

int main(int argc, char** argv){
    const string filename "filename.jpg";
    Mat image = imread(filename, 0);
    namedWindow("ImageBefore",CV_WINDOW_NORMAL);
    imshow("ImageBefore",image);
}

Yet I get the exact same error. The file is in my debug folder, the same folder as the compiled program, but if I write in the full path it still does not work.

I would really appreciate it if anyone could give me insight on why this is happening?

Thanks, Zach