一、前言
本文实验在VS将C++源码封装为dll、lib ,并做调用
二、欲封装代码
封装代码头文件和cpp文件如下:
//util.h#ifndef _Util_H_#define _Util_H_#include <iostream>#include<opencv2\opencv.hpp>#include <stdio.h>#include <list> using namespace std;using namespace cv; struct Move{bool res;int x;int y;};Mat resizeImg(const Mat& src , float s);Move matchOneImg( const Rect& ro , const Mat& tem , const float& thr , const Mat& re_ );void A_on_Mouse(int event, int x, int y, int flags, void* param);Rect getRoi(const Mat& img);class TempMatch{public:float scale; //缩放倍数float simi_thr; //相关系数阈值Rect roi; //模板区域(x,y.w.h)Mat templa; //模板区域图像TempMatch(char* p, float sca, float si = 0.75);Move matchImg(char* p);};#endif
下面是相应cpp文件