error: imread is not a member of cv

27,084

Solution 1

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

Solution 2

#include <opencv2/imgcodecs.hpp> 

solved the problem which contains the imread function

Share:
27,084
CanCam
Author by

CanCam

Updated on August 01, 2022

Comments

  • CanCam
    CanCam almost 2 years

    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.

  • Miki
    Miki over 8 years
    1) you don't need #include <opencv\cv.hpp>, 2) you can just use #include <opencv2/opencv.hpp> 3) without a main this won't work, 4) Opencv 3.0 parameter is now called IMREAD_COLOR
  • CanCam
    CanCam over 8 years
    I included those headers to my code, but this time I get another error, /usr/bin/ld cannot find -lml and same error for other libraries