遗忘海岸

江湖程序员 -Feiph(LM战士)

导航

中文识别

read_image (Image, '中文.png')
binary_threshold (Image, Region, 'max_separability', 'dark', UsedThreshold)
dilation_circle (Region, RegionDilation, 1)
connection (RegionDilation, ConnectedRegions2)
intersection ( ConnectedRegions2,Region, RegionIntersection)
sort_region (RegionIntersection, SortedRegions, 'character', 'true', 'row')

* Str :='这意味着在进一步的操作中图像矩阵包含所有像素'
* Fonts:=['','','','','','','','','','','','','','','','','','','','','','']
* classes:=[]
* for Index := 1 to 8 by 1
*     classes:=[classes,Fonts]
* endfor

* write_ocr_trainf (SortedRegions, Image, classes, '中文_ocr')
*read_ocr_trainf (Characters, '中文_ocr', CharacterNames)
* read_ocr_trainf_names ('中文_ocr', CharacterNames, CharacterCount)
* create_ocr_class_mlp (8, 10, 'constant', 'default',CharacterNames, 80, 'none', 10, 42, OCRHandle)
* trainf_ocr_class_mlp (OCRHandle, '中文_ocr', 200, 1, 0.01, Error, ErrorLog)
* write_ocr_class_mlp (OCRHandle, '中文_ocr')
read_ocr_class_mlp ('中文_ocr', OCRHandle)
read_image (Image2, '中文目标.png')
* vector_angle_to_rigid (200, 200, 0, 200, 200, rad(45), HomMat2D)
* affine_trans_image (Image2, ImageAffineTrans, HomMat2D, 'constant', 'false')

binary_threshold (Image2, Region2, 'max_separability', 'dark', UsedThreshold)
dilation_circle (Region2, RegionDilation2, 1)
connection (RegionDilation2, ConnectedRegions3)
intersection ( ConnectedRegions3,Region2, RegionIntersection2)
sort_region (RegionIntersection2, SortedRegions2, 'character', 'true', 'row')
do_ocr_multi_class_mlp (SortedRegions2, Image2, OCRHandle, Class, Confidence)
area_center (SortedRegions2, Area, Row, Column)
tuple_length (Row, Length)
phi:=gen_tuple_const(Length,0.0)
L1:=gen_tuple_const(Length,20)
L2:=gen_tuple_const(Length,20)
smallest_rectangle2 (SortedRegions2, Row1, Column1, Phi2, Length1, Length2)
gen_rectangle2_contour_xld (Rectangle1, Row1, Column1, Phi2, Length1 , Length2)
set_display_font (200000, 16, 'sans', 'true', 'false')
disp_message (200000, Class, 'window', Row-10, Column+2, 'black', 'true')
clear_ocr_class_mlp (OCRHandle)
View Code

打一些文字,然后做训练

然后识别

posted on 2021-07-15 17:27  遗忘海岸  阅读(54)  评论(0编辑  收藏  举报