之前的鼠标事件的响应以及均值漂移算法算法如果已经懂了,那么现在的程序就是合成了一下,就直接上代码了
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/imgproc/types_c.h>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/core/core.hpp>
#include<iostream>
#include<vector>
#include<opencv2/nonfree/features2d.hpp>
#include<opencv2/legacy/legacy.hpp>
#include<opencv2/features2d/features2d.hpp>
#include<opencv2/calib3d/calib3d.hpp>
#include<opencv2/video/tracking.hpp>
using namespace cv;
using namespace std;
class Package
{
private:
public:
Rect MeanShitfMath(const Mat &OrgInImage, const Mat &PreInImage, Rect &ROIrect);
};
Rect Package::MeanShitfMath(const Mat &OrgInImage, const Mat &PreInImage, Rect &ROIrect)
{
Mat orgimg = OrgInImage;
Mat preimg = PreInImage;
/*先对输入的原始图像进行感兴趣区域的采集*/
//先获取感兴趣区域的图像
Mat bgrROI = orgimg(ROIrect);
//将感兴趣区域的BGR空间转换为HSV空间
Mat hsvROI;
c