当前位置:网站首页>初识Opencv4.X----图像模板匹配
初识Opencv4.X----图像模板匹配
2022-07-25 09:22:00 【F l e】
图像模板匹配知识:

//图像模板匹配
#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;
//在原图像中标注处匹配结果
double min_value, max_value;
minMaxLoc(result, &min_value, &max_value, &min_index, &max_index);//注意result中的元素位置与原图像被匹配的部分图像的最左上角的元素位置一致
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;
}

边栏推荐
猜你喜欢

How many regions can a positive odd polygon be divided into

*6-1 CCF 2015-03-2 numerical sorting

本地存储待办事项(在待办事项上进行改进)

main函数的一些操作

Flex layout syntax and use cases

How to obtain location information (longitude and latitude) by uni app

一张图讲解 SQL Join 左连 又连

最短路问题 Bellman-Ford(单源最短路径)(图解)

Week summary

基于机智云平台的温湿度和光照强度获取
随机推荐
深入解读C语言随机数函数和如何实现随机数
对象初始化
OC--Foundation--字典
自定义 view 实现兑奖券背景[初级]
打造个人极限写作流程 -转载
Dream set sail (the first blog)
Swift创作天气APP
What is cerebral fissure?
OC--包装类和处理对象
作业7.21 约瑟夫环问题与进制转换
In depth interpretation of C language random number function and how to realize random number
如何将其他PHP版本添加到MAMP
语音聊天app源码-钠斯网络源码出品
[code source] score split of one question per day
Numpy array attribute, shape changing function, basic operation
Flutter Rive 多状态例子
关于学生管理系统(注册,登录,学生端)
How to customize the title content of uni app applet (how to solve the problem that the title of applet is not centered)
初识Opencv4.X----图像卷积
## 使用 Kotlin USE 简化文件读写