I'm on Red Hat Linux. I'm having some (probably newbie) problem with the includes in a C++ file. I created the following simple OpenCV script,
#include "opencv2/highgui/highgui.hpp"
using namespace cv;
int main(int argc, char ** argv){
Mat img = imread( argv[1], -1 );
if ( img.empty() ) return -1;
namedWindow( "Example1", cv::WINDOW_AUTOSIZE );
imshow( "Example1", img );
waitKey( 0 );
destroyWindow( "Example1" );
}
Then in the terminal I entered
g++ my_simple_script.cpp
and got the errors
newfile.cpp:1:39: error: opencv2/highgui/highgui.hpp: No such file or directory
newfile.cpp:3: error: 'cv' is not a namespace-name
newfile.cpp:3: error: expected namespace-name before ';' token
newfile.cpp: In function 'int main(int, char**)':
newfile.cpp:6: error: 'Mat' was not declared in this scope
newfile.cpp:6: error: expected ';' before 'img'
newfile.cpp:7: error: 'img' was not declared in this scope
newfile.cpp:8: error: 'cv' has not been declared
newfile.cpp:8: error: 'namedWindow' was not declared in this scope
newfile.cpp:9: error: 'img' was not declared in this scope
newfile.cpp:9: error: 'imshow' was not declared in this scope
newfile.cpp:10: error: 'waitKey' was not declared in this scope
newfile.cpp:11: error: 'destroyWindow' was not declared in this scope
I added
/home/m/maxwell9/2.4.3/include
to my PATH, where 2.4.3 indicates the version of OpenCV I'm using. When I type
echo $PATH
I see
/opt/apps/jdk1.6.0_22.x64/bin:/apps/smlnj/110.74/bin:/usr/local/cuda/bin:/sbin:/bin:/usr/sbin:/usr/bin:/apps/weka/3.7.12:/home/m/maxwell9/bin:/home/m/maxwell9/2.4.3/include
I confirmed that there is a file at
/home/m/maxwell9/2.4.3/include/opencv2/highgui/highgui.hpp