基于Halcon学习的OCR识别【三】----圆环字符

*读入图像
read_image (Image11, 'C:/Users/gwd/Desktop/1.1.bmp')
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
dev_display (Image11)
rgb1_to_gray (Image11, GrayImage)

*提取内外圆的半径
threshold (GrayImage, Regions, 0, 111)
shape_trans (Regions, outcircle, 'outer_circle')

*返回一个区域的补集
complement (Regions, RegionComplement)
connection (RegionComplement, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 1.56034e+006, 2.66379e+006)
smallest_circle (Regions, Row, Column, OuterRadius)

smallest_circle (SelectedRegions, Row1, Column1, InnerRadius)
polar_trans_image_ext (Image11, PolarTransImage, Row, Column, rad(360), 0, OuterRadius-100, InnerRadius+40, 1440, 100, 'bilinear')
rgb1_to_gray (PolarTransImage, GrayImage1)
invert_image (PolarTransImage, ImageInvert)
scale_image (ImageInvert, ImageScaled,  6.71053, -1429)

binary_threshold (ImageScaled, Region, 'max_separability', 'light', UsedThreshold)
connection (Region, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 43.94, 500)
union1 (SelectedRegions1, RegionUnion)

*若改成,11,,11 则C会被识别成G
dilation_rectangle1 (RegionUnion, RegionDilation, 6, 6)
connection (RegionDilation, ConnectedRegions2)
intersection (ConnectedRegions2, Region, RegionIntersection)
sort_region (RegionIntersection, SortedRegions, 'character', 'true', 'row')
read_ocr_class_mlp ('Industrial_0-9A-Z_NoRej.omc', OCRHandle)
do_ocr_multi_class_mlp (SortedRegions, GrayImage1, OCRHandle, Class, Confidence)
stop ()
*显示
count_obj (SortedRegions, Number)
area_center (SortedRegions, Area, Row2, Column2)
for i := 1 to Number by 1
    disp_message (WindowHandle, Class[i-1], 'PolarTransImage', 40, Column2[i-1]-20, 'red', 'true')
endfor

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值