Ask Your Question
0

opencv.hpp not in /opencv2

asked 2013-06-05 09:35:01 -0500

deepak t s gravatar image deepak t s
1 1 1

hi all I followed a tutorial "The OpenCV Tutorials, Release 2.4.5.0" and tried to build opencv for linux i could successfully build a /release but the folder /release/opencv2/ does not contain any of the .hpp files except opencv_modules.hpp file i created a sample folder in /release directory /release/sample and pleaced a file : DisplayImage.cpp containg following code :

#include <stdio.h>
#include "../opencv2/opencv.hpp"
using namespace cv;
int main( int argc, char** argv )
{
Mat image;
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;
}

//---------------------------- and CMakeLists.txt containing :

cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )

//------------------- when i ran cmake . i got

-- Configuring done -- Generating done -- Build files have been written to: /home/student/Documents/openCV/opencv/release/sample

//------------------- when i ran make command i got

100%] Building CXX object
> CMakeFiles/DisplayImage.dir/DisplayImage.cpp.o
> /home/student/Documents/openCV/opencv/release/sample/DisplayImage.cpp:2:30:
> fatal error: opencv2/opencv.hpp: No
> such file or directory compilation
> terminated. make[2]: ***
> [CMakeFiles/DisplayImage.dir/DisplayImage.cpp.o]
> Error 1 make[1]: ***
> [CMakeFiles/DisplayImage.dir/all]
> Error 2 make: *** [all] Error 2

//---------------------- suggestion are welcome

thankyou
deepak

delete close flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
4

answered 2013-06-05 13:19:02 -0500

HD_Mouse gravatar image HD_Mouse
420 3 10

updated 2013-06-05 13:22:24 -0500

Your line

#include "../opencv2/opencv.hpp"

is specifying a relative path for #include to look. If it can't find it there, then it tries to look for it wherever it stores the standard header files (such as: iostream, stdio.h). Assuming you built OpenCV for linux properly, the headers get copied into /usr/include/. You'll likely find opencv.hpp at "/usr/include/opencv2/opencv.hpp". The line isn't working because of the ".." you added to it. It's causing it to look for a file at /usr/opencv2/opencv.hpp".

You can probably fix this by just replacing that line with this:

#include <opencv2/opencv.hpp>

That said, it would be better practice to pull in only headers that are needed, such as:

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
link delete flag offensive edit

Login/Signup to Answer

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2013-06-05 09:35:01 -0500

Seen: 3,618 times

Last updated: Jun 05 '13