博客
关于我
opencv 模板匹配, 已解决模板过大程序不工作的bug
阅读量:801 次
发布时间:2023-02-23

本文共 1313 字,大约阅读时间需要 4 分钟。

    
#include 
#include
#include
#include
#include
#ifdef _DEBUG#pragma comment (lib,"opencv_highgui244d.lib")#pragma comment (lib,"opencv_core244d.lib")#pragma comment (lib,"opencv_imgproc244d.lib")#else#pragma comment (lib,"opencv_highgui244.lib")#pragma comment (lib,"opencv_core244.lib")#pragma comment (lib,"opencv_imgproc244.lib")#endifusing namespace std;using namespace cv;int app(vector
minV) { int t = 0; for (int i = 1; i < minV.size(); i++) { if (minV[i] < minV[t]) { t = i; } } return t;}int main() { Mat img = imread("src1.jpg"); Mat temp = imread("template1.png"); vector
minV; vector
minL; vector
down_temp; down_temp.push_back(temp); for (int i = 0; i < 4; i++) { long begin = GetTickCount(); Mat temp1; temp1.cols = down_temp[i].cols; temp1.rows = down_temp[i].rows; for (int j = 0; j < 4; j++) { Mat temp2; temp2 = temp; temp2 = temp2(resize( temp2.cols * 0.8, temp2.rows * 0.8 )); matchTemplate(img, temp2, temp1, minV, minL, temp1); } }}

转载于:https://www.cnblogs.com/luoyinjie/p/7219330.html

这段代码实现了基于模板匹配的图像处理功能。通过从图像库中读取源图像和模板图像,使用OpenCV框架对模板进行多次缩小匹配,最终实现图像特征的定位。代码中通过向量存储最小值和对应的位置信息,实现了对模板在不同尺度下的匹配,从而提高了图像处理的鲁棒性。该方法在图像识别和相似度计算中具有参考价值。
你可能感兴趣的文章
Oracle中Transate函数的使用
查看>>
oracle中关于日期问题的汇总!
查看>>
Oracle中常用的语句
查看>>
Oracle中序列的操作以及使用前对序列的初始化
查看>>
oracle中新建用户和赋予权限
查看>>
Oracle中的NVL,NVL2,NULLIF以及COALESCE函数使用
查看>>
Oracle中的rownum 和rowid的用法和区别
查看>>
oracle中的大小写、字符、dual、数字、处理、日期、函数、显/隐式、时间、条件表达式case、decode、to_date、to_char、sysdate
查看>>
oracle中表和视图的区别,oracle中常用表和视图
查看>>
oracle之表空间(tablespace)、方案(schema)、段(segment)、区(extent)、块(block)
查看>>
Oracle从11g导出后导入10g
查看>>
oracle从备份归档日志的方法集中回收
查看>>
oracle优化器analyzed,Oracle 学习之 性能优化(十三) 索引
查看>>
Oracle修改字段类型
查看>>
Oracle修改表或者字段的注释
查看>>
oracle典型安装失败,安装oracle 10失败
查看>>
Oracle内存结构详解(四)--Oracle SGA其他组成部分
查看>>
Oracle函数与存储过程和程序包
查看>>
Oracle分析函数之LEAD和LAG
查看>>
Oracle分组取前n条记录
查看>>