error: imread is not a member of cv

CanCam picture CanCam · Nov 14, 2015 · Viewed 25.3k times · Source

I use OpenCV 3.0 and Ubuntu 14.04. I'm trying to compile a few codes on ubuntu using opencv. I get error

"error: 'imread' is not a member of 'cv'"

Due to my previous search knowledge, I tried compiling by adding "highgui.h".

I use:

$g++ main.cpp HOG.cpp HOGFeaturesOfBlock.cpp -I/usr/local/include/opencv -lml -lcvaux -highgui -lcv -lcxcore -o featureExtractor

on terminal to compile.

Any suggest? Regards. Can.

Answer

mask picture mask · Nov 14, 2015

The following commands should work. If it doesn't work you should check if you set the include/lib files correctly.

#include <opencv2\highgui\highgui.hpp>
#include <opencv2\core\core.hpp>
#include <opencv\cv.hpp>

using namespace cv;

Mat image = imread(filename, CV_LOAD_IMAGE_COLOR);