31.10、几何定位---实例五(同步缩放)
目标:根据几何定位训练一个模板进行定位。
*读取图像,该图像由halcon提供
read_image (Image, 'rings/nuts_01.png')
draw_region (Region, 3600)
reduce_domain (Image, Region, ImageReduced)
*创建模板
create_scaled_shape_model (ImageReduced, 'auto', rad(0), rad(360), 'auto', 0.5, 1.5, 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID)
*获取模板轮廓
get_shape_model_contours (ModelContours, ModelID, 1)
*查找模板
find_scaled_shape_model (Image, ModelID, rad(0), rad(360), 0.5, 1.5, 0.5, 20, 0.5, 'least_squares', 0, 0.9, Row, Column, Angle, Scale, Score)
*显示结果
if(|Score|>0)
dev_display_shape_matching_results (ModelID, 'red', Row, Column, Angle, Scale, Scale, 0)
endif