《zw版·Halcon-delphi系列原创教程》 邮票艺术品自动分类脚本
邮票艺术品自动分类脚本,是个综合应用,有不同尺寸图像的自动识别、区域分割
还有作品附近文字的自动分割
此类项目,字符都不是标准工业字符,ocr需要重新建库,这里就略过了。
ps,脚本很短,才40多行,有兴趣的网友,可以自己改为delphi、vc、vb版
1 gen_rectangle1 (Rect, 0, 0, 5, 5) 2 dev_update_var ('off') 3 dev_update_window ('off') 4 dev_close_window () 5 read_image (Image, 'stamps/swiss1') 6 get_image_size (Image, Width, Height) 7 dev_open_window (0, 0, round(Width / 1.5), round(Height / 1.5), 'black', WindowID) 8 set_display_font (WindowID, 14, 'mono', 'true', 'false') 9 for i := 1 to 9 by 1 10 read_image (Image, 'stamps/swiss' + i) 11 get_image_size (Image, Width, Height) 12 dev_set_part (0, 0, Height - 1, Width - 1) 13 dev_display (Image) 14 dev_set_draw ('fill') 15 threshold (Image, Dark, 0, 110) 16 fill_up (Dark, DarkFilled) 17 connection (DarkFilled, ConnectedRegions) 18 select_shape (ConnectedRegions, PotStamps, 'area', 'and', 10000, 100000000) 19 opening_rectangle1 (PotStamps, Stamps, 10, 10) 20 select_shape (ConnectedRegions, Lines, 'convexity', 'and', 0, 0.3) 21 select_shape (ConnectedRegions, Character, 'area', 'and', 10, 500) 22 top_hat (Lines, Rect, RegionTopHat) 23 connection (RegionTopHat, ConnTopHat) 24 select_shape (ConnTopHat, AllLines, 'area', 'and', 150, 1000000) 25 union1 (Character, CharacterUnion) 26 dilation_rectangle1 (CharacterUnion, Words, 8, 2) 27 connection (Words, SingleWords) 28 shape_trans (SingleWords, RectWords, 'rectangle1') 29 dev_set_draw ('margin') 30 dev_display (Image) 31 dev_set_color ('red') 32 dev_display (AllLines) 33 dev_set_color ('green') 34 dev_display (Stamps) 35 dev_set_color ('yellow') 36 dev_display (Character) 37 dev_set_color ('blue') 38 dev_display (RectWords) 39 if (i < 9) 40 disp_continue_message (WindowID, 'black', 'true') 41 endif 42 stop () 43 endfor 44 dev_display (Image)
【《zw版·Halcon-delphi系列原创教程》,网址,cnblogs.com/ziwang/】