#include opencv中的C ++头文件 [英] #include C++ header files in opencv
问题描述
我只是使用
#include< opencv2 / opencv.hpp>
我可以问为什么我们应该这样做:
#include< opencv2 / imgproc / imgproc.hpp>
#include< opencv2 / objdetect / objdetect.hpp>
#include< opencv2 / highgui / highgui.hpp>
为什么这里有* .hpp文件,而不是* .h文件?
$ b对于请求这样简单的问题,请原谅我。 对于全局vs.小包括问题,你需要回忆一下C / C ++中的工作原理。 I just use and things worked. May I asked why we should do like: And why here are *.hpp files but not *.h files? Excuse me for asking for such simple questions. 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. 这篇关于#include opencv中的C ++头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! hpp
是C ++ 语言头文件的约定。由于OpenCV有一个与C ++ 并行的 C API的长篇故事,人们可以很容易地理解为什么编写库的人选择此扩展来避免混淆。
opencv.hpp
(这是一种伞,因为它包括所有其他),所有的库头文件被包括,从而复制到您的.cpp文件。这意味着更少的输入,但最终一个更大的文件为编译器。因此,编译时间较长。
-lopencv_core -lopencv_imgproc
如果只使用图像处理模块。
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
.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.
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.