read_image (Image1, 'C:/Users/ADMIN/Desktop/1.png')
rgb1_to_gray (Image1, GrayImage)
threshold (GrayImage, Regions1, 0, 127)
closing_rectangle1 (Regions1, RegionClosing, 10, 10)
connection (RegionClosing, ConnectedRegions)
shape_trans (ConnectedRegions, RegionTrans, 'rectangle1')
intersection (RegionTrans, Regions1, RegionIntersection)
sort_region (RegionIntersection, SortedRegions, 'character', 'true', 'row')
Class:=['你','好','丫','美','女','加','个','微','信','呗']
* 写入trf文件
write_ocr_trainf (SortedRegions, GrayImage, Class, 'C:/Users/ADMIN/Desktop/tranf.trf')
*添加trf
* append_ocr_trainf (SortedRegions, GrayImage, Class, 'C:/Users/ADMIN/Desktop/tranf1.trf')
*读取trf文件
read_ocr_trainf_names ('C:/Users/ADMIN/Desktop/tranf.trf', CharacterNames, CharacterCount)
*创建ocr分类器
create_ocr_class_mlp (10, 30, 'constant', 'default', CharacterNames, 80, 'none', 10, 42, OCRHandle)
*训练ocr分类器
trainf_ocr_class_mlp (OCRHandle, 'C:/Users/ADMIN/Desktop/tranf.trf', 200, 1, 0.01, Error, ErrorLog)
*写入ocr分类器
write_ocr_class_mlp (OCRHandle, 'C:/Users/ADMIN/Desktop/ocrF.omc')
read_image (Image, 'C:/Users/ADMIN/Desktop/2.png')
rgb1_to_gray (Image, GrayImage1)
threshold (GrayImage1, Regions, 0, 74)
closing_rectangle1 (Regions, RegionClosing1, 10, 10)
connection (RegionClosing1, ConnectedRegions1)
intersection (ConnectedRegions1, Regions, RegionIntersection1)
sort_region (RegionIntersection1, SortedRegions1, 'character', 'true', 'row')
*读取ocr分类器
read_ocr_class_mlp ('C:/Users/ADMIN/Desktop/ocrF.omc', OCRHandle1)
*
do_ocr_multi_class_mlp (SortedRegions1, GrayImage1, OCRHandle1, Class1, Confidence)
Halcon -OCR 中文
最新推荐文章于 2024-10-10 19:57:30 发布
本文介绍了使用OpenCV进行图像预处理,包括灰度转换、阈值处理和形态学操作,然后通过连接和形状转换实现字符区域提取。随后,展示了OCR技术的应用,如创建和训练MLP分类器,以及多阶段的识别流程。核心内容包括读取图像、识别字符并将其分类。
摘要由CSDN通过智能技术生成