HALCON之噴碼OCR識別案例

一個噴碼識別的案例

 

 1 read_image (Image, 'D:/用戶目錄/Desktop/2.png')
 2    
 3 rgb1_to_gray(Image, Image) 4 5 get_image_size (Image, Width, Height) 6 7 * 獲取噴碼區域的方法不少 好比能夠用mean+dyn的動態閾值 8 dots_image (Image, DotImage, 5, 'dark', 2) 9 threshold (DotImage, Region, 30, 255) 10 11 *這裏是形態學運算操做 目的就是要將單體字符連在一塊兒 12 *這裏面用到的自定義核你們能夠學習一下 13 closing_rectangle1 (Region, RegionClosing1, 1, 7) 14 closing_rectangle1 (RegionClosing1, RegionClosing2, 7, 1) 15 gen_rectangle2 (Rectangle, 10, 10, rad(45), 3, 0) 16 closing (RegionClosing2, Rectangle, RegionClosing3) 17 gen_rectangle2 (Rectangle, 10, 10, rad(135), 3, 0) 18 closing (RegionClosing3, Rectangle, RegionClosing4) 19 connection (RegionClosing4, ConnectedRegions) 20 select_shape (ConnectedRegions, SelectedRegions, ['area','height'], 'and', [100,50], [1000,70]) 21 22 23 *排序爲下步識別作準備 24 sort_region(SelectedRegions, SortedRegions, 'character', 'true', 'column') 25 area_center(SortedRegions, Area, Row, Column) 26 27 28 *識別階段 29 FontName:='DotPrint.omc' 30 read_ocr_class_mlp(FontName, OCRHandle) 31 do_ocr_multi_class_mlp (SortedRegions, Image, OCRHandle, RecNum, Confidence) 32 33 set_display_font (3600, 27, 'mono', 'true', 'false') 34 for i := 0 to |RecNum| - 1 by 1 35 disp_message (3600, RecNum[i], 'image', 200,Column[i], 'green', 'false') 36 endfor 37 clear_ocr_class_mlp (OCRHandle) 38 

 

halcon 的 DtoPrint 預設分類器不支持小寫 ,能夠使用Industrial.omc , 也能夠本身訓練

 

關注微信:halconhub,每日獲取halcon精華文章
相關文章
相關標籤/搜索