C ++ compilation error opencv - 64-bit version of Windows7 using Eclipse CDT

Trying to compile this sample project to familiarize yourself with OpenCV:

#include <cv.h> #include <highgui.h> using namespace cv; int main(int argc, char** argv) { Mat image = imread(argv[1], 1); if (argc != 2 || !image.data) { printf("No image data \n"); return -1; } namedWindow("Display Image", CV_WINDOW_AUTOSIZE); imshow("Display Image", image); waitKey(0); return 0; } 

I get the following compilation errors:

 Description Resource Path Location Type Field 'data' could not be resolved imageloader.cpp ‪/Session4‬ line 8 Semantic Error Invalid arguments ' Candidates are: void imshow(const std::basic_string<char,std::char_traits<char>,std::allocator<char>> &, const ? &) void imshow(const ? &, ?) ' imageloader.cpp ‪/Session4‬ line 14 Semantic Error 

Why can't I access the fields inside the Mat object? Not only the data field, but all the fields. I am creating an opencv library using c-make and MinGW +. I have included the appropriate header files and the lib path in the project properties.

Any help would be most appreciated.

+2
source share
1 answer

The Mat special method checks if the data has been successfully loaded:

// returns true if matrix data is NULL

bool empty () const;

So, in your code, change the if statement to:

 if (argc != 2 || image.empty()) 
0
source

Source: https://habr.com/ru/post/976516/


All Articles