当前位置:网站首页>[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;
}
戳戳小手帮忙点个免费的赞吧,嘿嘿。 |
边栏推荐
- 通过程序发送 Gmail 邮件
- .equals==
- MySQL索引、视图、设计三范式,通俗易懂,不可错过!
- 基本运算符
- Master-slave postition changes cannot be locked_Slave_IO_Running shows No_Slave_Sql_Running shows No---Mysql master-slave replication synchronization 002
- 函数二
- MySQL约束关系,你必须要知道的知识点!
- [ASM] Bytecode operation MethodVisitor case combat generation object
- Sweet alert
- Dream Notes 0809
猜你喜欢
随机推荐
Redis 缓存主动更新策略
BigDecimal用法常用操作记录
mysql简单安装
3D printed this DuPont cable management artifact, and the desktop is no longer messy
Win系统 - 罗技 G604 鼠标蓝灯闪烁、失灵解决方案
多线程案例——定时器
公里周日
3.List interface and implementation class
Arrays.toString( )打印二维数组
3. Practice the Thread
开源SPL,WebService/Restful广泛应用于程序间通讯,如微服务、数据交换、公共或私有的数据服务等。
Thread,Runnable,ExecutorService线程池控制下线程量
极域Killer 1.0代码
4. Character stream
LeetCode148:排序链表 归并排序,思路清晰,C语言练习看过来!
3. Coding method
Cisco common basic configuration of common commands
2. Thread creation
程序环境和预处理
Collections and Functions