Skip to content

Shape-based matching🔗

General concept🔗

More Info

Learn about shape-based matching and many other topics in interactive online courses at our MVTec Academy.

Shape-based matching using the generic interface consists of these main steps:

flowchart TD
    A[Select the object in the
reference image] --> B[Create a suitable shape
model]
    B --> C[Train the model]
    C --> D[Find object instances]

Step 1: Select the object in the reference image

After grabbing the reference image the first task is to create a region containing the object. This object will serve as training template in Step 3.

Step 2: Create a suitable shape model

The model is created using the operator create_generic_shape_model. As a result, the operator returns a handle for the newly created model (ModelID). Parameters modifying the model ModelID itself have to be set in this step using set_generic_shape_model_param. Changing a corresponding value later makes it necessary to retrain the adjusted model before the matching. This is also indicated by the parameter 'needs_training', which you can retrieve using get_generic_shape_model_param. Note that if you use HALCON’s .NET, or C++ interface and call the operator via the class HShapeModel, no handle is returned because the instance of the class itself acts as your handle.

Step 3: Train the model

Train the created model using train_generic_shape_model in order to find the training pattern given in Template.

Step 4: Find object instances

Find the model object instances using find_generic_shape_model. Parameters optimizing the search of a model instance can be set using set_generic_shape_model_param as their modification does not necessitate a model training. Note, that this is not the case if they are set from a non-estimated value to a value leading to an automatic estimation during train_generic_shape_model.