Operators |
align_metrology_model — Alignment of a metrology model.
align_metrology_model( : : MetrologyHandle, Row, Column, Angle : )
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:
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.
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.
threshold (Image, Region, 0, 50) smallest_rectangle2 (Region, RowOrig, ColumnOrig, AngleOrig, Length1, \ Length2) set_metrology_model_param (MetrologyHandle, 'reference_system', \ [RowOrig, ColumnOrig, AngleOrig])
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.
threshold (CurrentImage, Region, 0, 50) smallest_rectangle2 (Region, RowAlign, ColumnAlign, AngleAlign, Length1, \ Length2) align_metrology_model (MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)
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) |
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.
create_shape_model (Image, 6, 0, rad(360), 'auto', 'auto', \ 'use_polarity', 'auto', 20, ShapeModelID) area_center (Image, Area, RowOrig, ColumnOrig) set_metrology_model_param (MetrologyHandle, 'reference_system', \ [RowOrig,ColumnOrig,0])
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 .
find_shape_model (CurrentImage, ShapeModelID, 0, rad(360), 0.5, 1, 0, \ 'least_squares', 5, 0.9, RowAlign, ColumnAlign, AngleAlign,\ Score) align_metrology_model (MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)
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) |
Determine the point correspondences
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.
vector_to_rigid (PRowModel, PColumnModel, PRowCurrent, PColumnCurrent, HomMat2D) hom_mat2d_to_affine_par (HomMat2D, Sx, Sy, Angle, Theta, Row, Column) align_metrology_model (MetrologyHandle, Row, Column, Angle)
This operator modifies the state of the following input parameter:
The value of this parameter may not be shared across multiple threads without external synchronization.Handle of the metrology model.
read_image (Image, 'metal-parts/circle_plate_01') 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] add_metrology_object_generic (MetrologyHandle, 'circle', CircleParam, 20,\ 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]) read_image (CurrentImage, 'metal-parts/circle_plate_02') 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)
If the parameters are valid, the operator align_metrology_model returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.
set_metrology_model_param, add_metrology_object_generic
get_metrology_object_model_contour
2D Metrology
Operators |