align_metrology_model (Operator)

Name

align_metrology_model — Alignment of a metrology model.

Signature

align_metrology_model( : : MetrologyHandle, Row, Column, Angle : )

Description

align_metrology_model moves and rotates the whole metrology model MetrologyHandle relative to the image coordinate system which has its origin in the top left corner.

For an explanation of the concept of 2D metrology see the introduction of chapter 2D Metrology.

An alignment ensures, that the position and orientation of the metrology model is adapted to the objects to be measured in the current image. The alignment is then used by apply_metrology_model to perform the measurement. First the metrology model is rotated by Angle, then the metrology model is translated by Row and Column. The values of the alignment are overwritten by the next call of align_metrology_model.

Computation of the parameters of the alignment

The parameters of the alignment can be determined using diverse methods. Here, three possibilities to determine the parameters are listed:

Using region analysis:

If the metrology model can be extracted using region processing and if the pose of the Region changes only slightly in subsequent images, the parameters of the reference system of the metrology model and of the alignment can be derived using region analysis. In the following picture threshold and smallest_rectangle2 were used to obtain these parameter.

The region extracted with threshold is shown in red. The rectangle computed with smallest_rectangle2 is shown in green.
1. Setting the reference system

In the image in which the metrology model was defined, extract a region containing the metrology objects. The pose of this region with respect to the image coordinate system is determined and set as the reference system of the metrology model using set_metrology_model_param. This step is only performed once when setting up the metrology model.

Example:

2. Determining the alignment

In an image where the metrology model occurs in a different Pose, the current pose if the extracted region is determined. This pose is then used to align the metrology model.

Example:

align_metrology_model(MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)

Using a shape model:

If a shape model is used to align the metrology model, the reference system with respect to which the metrology objects are given has to be set so that it coincides with the coordinate system used by the shape model. Only then, the results (Row, Column, Angle) of find_shape_model can be used directly in align_metrology_model to align the metrology model in the current image. The individual steps that are needed, are shown below.

 (1) (2) (3)
(1) The contours of the metrology model (2) The contours of the shape model (3) The contours of the metrology model after setting the correct reference system.
1. Setting the reference system

In the image in which the metrology model was defined, the pose of the origin of the shape model is determined and set as the reference system of the metrology model using set_metrology_model_param. This step is only performed once when setting up the metrology model.

Example:

2. Determining the alignment

In an image, in which the object to be measured occurs in a different pose, the current pose of the shape model is determined and set in the metrology model using align_metrology_model.

Example:

align_metrology_model(MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)

Using a rigid 2D transformation:

If certain model points (given as [PRowModel], [PColumnModel]) can be clearly identified and if they can still be clearly identified in further images in which the objects to be measured can occur shifted or rotated, a rigid transformation can be calculated between those points. The transformation parameters can then directly be used for aligning the model. In this case, the reference point of the metrology model does not have to be changed.

 (1) (2)
(1) The contours of the metrology object and the four corresponding points in the image that was used for the creation of the metrology model. (2) The contours of the metrology object and the four corresponding points in a new image.
1. Determine the point correspondences

2. Estimate the model pose

The following operator sequence calculates the parameters of the model pose (Row, Column, Angle) from corresponding points in the model image and one other image.

Example:

align_metrology_model(MetrologyHandle, Row, Column, Angle)

Execution Information

• Multithreading type: reentrant (runs in parallel with non-exclusive operators).
• Processed without parallelization.

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

Parameters

MetrologyHandle (input_control, state is modified)  metrology_model (handle)

Handle of the metrology model.

Row (input_control)  real (real / integer)

Row coordinate of the alignment.

Default value: 0

Column (input_control)  real (real / integer)

Column coordinate of the alignment.

Default value: 0

Angle (input_control)  angle.rad (real / integer)

Rotation angle of the alignment.

Default value: 0

Example (HDevelop)

create_metrology_model (MetrologyHandle)
get_image_size (Image, Width, Height)
set_metrology_model_image_size (MetrologyHandle, Width, Height)
CircleParam := [354,274,53]
CircleParam := [CircleParam,350,519,53]
5, 1, 30, [], [], CircleIndices)
create_shape_model (Image, 6, 0, rad(360), 'auto', 'auto', \
'use_polarity', 'auto', 20, ShapeModelID)
* Determine location of shape model origin
area_center (Image, Area, RowOrigin, ColOrigin)
set_metrology_model_param (MetrologyHandle, 'reference_system', \
[RowOrigin,ColOrigin,0])
find_shape_model (CurrentImage, ShapeModelID, 0, rad(360), 0.5, 1, 0, \
'least_squares', 5, 0.9, RowAlign, ColAlign, AngleAlign,\
Score)
align_metrology_model (MetrologyHandle, RowAlign,ColAlign,AngleAlign)
apply_metrology_model (CurrentImage, MetrologyHandle)
get_metrology_object_result (MetrologyHandle, CircleIndices, 'all', \
'result_type', 'all_param', Rectangle)
get_metrology_object_result_contour (Contour, MetrologyHandle, CircleIndices,\
'all', 1.5)

Result

If the parameters are valid, the operator align_metrology_model returns the value TRUE. If necessary, an exception is raised.