需要调用到opencv的什么功能,就在代码头提前引用好对应的头文件。
所有的头文件都可以在include/opencv2/
文件夹找到。
常见头文件:
#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/flann/miniflann.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/photo/photo.hpp"
#include "opencv2/video/video.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/ml/ml.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/contrib/contrib.hpp"
具体作用:
其中,最常引用的头文件:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
由于opencv.hpp
中已经包含了OpenCV中各模块的头文件,所以也可以只引用该头文件:
#include <opencv2/opencv.hpp>
[1] OpenCV概要介绍 [2] OpenCV学习(3) OpenCV框架