OCR字符识别 Halcon同类软件 Malcon 机器视觉软件 DoOcrSingleClassKnn DoOcrMultiClassKnn
Malcon的OCR字符识别应用起来很方便,可以保存和读取,
1、读取图片ReadImage
2、阈值分割Threshold
3、连通区域Connection
4、排序区域SortRegion
5、贴上类标签Class:=['a','a','a','a','b','b','b','b','c','c','c','c']
6、写入字符文件WriteOcrTrainf
7、读取字符文件:输出标签类名和数量ReadOcrTrainfNames
8、创建OCR句柄CreateOcrClassKnn
9、训练OCR句柄TrainfOcrClassKnn
10、单个字符分类DoOcrSingleClassKnn
11、多个字符分类DoOcrMultiClassKnn
12、清除字符句柄ClearOcrClassKnn
13、获取字符区域的位置坐标AreaCenter
14、设置显示字体SetDisplayFont
15、显示字符信息DispMessage
ReadImage(moImage, 'a1.bmp')
Threshold(moImage, thRegion, 0, 50)
Connection(thRegion, thRegion)
//区域从左到右,从上到下排序
SortRegion(thRegion, StRegion,'character', 'true', 'row')
Class:=['a','a','a','a','b','b','b','b','c','c','c','c']
WriteOcrTrainf(StRegion,moImage,Class,'KNNletters.trf')
ReadOcrTrainfNames('KNNletters.trf',name,count)
CreateOcrClassKnn(15,15,'','',name,'','',ocrHandle)
TrainfOcrClassKnn(ocrHandle,'KNNletters.trf','','')
//开始分类
DoOcrSingleClassKnn(StRegion,moImage,ocrHandle,1,1,Class2,Confidence)
DoOcrMultiClassKnn(StRegion,moImage,ocrHandle,Class3,Confidence2)
ClearOcrClassKnn(ocrHandle)
//把结果显示出来
AreaCenter(StRegion,Area,Row,Column)
SetDisplayFont(3600,40,'','true','false')
DispMessage(3600,Class3,'',Row,Column,'red','false')