当前位置:网站首页>First knowledge of opencv4.x --- image template matching
First knowledge of opencv4.x --- image template matching
2022-07-25 09:47:00 【F l e】
Image template matching knowledge :

// Image template matching
#include <stdio.h>
#include <iostream>
#include <string>
#include <opencv2\opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat img = imread("person2.jpeg");
Mat temp = imread("person2_temp.jpeg");
Mat result;
matchTemplate(img, temp, result, TM_CCOEFF_NORMED);
Point max_index, min_index;
// Match the result at the mark of the original image
double min_value, max_value;
minMaxLoc(result, &min_value, &max_value, &min_index, &max_index);// Be careful result The element position in is consistent with the element position in the top left corner of the matched part of the original image
rectangle(img, Rect(max_index.x, max_index.y, temp.cols, temp.rows), Scalar(255, 255, 255), 2);
namedWindow("result", WINDOW_NORMAL);
namedWindow("temp", WINDOW_NORMAL);
namedWindow("img", WINDOW_NORMAL);
imshow("result", result);
imshow("temp", temp);
imshow("img", img);
waitKey(0);
return 0;
}

边栏推荐
猜你喜欢

*6-3 save small experts

@2-1 safety index predicted by CCF at the end of December 1, 2020

cf #785(div2) C. Palindrome Basis

解决QTCreator使用VS编译中文乱码错误

Class (2) and protocol

初识Opencv4.X----为图像添加高斯噪声

Segmentation-based deep-learning approach for surface-defectdetection(基于分割的表面缺陷深度学习检测方法)

matlab如何导入大量数据

CoreData存储待办事项

OC--对象复制
随机推荐
类(2) 和 协议
Flutter Rive 多状态例子
[code source] daily question simple fields and
Customize the view to realize the background of redeeming lottery tickets [elementary]
OC--类别 扩展 协议与委托
Browser access to swagger failed with error err_ UNSAFE_ PORT
【深度学习】卷积神经网络
[code source] daily question tree
How to convert object data into arrays
Minkowskiengine installation
【深度学习】自编码器
Voice chat app source code - produced by NASS network source code
【数据挖掘】最近邻和贝叶斯分类器
关于C和OC
¥ 1-3 SWUST OJ 942: reverse sequence table
学生管理系统(总结)
[code source] score split of one question per day
无向连通图邻接矩阵的创建输出广度深度遍历
Android & kotlin: puzzle solution
How to add other PHP versions to MAMP