I just use
#include <opencv2/opencv.hpp>
and things worked. May I asked why we should do like:
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
And why here are *.hpp files but not *.h files?
Excuse me for asking for such simple questions.
just open opencv2/opencv.hpp file and I think you will get your answer.
This header file include all the other header files in OpenCV in its body. So, if you include that file, it is more than enough.
".h" is for C and ".hpp" is for C++. This is just the standard.
.hpp
is a convention for C++ language header files. Since OpenCV has a long story of a C API in parallel of the C++ one, one can easily understand why the people writing the library chose this extension to avoid confusion.For the global vs. small includes question, you need to recall how things work in C/C++. The header files are just copied into your .c file before compilation.
opencv.hpp
(which is some kind of umbrella since it includes all the others), all the library header files are included and thus copied into your .cpp file. This means less typing for you but in the end a bigger file for the compiler. Hence, compilation times are longer.-lopencv_core -lopencv_imgproc
if you use only the image processing module.