通过卡尺测量实现定位圆
素材图片【素材来源于iHalcon】:
处理效果如下:
代码:
read_image (Image, 'C:/Users/Sawyer/Desktop/10_39545_03405e515b16ed5.jpg')
get_image_size (Image, Width, Height)
create_metrology_model (MetrologyHandle1)
set_metrology_model_image_size (MetrologyHandle1, Width, Height)
* gen_circle (ROI_0, 199.5, 266.817, 130.134)
shapeParam:=[199.5, 266.817, 130.134]
add_metrology_object_generic (MetrologyHandle1, 'circle', shapeParam, 10, 5, 1, 40, [], [], Index)
apply_metrology_model (Image, MetrologyHandle1)
get_metrology_object_result_contour (Contour, MetrologyHandle1, 'all', 'all', 1.5)
get_metrology_object_measures (Contours, MetrologyHandle1, 'all', 'all', Row, Column)
get_metrology_object_result (MetrologyHandle1, 'all', 'all', 'result_type', 'all_param', Parameter)
clear_metrology_model (MetrologyHandle1)
stop()
************************************************************************************
create_metrology_model (MetrologyHandle2)
set_metrology_model_image_size (MetrologyHandle2, Width, Height)
* gen_circle (ROI_0, 200.34, 263.548, 155.818)
shapeParam:=[200.34, 263.548, 155.818]
add_metrology_object_generic (MetrologyHandle2, 'circle', shapeParam, 10, 5, 1, 40, [], [], Index)
apply_metrology_model (Image, MetrologyHandle2)
get_metrology_object_result_contour (Contour, MetrologyHandle2, 'all', 'all', 1.5)
get_metrology_object_measures (Contours, MetrologyHandle2, 'all', 'all', Row, Column)
get_metrology_object_result (MetrologyHandle2, 'all', 'all', 'result_type', 'all_param', Parameter)
clear_metrology_model (MetrologyHandle2)
利用同样的方式可以实现卡尺测量直线,椭圆等。