CanCam
CanCam

Reputation: 131

How to resolve an error: imread is not a member of cv?

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 the terminal to compile.

Any suggestions?

Upvotes: 12

Views: 33449

Answers (4)

letsdev-cwack
letsdev-cwack

Reputation: 139

#include <opencv2/imgcodecs.hpp> 

solved the problem which contains the imread function

Upvotes: 10

Forgoys
Forgoys

Reputation: 1

I had a same question before. Just add #include "imgcodec.hpp", Hope this can help you

Upvotes: -1

Roel Van de Paar
Roel Van de Paar

Reputation: 2228

I found that the compile command had to be very specific (besides having added using namespace cv; in the code), with the source file having to come directly after the g++, as follows;

g++ test.cpp -fpermissive $(pkg-config --cflags --libs opencv) -o testbin

Replace opencv with opencv4 if that is what you use

Upvotes: 1

mask
mask

Reputation: 549

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);

Upvotes: 9

Related Questions