当前位置:网站首页>[Halcon&定位] 解决Roi区域外的模板匹配成功
[Halcon&定位] 解决Roi区域外的模板匹配成功
2022-08-09 10:00:00 【丶布布】
- 博客主页:https://blog.csdn.net/weixin_43197380
- 欢迎点赞 收藏 留言 如有错误敬请指正!
- 本文由 Loewen丶原创,首发于 CSDN
- 现在的付出,都会是一种沉淀,只为让你成为更好的人
一.问题描述
用halcon形状模版匹配,红色矩形框是搜索范围,ROI 矩形框中间的是训练的模版,按理说应该只会匹配到ROI中中间的那个为什么会搜到搜索区域之外的部分,而且匹配分数还很高,即模板在搜索区域外仍能匹配成功。
二.原因分析
使用reduce_domain裁切搜索区域部分的图像时,只是将搜索区域以外的图像遮盖了,并不是彻底消失了。所以在参数设置没问题,匹配分数依然很高的情况下,只要模板的重心还在搜索Roi内,依然能搜索模板。
三.解决措施
将搜索区域以外的图像彻底遮盖掉,这样即使模板的重心还在搜索Roi内,也不能匹配到搜索区域以外的图像了。
Halcon代码:
dev_close_window ()
dev_open_window (0, 0, 648, 512, 'black', WindowHandle)
read_image (Image, '图像1.png')
*建模
*draw_region (OutRegion, WindowHandle)
*draw_region (InRegion, WindowHandle)
*difference (OutRegion, InRegion, RegionDifference)
read_region (RegionDifference, 'ModelRegion.hobj')
reduce_domain (Image, RegionDifference, ImageReduced1)
create_shape_model (ImageReduced1, 5, 0, 0, 'auto', 'auto', 'ignore_global_polarity', 'auto', 50, ModelID2)
*匹配
read_image (Image, '图像1.png')
*draw_circle (WindowHandle, Row2, Column2, Radius)
gen_circle (SerRegion, 433, 620, 100)
***↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓***
*这里取消掉reduce_domain得到搜索图像,而是采用paint_region方式
*reduce_domain (Image, SerRegion, ImageReduced3)
get_domain (Image, Domain)
difference (Domain, SerRegion, RegionDifference1)
paint_region (RegionDifference1, Image, ImageReduced3, 1, 'fill')
***↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑***
find_shape_model (ImageReduced3, ModelID2, -0.39, 0.79, 0.5, 1, 0.5, 'least_squares', 0, 0.9, Row7, Column7, Angle3, Score3)
get_shape_model_contours (ModelContours4, ModelID2, 1)
vector_angle_to_rigid (0, 0, 0, Row7, Column7, Angle3, HomMat2D)
affine_trans_contour_xld (ModelContours4, ContoursAffineTrans, HomMat2D)
dev_display (Image)
dev_set_color ('red')
dev_display (SerRegion)
dev_set_color ('green')
dev_set_line_width (2)
dev_display (ContoursAffineTrans)
C++源码:
if (m_RegionSer.AreaCenter(&HTuple(), &HTuple()) > 0)
{
//_reduceImg = _inImg.ReduceDomain(_inRegion);
HObject Domain, RegionDifference;
GetDomain(m_TriggerImg, &Domain);
Difference(Domain, m_RegionSer, &RegionDifference);
PaintRegion(RegionDifference, m_TriggerImg, &imgReduced, 0, "fill");
}
else
{
imgReduced = m_TriggerImg;
}
戳戳小手帮忙点个免费的赞吧,嘿嘿。 |
边栏推荐
- LeetCode56:合并区间 C语言解法,注解详细 一看就懂!
- Ontology Development Diary 03 - When debugging is in progress
- Practical skills: a key for image information in the Harbor, quick query image
- 【 size_t is unsigned integer (1 > 10) - > 1.
- 归并排序
- JDBC中的增删改查操作
- 技术分享 | 使用 cURL 发送请求
- 关于SQL的SELECT查询语句的一般格式的描述2021-05-19
- 元组 字典 集合
- 实验室装修及改造工程程序简介
猜你喜欢
Super detailed MySQL basic operations
【八大排序②】选择排序(选择排序,堆排序)
.equals==
通过程序发送 Gmail 邮件
【MySQL】mysql因为字符集导致left join出现Using join buffer (Block Nested Loop)
文件操作
LeetCode148:排序链表 归并排序,思路清晰,C语言练习看过来!
Quick sort eight sorts (3) 】 【 (dynamic figure deduction Hoare, digging holes, front and rear pointer method)
【ASM】字节码操作 MethodVisitor 案例实战 生成对象
EndNote使用指南
随机推荐
Golang Protobuf 处理
需求侧电力负荷预测(Matlab代码实现)
3.List interface and implementation class
mysql简单安装
Redis cache update strategy actively
The GNU Privacy Guard
蓄电池建模、分析与优化(Matlab代码实现)
A Practical Guide to Building OWL Ontologies using Protege4 and CO-ODE Tools - Version 1.3 (7.4 Annotation Properties - Annotation Properties)
文件操作
ArrayList和LinkedList
多线程案例——阻塞式队列
Browser error classification
conditional control statement
8. Recursively traverse and delete cases
安装torch_sparse失败解决方法
程序环境和预处理
EndNote使用指南
记录一次被入侵5900端口经历
mysql 修改密码和忘记密码操作
极域Killer 1.0代码