1.图像差分后取灰度值
main.cpp
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <opencv2/opencv.hpp>
using namespace cv;
void onTrackerSlid(Mat &inputimage1, Mat &inputimage2, Mat &outputimage, int pos);
int main()
{
Mat srcimage1 = imread("1.png");
Mat srcimage2 = imread("2.png");
Mat dstimage;
Mat dstimage1;
dstimage.create(srcimage1.rows, srcimage1.cols, srcimage1.type());
dstimage1.create(srcimage1.rows, srcimage1.cols, srcimage1.type());
onTrackerSlid(srcimage1, srcimage2, dstimage, 100); //将图1与图2的差分结果保存在dstimage中
namedWindow("srcimage1", CV_WINDOW_AUTOSIZE);
namedWindow("srcimage2", CV_WINDOW_AUTOSIZE);
namedWindow("dstimage", CV_WINDOW_AUTOSIZE);
imshow("srcimage1", srcimage1);
imshow("srcimage2", srcimage2);
imshow("dstimage", dstimage);
cvtColor(