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精华文章

转载于:https://www.cnblogs.com/xiaomaLV2/p/5087657.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值