主要内容

Train Optical Character Recognition for Custom Fonts

光学特征识别(OCR)应用程序训练ocr识别自定义语言或字体的功能。您可以使用此应用程序将角色数据交互标记以进行OCR培训,并生成OCR语言数据文件,以与ocrfunction.

Open the OCR Trainer App

  • MATLAB®Toolstrip: On theAppstab, underImage Processing and Computer Vision, click, the OCR app icon.

  • MATLAB命令提示:输入OCRTRAINER.

火车OCR

  1. 在OCR教练,单击新会话to open the OCR Training Session Settings dialog box.

  2. Under输出设置,输入OCR语言数据文件的名称,然后选择文件的输出文件夹位置。您指定的位置必须是可写的。

  3. UnderLabeling Method,要么使用光学字符识别来手动标记数据或预先标记。如果使用OCR,则可以选择预装的英语或日语,也可以下载其他语言支持文件。金宝app

    Note

    To download a language support file, typevisionSupportPackagesin a MATLAB Command Window. Alternatively, on the MATLABHome标签,在环境部分中,点击附加组件>Get Add-Ons. Then use the search box to find “Computer Vision System Toolbox OCR Language Data.”

  4. Add images at any time during the training session. The trainer automatically segments the images for OCR training. Inspect the results to verify expected text segmentation. To improve the segmentation, pre-process your images using theImage Segmenterapp. Once the images are added, you can inspect segmentation results from the training image view.

    To limit the OCR to a specific character set, select theCharacter setcheck box and add the characters.

    Note

    使用包含您希望OCR识别的文本的培训图像。请勿仅使用几个字符的训练图像。如果训练图像包含许多单词的块,则OCR培训最有效。您可以使用insertText功能自动为已知字体生成训练图像。

    I = zeros(500,500,3,'uint8'); textLines = [ "some training text" "even more stuff to learn" ] lineYLocation = 50; for i = 1:numel(textLines) I = insertText(I,[50 lineYLocation],char(textLines(i)), ... 'Font','LucidaSansRegular',... 'FontSize',16,'TextColor','white',... 'BoxOpacity',0); % increment to next line lineYLocation = lineYLocation + 20; end figure imshow(I)
  5. Remove any noisy images. To improve segmentation results, you can draw a region of interest to select a portion of an image. The display shows the original image on the left and the edited one on the right. When you are done, clickAccept All.

  6. Modify the extracted samples from the character view window.

    • To correct samples, select a group of samples in the character view window and change the labels using theCharacter Labelfield.

    • 要从培训中排除样品,请右键单击样品,然后选择将该样品移动到的选项Unknown类别。未知样品在数据浏览器窗口的顶部列出,不用于培训。

    • If the bounding box clipped a character, double-click the character and modify it in the image it was extracted from.

  7. After correcting the samples, clickTrain. When the trainer completes training, the app creates an OCR language data file and saves it to the folder you specified.

App Controls

Sessions

Starts a new session, opens a saved session, or adds a session to the current one. You can also save and name the session. The sessions are saved as MAT files.

添加图像

添加图像。您可以在开始新会话或接受当前图像集合后添加图像。

Settings

Set or change the font display.

编辑框

Selects the image that contains the selected character, along with the bounding boxes. You can create additional regions, merge, modify, or delete existing images. To delete an ROI, use the删除钥匙。

Train

Creates an OCR data file from the session. To use the.traineddata带有ocrfunction, set the'Language'属性ocrfunction, and follow the directions for a custom language.

Generate Function

Creates an autogenerated evaluation function for verification of training results.

Note

Before running the OCR Trainer app, check if your machine has only one Tesseract installation. If there are multiple Tesseract installations, remove the extra installations and restart MATLAB to run the OCR Trainer app. Otherwise, the app returns the error "Not enough input arguments" when you click the Train button.

See Also

|