Training of Custom Classifiers in MVTec HALCON

Published on October 31, 2019 by TIS Marketing.

This post, Training of Custom Classifiers in MVTec HALCON is the sixth in a series of 7 posts from Pushing OCR Performance with MVTec HALCON: 1, 2, 3, 4, 5, 6, 7.

Previous posts covered working with the OCR assistant and the underlying methodology of a text model reader. This post focuses on the classification aspects of optical character recognition and, most importantly, the training of a custom classifier.

In some cases, the pre-trained fonts or symbol sets available in HALCON are unsuitable for the text at hand or do not deliver satisfactory results. Under these circumstances, an option to be considered is training a custom classifier tailored to the application's needs.

Fig. 1: Segmented symbols for training with OCR assistant

HALCON's OCR Assistant provides options for creating so-called training files. Training files contain information about the symbol region's ground truth class as well as information about their width and height.

Fig. 2: OCR assistant

The successful implementation of the segmentation step is crucial to the creation of such a training file (or when adding symbols with their respective class). This means, the image and region containing the symbols have been defined and set with correct segmentation parameters. Please note: Quick Setup can be used to perform these tasks.

After successful segmentation, teaching works as follows: By clicking into the text field (fig. 2, above), the first symbol for labeling is displayed in the image field (right). This process should be repeated with every symbol which needs to be taught, one after the other, by typing the corresponding class name into the text field. If all symbols are labeled with their ground truth class, the information can be added to the training data by clicking the button add to training data.

The number of samples is automatically adapted in the next section and training of the classifier is enabled. The classifier filename and status give some basic information about training success (e.g. the classifier's confidence score if it is applied on the training data set). You can click on Train Now to start the training process.

In the next post, the training of custom classifiers will be the topic as well as the creation of a training file and the usage of the Training File Browser in HDevelop. (Please see navigation at the top of this page for additional posts.)

Please click here to download image.