Halcon实战记录之三《模板制作--两点定位》
2017-07-19 11:09
357 查看
目的:计算被检测物体的位置和角度偏移
内容:
1、其中Angle为匹配图和模板的相对旋转角度,可以以此获取匹配图中感兴趣ROI。
2、可以通过模板匹配的方法获取位置偏移量。
模板图:
匹配图:
备注:
1、保存模板的算子:
2、加载模板的算子:
3、匹配后的score需要作出判断,避免某些情况下匹配失败导致数据不对,程序奔溃。
4、在创建模板的时候,可以自己先对该区域做阈值处理,获取更明晰的轮廓,再创建模板。
内容:
*创建模板 read_image (Image1, 'D:/Program Files/MVTec/HALCON-12.0/examples/images/bottles/bottle_crate_01.png') dev_set_draw ('margin') *创建第一个模板 gen_rectangle1 (mrect1, 83.3297, 63.4186, 142.725, 144.029) reduce_domain (Image1, mrect1, Model1) create_shape_model (Model1, 'auto', -3.14, 6.29, 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID1) *创建第二个模板 gen_rectangle1 (mrect2, 381.057, 79.7036, 438.948, 144.029) reduce_domain (Image1, mrect2, Model2) create_shape_model (Model2, 'auto', -3.14, 6.29, 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID2) find_shape_model (Model1, ModelID1, -3.14, 6.29, 0.5, 1, 0.5, 'least_squares', 0, 0.9, Row1, Column1, Angle1, Score1) find_shape_model (Model2, ModelID2, -3.14, 6.29, 0.5, 1, 0.5, 'least_squares', 0, 0.9, Row2, Column2, Angle2, Score2) dev_display (Image1) gen_cross_contour_xld (Cross1, Row1, Column1, 20, Angle1) gen_cross_contour_xld (Cross2, Row2, Column2, 20, Angle2) dev_display (Cross1) dev_display (Cross1) gen_rectangle2 (TEST_ROI, 100.246, 416.396, rad(-0), 40.7125, 41.3) dev_display (TEST_ROI) *匹配 read_image (Image2, 'D:/Program Files/MVTec/HALCON-12.0/examples/images/bottles/bottle_crate_04.png') reduce_domain (Image2, mrect1, ImageFor1) reduce_domain (Image2, mrect2, ImageFor2) find_shape_model (ImageFor1, ModelID1, -3.14, 6.29, 0.5, 1, 0.5, 'least_squares', 0, 0.9, RowFor1, ColumnFor1, AngleFor1, ScoreFor1) gen_cross_contour_xld (CrossFor1, RowFor1, ColumnFor1, 20, AngleFor1) dev_display (CrossFor1) find_shape_model (ImageFor2, ModelID2, -3.14, 6.29, 0.5, 1, 0.5, 'least_squares', 0, 0.9, RowFor2, ColumnFor2, AngleFor2, ScoreFor2) gen_cross_contour_xld (CrossFor2, RowFor2, ColumnFor2, 20, AngleFor2) dev_display (CrossFor2) angle_ll (Row1, Column1, Row2, Column2, RowFor1, ColumnFor1, RowFor2, ColumnFor2, Angle) vector_angle_to_rigid (Row1, Column1, 0, RowFor1, ColumnFor1, Angle, HomMat2D) affine_trans_region (TEST_ROI, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
1、其中Angle为匹配图和模板的相对旋转角度,可以以此获取匹配图中感兴趣ROI。
2、可以通过模板匹配的方法获取位置偏移量。
模板图:
匹配图:
备注:
1、保存模板的算子:
write_shape_model( : : ModelID, FileName : )
2、加载模板的算子:
read_shape_model( : : FileName : ModelID)
3、匹配后的score需要作出判断,避免某些情况下匹配失败导致数据不对,程序奔溃。
4、在创建模板的时候,可以自己先对该区域做阈值处理,获取更明晰的轮廓,再创建模板。
相关文章推荐
- 韩顺平主讲织梦dedecms 5.7二次开发实战仿站模板制作视频教程
- DedeCMS实战-----4、制作文章内容页模板
- Halcon实战记录之一《划分图像区域为中心,四边,四角》
- Halcon实战记录之二《判断两个直线或者矩形是否相交》
- 实战 MDT 2012(二)---制作模板机
- 实战 MDT 2012(二)---制作模板机
- 实战 MDT 2012(二)---制作模板机
- 使用Unity3D 自主实战开发的赛车游戏实例,关键点记录 (二)之地形场景漫游导览制作
- halcon 基于形状模板匹配的定位与测定
- 学习Discuz! X3.2记录:又一个插件制作过程,未涉及数据库,用简单模板重定向
- DedeCMS实战-----3、制作文章列表页模板
- 实战 MDT 2012(二)---制作模板机
- 使用Unity3D 自主实战开发的赛车游戏实例,关键点记录 (三)之UI菜单制作
- DedeCMS实战-----2、制作频道封面页模板
- Java 性能优化实战记录(1)---定位并分析耗cpu最多的线程
- 21讲项目实战CMS-wordpress主题网站模板制作
- DedeCMS实战-----1、制作首页模板
- Java 性能优化实战记录(1)---定位并分析耗cpu最多的线程
- qt+halcon配置方法记录
- 开源博客QBlog开发者视频教程:博客皮肤模板制作指南-模板之拿来主义(六)