要识别的图片
训练ocr,生成osc文件
read_image (Image, 'E:/halcon学习笔记/201909.jpg')
rgb1_to_gray (Image, GrayImage)
a:=['2','0','1','9']
create_ocr_class_svm (8, 10, 'constant', 'default', a, 'rbf', 0.02, 0.05, 'one-versus-all', 'normalization', 10, OCRHandle)
threshold (GrayImage, Region, 0, 100)
connection (Region, ConnectedRegions)
sort_region (ConnectedRegions, SortedRegions, 'first_point', 'true', 'column')
for i := 1 to |a| by 1
select_obj (SortedRegions, ObjectSelected, i)
if(i==1)
write_ocr_trainf (ObjectSelected, GrayImage, a[i-1], 'train_ocr')
else
append_ocr_trainf (ObjectSelected, GrayImage, a[i-1], 'train_ocr')
endif
stop ()
endfor
trainf_ocr_class_svm (OCRHandle, 'train_ocr', 0.001, 'default')
write_ocr_class_svm (OCRHandle, '2.osc')
read_image (Image