Halcon曲图识别字体OCR

read_image(Image, 'D:/图片/视觉检测图片/13.jpg')
rgb1_to_gray(Image, GrayImage)
get_image_size(GrayImage, Width, Height)
dev_close_window()
dev_open_window(0, 0, Width/2, Height/2, 'black', WindowHandle)
dev_display(GrayImage)

**********************大圆
scale_image(GrayImage, ImageScaled, 3, 5)
threshold(ImageScaled, Region, 70, 255)
opening_circle(Region, RegionOpening, 3.5)
connection(RegionOpening, ConnectedRegions)
select_shape(ConnectedRegions, SelectedRegions, 'area', 'and', 12000, 99999)
shape_trans(SelectedRegions, RegionTrans, 'outer_circle')
smallest_circle(RegionTrans, Row, Column, Radius)
gen_circle(Circle, Row+20, Column+10, Radius+20)

************************************小圆
dev_display(GrayImage)
threshold(GrayImage, Region1, 3, 17)
opening_circle(Region1, RegionOpening1, 25.5)
connection(RegionOpening1, ConnectedRegions1)
select_shape(ConnectedRegions1, SelectedRegions1, 'area', 'and', 30000, 99999)
shape_trans(SelectedRegions1, RegionTrans1, 'outer_circle')
smallest_circle(RegionTrans1, Row1, Column1, Radius1)
gen_circle(Circle1, Row1+5, Column1+20, Radius1)
difference(Circle, Circle1, RegionDifference)

**************************环形拉直
Widthpolar:=1440
Heightpolar:=round(Radius-Radius1)
*取形拉直角度未rad90-rad360
polar_trans_image_ext(GrayImage, PolarTransImage1, Row+20, Column+10, rad(90), rad(360),  Radius-100, Radius+100, Width, Height, 'nearest_neighbor')
polar_trans_image_ext(GrayImage, PolarTransImage2, Row1, Column1, rad(0), rad(90), Radius1, Radius1+100, Width, Height, 'nearest_neighbor')
*图片倒转,
mirror_image(PolarTransImage1, ImageMirror1, 'row')
*这个不反转,因为是参数是column
mirror_image(ImageMirror1, ImageMirror, 'column')
dev_close_window()
dev_open_window(0, 0, 1000, 200, 'black', WindowHandle1)


dev_display(ImageMirror1)
invert_image(ImageMirror, ImageInvert)
*增强,白的变亮,黑的变黑
emphasize(ImageInvert, ImageEmphasize, 20, 20, 5)
threshold(ImageEmphasize, Region2, 0, 95)

connection(Region2, ConnectedRegions2)
select_shape(ConnectedRegions2, SelectedRegions2, 'area', 'and', 200, 99999)
sort_region(SelectedRegions2, SortedRegions, 'first_point', 'true', 'row')
concat_obj(SortedRegions, SortedRegions, ObjectsConcat)
count_obj(ObjectsConcat, Number)
smallest_rectangle1(SortedRegions, Row11, Column11, Row2, Column2)
*获取OCR句柄
read_ocr_class_mlp('Industrial_0-9A-Z_NoRej.omc', OCRHandle)
*读取多个OCR字体
do_ocr_multi_class_mlp(SortedRegions, ImageEmphasize, OCRHandle, Class, Confidence)
*设置输出字体大小
set_display_font(WindowHandle1,16 , 'mono', 'true', 'false')
for Index :=1 to Number by 1
    *dev_disp_text(Class, 'window', Row11[1]-8, Column11[Index], 'green', [], [])
    disp_message(WindowHandle1, Class, 'Image', Row11[1]-200, Column11, 'yellow', 'true')
endfor

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小兴-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值