代码如下:

*创建窗口
dev_open_window (0, 0, 500, 300, 'black', WindowID)
*清除窗口
dev_clear_window ()
*读取图片
read_image (Image, 'C:/Users/58937/Desktop/4.png')
*图片分为R,G.B三个分量
decompose3 (Image, Red, Green, Blue)
*图片分为h,s,v三个分量
trans_from_rgb (Red, Green, Blue, Hue, Saturation, Intensity, 'hsv')
*图像颜色反转
invert_image (Saturation, ImageInvert)
*阈值分割
threshold (ImageInvert, Regions, 0, 0)
*砍断,分成几个区域
connection (Regions, ConnectedRegions)
*根据行进行分割
select_shape (ConnectedRegions, SelectedRegions2, 'row', 'and', 208.72, 243.58)
*根据列进行分割
select_shape (SelectedRegions2, SelectedRegions1, 'column', 'and', 63.3, 925.69)
*区域排序从左往右
sort_region (SelectedRegions1, SortedRegions, 'first_point', 'true', 'column')
*调用自带字库
read_ocr_class_mlp ('Industrial_0-9A-Z_NoRej.omc', OCRHandle)
*文字识别
do_ocr_multi_class_mlp (SortedRegions, ImageInvert, OCRHandle, Class, Confidence)
*显示原图
dev_display (Image)
*显示文字于图片
write_string (WindowID, Class)

图片如下:

Halcon识别字母数字

相关文章:

  • 2021-12-23
  • 2021-12-14
  • 2021-09-05
  • 2021-04-06
  • 2021-10-15
猜你喜欢
  • 2022-01-15
  • 2021-04-27
  • 2021-06-05
  • 2021-12-06
  • 2022-12-23
  • 2021-11-06
  • 2021-12-14
相关资源
相似解决方案