博主写作不容易,孩子需要您鼓励 万水千山总是情 , 先点个赞行不行
处理要求
测量圆环同心度
处理源码
read_image ( Image , 'C:/Users/22967/Desktop/图像Barrel 20201024/201024 手机行业 摄像头检测/Barrel 背光/Pic_2020_10_24_095951_blockId#20579.bmp' )
dev_close_window ( )
dev_open_window_fit_image ( Image , 0 , 0 , - 1 , - 1 , WindowHandle ) * 背光,测量外轮廓相对圆心差别
* Image Acquisition 01 : Code generated by Image Acquisition 01
list_files ( 'C:/Users/22967/Desktop/图像Barrel 20201024/201024 手机行业 摄像头检测/Barrel 背光' , [ 'files' , 'follow_links' ] , ImageFiles )
tuple_regexp_select ( ImageFiles , [ '\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$' , 'ignore_case' ] , ImageFiles )
for Index : = 0 to | ImageFiles | - 1 by 1 read_image ( Image , ImageFiles [ Index ] ) binary_threshold ( Image , Region , 'max_separability' , 'dark' , UsedThreshold ) connection ( Region , ConnectedRegions ) select_shape_std ( ConnectedRegions , SelectedRegions , 'max_area' , 70 ) smallest_circle ( SelectedRegions , Row , Column , Radius ) fill_up ( SelectedRegions , RegionFillUp ) difference ( RegionFillUp , SelectedRegions , RegionDifference ) smallest_circle ( RegionDifference , Row1 , Column1 , Radius1 ) FindShapeModelBaseMetro ( Image , Contour , Row , Column , Radius , ParameterUnder ) FindShapeModelBaseMetro ( Image , Contour , Row1 , Column1 , Radius1 , ParameterUnder1 ) disUnderX [ Index ] : = ParameterUnder [ 1 ] -ParameterUnder1 [ 1 ] disUnderY [ Index ] : = ParameterUnder [ 0 ] -ParameterUnder1 [ 0 ] disUnder [ Index ] : = pow ( pow ( disUnderX [ Index ] , 2 ) + pow ( disUnderY [ Index ] , 2 ) , 0.5 ) dev_display ( Image ) dev_set_draw ( 'margin' ) disp_circle ( WindowHandle , Row1 , Column1 , Radius1 ) disp_circle ( WindowHandle , Row , Column , Radius )
* stop ( )
endfor
tuple_deviation ( disUnder , DeviationUnder )
stop ( )
自定义函数FindShapeModelBaseMetro
源码
create_metrology_model ( MetrologyHandle ) add_metrology_object_circle_measure ( MetrologyHandle , Row , Column , Radius , Radius / 10 , Radius / 60 , 1 , 4 , [ 'measure_distance' , 'min_score' ] , [ Radius / 30 , 0.2 ] , Index1 ) apply_metrology_model ( Image , MetrologyHandle ) gen_empty_obj ( Contours ) get_metrology_object_measures ( Contours , MetrologyHandle , 'all' , 'all' , Row1 , Column1 ) get_metrology_object_result ( MetrologyHandle , 'all' , 'all' , 'result_type' , 'all_param' , Parameter ) get_metrology_object_result_contour ( Contour , MetrologyHandle , 'all' , 'all' , 1.5 ) clear_metrology_model ( MetrologyHandle )
return ( )
处理结果
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 分割线
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
博主简介: 工业自动化上位机软件工程师、机器视觉算法工程师、运动控制算法工程师。目前从业于智能制造自动化行业。 博主邮箱:2296776525@qq.com