Training of Custom Classifiers in MVTec HALCON: Advanced Parameters

Published on November 5, 2019

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

The last post covered the training of a custom classifier tailored to particular application requirements. The focus of this post will be on using advanced parameters when training a custom classifier.

<b>Fig. 1:</b> Teaching assistant

Since the classifier should be invariant with respect to scaling, symbol training regions (and later on, the ones for classification) are scaled to a fixed size. This size can be defined with the parameters Pattern Width and Pattern Height found in the Basic Features section (Fig. 1). If the scaling is too small, important information might not be included and result in underfitting. Conversely, too-large scaling could result in over-specification (overfitting) and increase calculation time for both training and classification.

Gray Values, Symbol Region or Gradient information can be selected under Basic Features. Additional features for the classifier can be selected in Advanced Training Parameters and Features - (e.g. ratio, anisometry or convexity).

In Advanced Training Parameters and Features, the classifier type can also be changed. The available approaches range from support-vector machines (SVM) to k-nearest neighbor (k-NN) and Hyperbox classifiers. (In-depth information on classifiers is discussed at the The Imaging Source's regularly-occuring Machine Learning in HALCON seminars.) For the purposes of this post, a multilayer perceptron (MLP) will be used as the default classifier. Often, the default parameters deliver satisfactory results. Therefore, default classifiers should only be changed if there is certainty that misclassifications are a result of the underlying classifier structure.

Since multiple samples are usually necessary for a good training set, more than one image might be required. After adding samples to the training data and saving the training file, it is always possible to go back to the Setup tab and load a new image and a new region.

Best case, the segmentation will not need to be adapted to the new image and the teaching process can begin again. It is possible that the classifier (already trained on the previous samples) suggests the right classifications. These suggestions can be inserted into the text field by clicking the blue arrow underneath the text field. Training has to be executed again with the whole training file.

The Training File Browser (Fig. 2) which is available by clicking on the right symbol next to Selection of Training File, allows you to inspect the single samples. It not only shows every single sample with segmented region, class and size but also enables the testing of a classifier on this data. If training samples are rare and also occur in rotated or scaled versions, it could also be useful to augment the data accordingly and add new samples to the training data set. To generate variations of the data, select the correct option in the Edit menu.

<b>Fig. 2:</b> <i>Training File Browser</i>

If the training symbols and classification results on the training set are satisfactory, the classifier can be used like any other pre-trained classifier. Classifier training can also be performed without the assistant: Under the tab Code Generation HALCON allows for the placement of the respective code. If all samples should not be added (but rather only in a semi-automatic way), the desired training file can be appended with append_ocr_trainf.

This series of eight posts covered a simple way of getting started with OCR (e.g. basic operators in working with text model readers and how to create and modify a training file). If you have any questions feel free to contact us or visit one of our training courses.

Please click here to download image.

Share this post with your friends and coworkers:

Post published by TIS Marketing on November 5, 2019.

About The Imaging Source

Established in 1990, The Imaging Source is one of the leading manufacturers of industrial cameras, video converters and embedded vision components for factory automation, quality assurance, medicine, science, security and a variety of other markets.

Our comprehensive range of cameras with USB 3.1, USB 3.0, USB 2.0, GigE, MIPI interfaces and other innovative machine vision products are renowned for their high quality and ability to meet the performance requirements of demanding applications.

ISO 9001:2015 certified MVTEC | Edge AI + Vision Alliance | EMVA

Contact us