align_metrology_modelT_align_metrology_modelAlignMetrologyModelAlignMetrologyModelalign_metrology_model (Operator)

Name

align_metrology_modelT_align_metrology_modelAlignMetrologyModelAlignMetrologyModelalign_metrology_model — Alignment of a metrology model.

Signature

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

Herror T_align_metrology_model(const Htuple MetrologyHandle, const Htuple Row, const Htuple Column, const Htuple Angle)

void AlignMetrologyModel(const HTuple& MetrologyHandle, const HTuple& Row, const HTuple& Column, const HTuple& Angle)

void HMetrologyModel::AlignMetrologyModel(const HTuple& Row, const HTuple& Column, const HTuple& Angle) const

void HMetrologyModel::AlignMetrologyModel(double Row, double Column, double Angle) const

static void HOperatorSet.AlignMetrologyModel(HTuple metrologyHandle, HTuple row, HTuple column, HTuple angle)

void HMetrologyModel.AlignMetrologyModel(HTuple row, HTuple column, HTuple angle)

void HMetrologyModel.AlignMetrologyModel(double row, double column, double angle)

def align_metrology_model(metrology_handle: HHandle, row: Union[int, float], column: Union[int, float], angle: Union[int, float]) -> None

Description

align_metrology_modelalign_metrology_modelAlignMetrologyModelAlignMetrologyModelAlignMetrologyModelalign_metrology_model moves and rotates the whole metrology model MetrologyHandleMetrologyHandleMetrologyHandleMetrologyHandlemetrologyHandlemetrology_handle 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_modelapply_metrology_modelApplyMetrologyModelApplyMetrologyModelApplyMetrologyModelapply_metrology_model to perform the measurement. First the metrology model is rotated by AngleAngleAngleAngleangleangle, then the metrology model is translated by RowRowRowRowrowrow and ColumnColumnColumnColumncolumncolumn. The values of the alignment are overwritten by the next call of align_metrology_modelalign_metrology_modelAlignMetrologyModelAlignMetrologyModelAlignMetrologyModelalign_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 thresholdthresholdThresholdThresholdThresholdthreshold and smallest_rectangle2smallest_rectangle2SmallestRectangle2SmallestRectangle2SmallestRectangle2smallest_rectangle2 were used to obtain these parameter.

  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_paramset_metrology_model_paramSetMetrologyModelParamSetMetrologyModelParamSetMetrologyModelParamset_metrology_model_param. This step is only performed once when setting up the metrology model.

    Example:

    threshold(Image, Region, 0, 50)threshold(Image, Region, 0, 50)Threshold(Image, Region, 0, 50)Threshold(Image, Region, 0, 50)Threshold(Image, Region, 0, 50)threshold(Image, Region, 0, 50)

    smallest_rectangle2(Region, RowOrig, ColumnOrig, AngleOrig, Length1, Length2)smallest_rectangle2(Region, RowOrig, ColumnOrig, AngleOrig, Length1, Length2)SmallestRectangle2(Region, RowOrig, ColumnOrig, AngleOrig, Length1, Length2)SmallestRectangle2(Region, RowOrig, ColumnOrig, AngleOrig, Length1, Length2)SmallestRectangle2(Region, RowOrig, ColumnOrig, AngleOrig, Length1, Length2)smallest_rectangle2(Region, RowOrig, ColumnOrig, AngleOrig, Length1, Length2)

    set_metrology_model_param(MetrologyHandle, 'reference_system', [RowOrig, ColumnOrig, AngleOrig])set_metrology_model_param(MetrologyHandle, "reference_system", [RowOrig, ColumnOrig, AngleOrig])SetMetrologyModelParam(MetrologyHandle, "reference_system", [RowOrig, ColumnOrig, AngleOrig])SetMetrologyModelParam(MetrologyHandle, "reference_system", [RowOrig, ColumnOrig, AngleOrig])SetMetrologyModelParam(MetrologyHandle, "reference_system", [RowOrig, ColumnOrig, AngleOrig])set_metrology_model_param(MetrologyHandle, "reference_system", [RowOrig, ColumnOrig, AngleOrig])

  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:

    threshold(CurrentImage, Region, 0, 50)threshold(CurrentImage, Region, 0, 50)Threshold(CurrentImage, Region, 0, 50)Threshold(CurrentImage, Region, 0, 50)Threshold(CurrentImage, Region, 0, 50)threshold(CurrentImage, Region, 0, 50)

    smallest_rectangle2(Region, RowAlign, ColumnAlign, AngleAlign, Length1, Length2)smallest_rectangle2(Region, RowAlign, ColumnAlign, AngleAlign, Length1, Length2)SmallestRectangle2(Region, RowAlign, ColumnAlign, AngleAlign, Length1, Length2)SmallestRectangle2(Region, RowAlign, ColumnAlign, AngleAlign, Length1, Length2)SmallestRectangle2(Region, RowAlign, ColumnAlign, AngleAlign, Length1, Length2)smallest_rectangle2(Region, RowAlign, ColumnAlign, AngleAlign, Length1, Length2)

    align_metrology_model(MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)align_metrology_model(MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)AlignMetrologyModel(MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)AlignMetrologyModel(MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)AlignMetrologyModel(MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)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 (RowRowRowRowrowrow, ColumnColumnColumnColumncolumncolumn, AngleAngleAngleAngleangleangle) of find_shape_modelfind_shape_modelFindShapeModelFindShapeModelFindShapeModelfind_shape_model can be used directly in align_metrology_modelalign_metrology_modelAlignMetrologyModelAlignMetrologyModelAlignMetrologyModelalign_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_paramset_metrology_model_paramSetMetrologyModelParamSetMetrologyModelParamSetMetrologyModelParamset_metrology_model_param. This step is only performed once when setting up the metrology model.

    Example:

    create_shape_model(Image, 6, 0, rad(360), 'auto', 'auto', 'use_polarity', 'auto', 20, ShapeModelID)create_shape_model(Image, 6, 0, rad(360), "auto", "auto", "use_polarity", "auto", 20, ShapeModelID)CreateShapeModel(Image, 6, 0, rad(360), "auto", "auto", "use_polarity", "auto", 20, ShapeModelID)CreateShapeModel(Image, 6, 0, rad(360), "auto", "auto", "use_polarity", "auto", 20, ShapeModelID)CreateShapeModel(Image, 6, 0, rad(360), "auto", "auto", "use_polarity", "auto", 20, ShapeModelID)create_shape_model(Image, 6, 0, rad(360), "auto", "auto", "use_polarity", "auto", 20, ShapeModelID)

    area_center(Image, Area, RowOrig, ColumnOrig)area_center(Image, Area, RowOrig, ColumnOrig)AreaCenter(Image, Area, RowOrig, ColumnOrig)AreaCenter(Image, Area, RowOrig, ColumnOrig)AreaCenter(Image, Area, RowOrig, ColumnOrig)area_center(Image, Area, RowOrig, ColumnOrig)

    set_metrology_model_param(MetrologyHandle, 'reference_system', [RowOrig,ColumnOrig,0])set_metrology_model_param(MetrologyHandle, "reference_system", [RowOrig,ColumnOrig,0])SetMetrologyModelParam(MetrologyHandle, "reference_system", [RowOrig,ColumnOrig,0])SetMetrologyModelParam(MetrologyHandle, "reference_system", [RowOrig,ColumnOrig,0])SetMetrologyModelParam(MetrologyHandle, "reference_system", [RowOrig,ColumnOrig,0])set_metrology_model_param(MetrologyHandle, "reference_system", [RowOrig,ColumnOrig,0])

  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_modelalign_metrology_modelAlignMetrologyModelAlignMetrologyModelAlignMetrologyModelalign_metrology_model.

    Example:

    find_shape_model(CurrentImage, ShapeModelID, 0, rad(360), 0.5, 1, 0, 'least_squares', 5, 0.9, RowAlign, ColumnAlign, AngleAlign, Score)find_shape_model(CurrentImage, ShapeModelID, 0, rad(360), 0.5, 1, 0, "least_squares", 5, 0.9, RowAlign, ColumnAlign, AngleAlign, Score)FindShapeModel(CurrentImage, ShapeModelID, 0, rad(360), 0.5, 1, 0, "least_squares", 5, 0.9, RowAlign, ColumnAlign, AngleAlign, Score)FindShapeModel(CurrentImage, ShapeModelID, 0, rad(360), 0.5, 1, 0, "least_squares", 5, 0.9, RowAlign, ColumnAlign, AngleAlign, Score)FindShapeModel(CurrentImage, ShapeModelID, 0, rad(360), 0.5, 1, 0, "least_squares", 5, 0.9, RowAlign, ColumnAlign, AngleAlign, Score)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)align_metrology_model(MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)AlignMetrologyModel(MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)AlignMetrologyModel(MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)AlignMetrologyModel(MetrologyHandle, RowAlign, ColumnAlign, AngleAlign)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 (RowRowRowRowrowrow, ColumnColumnColumnColumncolumncolumn, AngleAngleAngleAngleangleangle) from corresponding points in the model image and one other image.

    Example:

    vector_to_rigid(PRowModel, PColumnModel, PRowCurrent, PColumnCurrent, HomMat2D)vector_to_rigid(PRowModel, PColumnModel, PRowCurrent, PColumnCurrent, HomMat2D)VectorToRigid(PRowModel, PColumnModel, PRowCurrent, PColumnCurrent, HomMat2D)VectorToRigid(PRowModel, PColumnModel, PRowCurrent, PColumnCurrent, HomMat2D)VectorToRigid(PRowModel, PColumnModel, PRowCurrent, PColumnCurrent, HomMat2D)vector_to_rigid(PRowModel, PColumnModel, PRowCurrent, PColumnCurrent, HomMat2D)

    hom_mat2d_to_affine_par(HomMat2D, Sx, Sy, Angle, Theta, Row, Column)hom_mat2d_to_affine_par(HomMat2D, Sx, Sy, Angle, Theta, Row, Column)HomMat2dToAffinePar(HomMat2D, Sx, Sy, Angle, Theta, Row, Column)HomMat2dToAffinePar(HomMat2D, Sx, Sy, Angle, Theta, Row, Column)HomMat2dToAffinePar(HomMat2D, Sx, Sy, Angle, Theta, Row, Column)hom_mat2d_to_affine_par(HomMat2D, Sx, Sy, Angle, Theta, Row, Column)

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

