#include<opencv2/opencv.hpp>
#include<iostream>
#include<vector>
using namespace cv;
using namespace std;
Mat findImage;
Mat modeImage;
bool g_bDrawingBox = false;
Rect g_rectangle;
RNG &g_rng = theRNG();
Mat modeROIImage;
Point startPoint;
Mat tempImage;
Mat findMidImage;
void onMouse(int event, int x, int y, int flag, void *param)
{
Mat &img = *(cv::Mat*)param;
switch (event)
{
//移动鼠标的时候
case CV_EVENT_MOUSEMOVE:
{
if (g_bDrawingBox)
{
g_rectangle.width = x - g_rectangle.x;
g_rectangle.height = y - g_rectangle.y;
tempImage.copyTo(modeImage);
rectangle(modeImage, startPoint
, Point(startPoint.x + g_rectangle.width, startPoint.y + g_rectangle.height)
, Scalar(g_rng.uniform(0, 255), g_rng.uniform(0, 255), g_rng.uniform(0, 255)));
imshow("【模版图像】", modeImage);
}
}
break;
opencv3 实现模版匹配-鼠标事件
最新推荐文章于 2023-08-30 15:34:16 发布