[机器视觉]halcon应用实例 找圆
代码
*清空屏幕,显示控制图像
dev_close_window ()
dev_update_off ()
read_image (Image, '形状模板图')
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
dev_display (Image)
*创建测量模型
create_metrology_model (MetrologyHandle)
*给制圆形
draw_circle (WindowHandle, Row, Column, Radius)
*添加找圆工具,给定参数,显示过程卡尺
add_metrology_object_circle_measure (MetrologyHandle, Row, Column, Radius, 50, 5, 1, 30, [], [], Index)
get_metrology_object_model_contour (Contour, MetrologyHandle, 0, 1.5)
get_metrology_object_measures(Contours, MetrologyHandle, 'all', 'all', Row1, Column1)
dev_set_color ('cyan')
dev_display(Contour)
dev_display (Contours)
*执行找圆并显示结果
apply_metrology_model (Image, MetrologyHandle)
get_metrology_object_result (MetrologyHandle, 0, 'all', 'result_type', 'all_param', Parameter)
get_metrology_object_result_contour (Contour1, MetrologyHandle, 0, 'all', 1.5)
dev_set_line_width (3)
dev_set_color ('red')
dev_display(Contour1)
clear_metrology_model (MetrologyHandle)
END