affine_trans_polygon_xld — Apply an arbitrary affine transformation to XLD polygons.
affine_trans_polygon_xld applies an arbitrary affine transformation,
i.e., scaling, rotation, translation, and slant (skewing), to the XLD
polygons given in
Polygons and returns the transformed polygons in
PolygonsAffineTrans. The affine transformation is described by the
homogeneous transformation matrix given in
HomMat2D. This matrix can
be created using the operators
hom_mat2d_translate, etc., or be the result of operators like
The components of the homogeneous transformation matrix are interpreted as follows: The row coordinate of the image corresponds to x and the column coordinate corresponds to y of the coordinate system in which the transformation matrix was defined. This is necessary to obtain a right-handed coordinate system for the image. In particular, this assures that rotations are performed in the correct direction. Note that the (x,y) order of the matrices quite naturally corresponds to the usual (row,column) order for coordinates in the image.
The XLD contours that are possibly referenced by
are neither transformed nor stored with the output polygons, since
this is generally impossible without creating inconsistencies for
the attributes of the XLD contours. Hence, operators that access
the contours associated with a polygon, e.g.,
split_contours_xld will not work correctly.
affine_trans_polygon_xld does not use the HALCON standard
coordinate system (with the origin in the center of the upper left
pixel), but instead uses the same coordinate system as in
affine_trans_pixel, i.e., the origin lies in the upper
left corner of the upper left pixel. Therefore,
affine_trans_polygon_xld corresponds to
a chain of transformations (see
affine_trans_pixel), which is
applied to each point of the polygon (input and output pixels as homogeneous
As an effect, you might get unexpected results when creating affine
transformations based on coordinates that are derived from the
polygon, e.g., by operators like
area_center_xld. For example, if you use this operator to calculate
the center of gravity of a rotationally symmetric XLD polygon and then
rotate the polygon around this point using
resulting polygon will not lie on the original one. In such a case, you can
compensate this effect by applying the following translations to
HomMat2D before using it in
For an explanation of the different 2D coordinate systems used in HALCON, see the introduction of chapter Transformations / 2D Transformations.
Input XLD polygons.
Transformed XLD polygons.
Input transformation matrix.
If the matrix
HomMat2D represents an affine transformation
(i.e., not a projective transformation),
affine_trans_polygon_xld returns 2 (H_MSG_TRUE). If the input is
empty the behavior can be set via
set_system(::'no_object_result',<Result>:). If necessary,
an exception is raised.