Halcon---------align_measurements.hdev学习总结

本文总结了使用Halcon的align_measurements.hdev示例进行模板匹配的学习心得。相较于VisionPro,Halcon操作更为复杂,尤其在创建辅助线和减少域的操作上。通过create_shape_model、find_shape_model等算子定位模板,gen_measure_rectangle2和measure_pairs计算边缘对的齿数,进而识别缺失部分。
摘要由CSDN通过智能技术生成
* ------------------------------------------------------------------------------------------------
* This example program uses shape-based matching to align ROIs for the measure
* tool, which then inspects individual razor blades.
* The program can be run in two modes: 
* (1) with the full affine transformation
* (2) using translate_measure
* Modify the next line to switch between the modes.


USING_TRANSLATE_MEASURE := 0       //后面用到,但一直看不懂这是干啥的?????????????

* general configuration of HDevelop
dev_update_window ('off')
* image acquisition and window size
read_image (ModelImage, 'razors1')
get_image_pointer1 (ModelImage, Pointer, Type, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'white', WindowHandle)
dev_set_part (0, 0, Height - 1, Width - 1)
dev_display (ModelImage)
* colors and other settings for the visualization
dev_set_color ('cyan')
dev_set_draw ('margin')
dev_set_line_width (2)
stop ()
* -------------------  start of the application  ----------------
* -> select the model object    //这一步在模板匹配前用XLD框出要用的模板
Row1 := 46
Column1 := 57
Row2 := 79
Column2 := 94
gen_rectangle1 (ROIPart1, Row1, Column1, Row2, Column2)
gen_rectangle1 (ROIPart2, Row1 + 364, Column1 + 13, Row2 + 364, Column2 + 13)
union2 (ROIPart1, ROIPart2, ModelROI)
area_center (ModelROI, Area, CenterROIRow, CenterROIColumn)
dev_display (ModelImage)
dev_display (ModelROI)
stop ()
* -> create the model
reduce_domain (ModelImage, ModelROI, ImageROI)//缩小图像定义域到感兴趣的区域
create_shape_model (ImageROI, 4, 0, 0, 'auto', 'none', 'use_polarity', 30, 10, ModelID)
//创建模板,金字塔的级数Numlevels值越大则找到物体的时间越少,AngleStart和AngleExtent决定可能的旋转范围,AngleStep指定角度范围搜索的步长;
inspect_shape_model (ImageROI, ShapeModelImage, ShapeModelRegion, 1, 30)
//检查参数,这一步返回一个原始模板图片和模板的特征轮廓线
get_shape_model_contours (ShapeModel, ModelID, 1)
//1.返回了一个清晰的重新生成的特征轮廓线
//2.坐标(0,0)
//3.是XLD轮廓
dev_clear_window ()
dev_set_color ('blue')
dev_display (ShapeModelRegion)
stop ()

                
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值