基于Halcon学习的OCR识别【四】----点状字符

dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
read_image (Image20160713, 'C:/Users/gwd/Desktop/20160713.png')
get_image_size (Image20160713, Width, Height)
gen_rectangle1 (ROI_0, 97.3428, 119.137, 219.979, 488.137)
text_line_orientation (ROI_0, Image20160713, 25, -0.523599, 0.523599, OrientationAngle)
vector_angle_to_rigid (Height/2, Width/2, OrientationAngle, Height/2, Width/2, 0, HomMat2D)
affine_trans_image (Image20160713, ImageAffineTrans, HomMat2D, 'constant', 'false')
dots_image (ImageAffineTrans, DotImage, 5, 'dark', 0)
reduce_domain (DotImage, ROI_0, ImageReduced)
invert_image (ImageReduced, ImageInvert)

binary_threshold (ImageReduced, Region, 'max_separability', 'light', UsedThreshold)
dilation_rectangle1 (Region, RegionDilation, 3.5, 6.5)
connection (RegionDilation, ConnectedRegions)
shape_trans (ConnectedRegions, RegionTrans, 'rectangle1')
select_shape (RegionTrans, SelectedRegions, 'area', 'and', 182.59, 2000)
intersection (SelectedRegions, Region, RegionIntersection)

sort_region (RegionIntersection, SortedRegions, 'character', 'true', 'row')
*此处用halcon自带的点状库
read_ocr_class_mlp ('DotPrint_0-9A-Z_NoRej.omc', OCRHandle)
do_ocr_multi_class_mlp (SortedRegions, ImageInvert, OCRHandle, Class, Confidence)

dev_display (ImageAffineTrans)
smallest_rectangle1 (SortedRegions, Row1, Column1, Row2, Column2)
count_obj (SortedRegions, Number)
for i:=1 to Number by 1
*显示
disp_message (WindowHandle, Class[i-1], 'Image2016', Row2[i-1]+30, Column1[i-1], 'red', 'true')
endfor

 第二个点状图片:

 

read_image (Image11, 'C:/Users/gwd/Desktop/2.bmp')
 
get_image_size (Image, Width, Height)
gen_rectangle1 (ROI_0, 258.5, 348.25, 572.5, 1095.75)
    
text_line_orientation (ROI_0, Image, 25, -0.523599, 0.523599, OrientationAngle)
vector_angle_to_rigid (Height/2, Width/2, OrientationAngle, Height/2, Width/2, 0, HomMat2D)
affine_trans_image (Image, ImageAffineTrans, HomMat2D, 'constant', 'false')
dots_image (ImageAffineTrans, DotImage, 5, 'dark', 0)
reduce_domain (DotImage, ROI_0, ImageReduced)
    
invert_image (ImageReduced, ImageInvert)   
binary_threshold (ImageReduced, Region, 'max_separability', 'light', UsedThreshold)
dilation_rectangle1 (Region, RegionDilation, 5, 13.5)
connection (RegionDilation, ConnectedRegions)
shape_trans (ConnectedRegions, RegionTrans, 'rectangle1')
select_shape (RegionTrans, SelectedRegions, 'area', 'and', 499.15, 5000)
intersection (SelectedRegions, Region, RegionIntersection)

sort_region (RegionIntersection, SortedRegions, 'character', 'true', 'row')
read_ocr_class_mlp ('DotPrint_0-9A-Z_NoRej.omc', OCRHandle)
do_ocr_multi_class_mlp (SortedRegions, ImageInvert, OCRHandle, Class, Confidence)

dev_display (ImageAffineTrans)
smallest_rectangle1 (SortedRegions, Row1, Column1, Row2, Column2)
count_obj (SortedRegions, Number)
for i:=1 to Number by 1
    
disp_message (200000, Class[i-1], 'Image2016', Row2[i-1]+30, Column1[i-1], 'red', 'true')

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值