在做高翔《一起做RGB-D SLAM》系列过程中,由于工程较大,需要将自己写的函数进行封装,方便调用,将函数的封装和调用过程记录下来,方便查阅
-
函数的封装
将需要封装的函数的声明和定义分别放在头文件(.h)和源文件(.cpp)中 头文件:包含了库的引用,数据类型的定义,结构体定义,函数声明 源文件:函数定义
以特征点检测和匹配的函数为例
feature_detect.h
#pragma once
#include <fstream>
#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
typedef pcl::PointXYZRGBA PointT;
typedef pcl::PointCloud<PointT> PointCloud;
using namespace std;
using namespace cv;
struct CAMERA_INTRINSIC_PARAMETERS
{
double cx,cy,fx,fy,scale;
}