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

* ------------------------------------------------------------------------------------------------
* 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 ()
 
 

你可能感兴趣的:(Halcon,Halcon)