Execution Information

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

MetrologyHandleMetrologyHandleMetrologyHandleMetrologyHandlemetrologyHandlemetrology_handle (input_control, state is modified)  metrology_model HMetrologyModel, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the metrology model.

RowRowRowRowrowrow (input_control)  real HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Row coordinate of the alignment.

Default value: 0

ColumnColumnColumnColumncolumncolumn (input_control)  real HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Column coordinate of the alignment.

Default value: 0

AngleAngleAngleAngleangleangle (input_control)  angle.rad HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Rotation angle of the alignment.

Default value: 0

Example (HDevelop)

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)

Result

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

Possible Predecessors

set_metrology_model_paramset_metrology_model_paramSetMetrologyModelParamSetMetrologyModelParamSetMetrologyModelParamset_metrology_model_param, add_metrology_object_genericadd_metrology_object_genericAddMetrologyObjectGenericAddMetrologyObjectGenericAddMetrologyObjectGenericadd_metrology_object_generic

Possible Successors

apply_metrology_modelapply_metrology_modelApplyMetrologyModelApplyMetrologyModelApplyMetrologyModelapply_metrology_model

See also

get_metrology_object_model_contourget_metrology_object_model_contourGetMetrologyObjectModelContourGetMetrologyObjectModelContourGetMetrologyObjectModelContourget_metrology_object_model_contour

Module

2D Metrology