create_aniso_shape_model_xldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldCreateAnisoShapeModelXld — Prepare an anisotropically scaled shape model for matching
from XLD contours.
The operator create_aniso_shape_model_xldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldCreateAnisoShapeModelXld creates an anisotropically
scaled shape model used for matching from the XLD contours passed in
ContoursContoursContoursContoursContourscontours. The XLD contours represent the grayvalue edges of the
object to be searched for. In contrast to the operator
create_aniso_shape_modelcreate_aniso_shape_modelCreateAnisoShapeModelcreate_aniso_shape_modelCreateAnisoShapeModelCreateAnisoShapeModel, which creates a shape model from a
template image, the operator create_aniso_shape_model_xldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldCreateAnisoShapeModelXld creates
the shape model from XLD contours, i.e., without the use of a template
image.
The number of pyramid levels is determined with the parameter
NumLevelsNumLevelsNumLevelsNumLevelsNumLevelsnumLevels. It should be chosen as large as possible
because by this the time necessary to find the object is
significantly reduced. On the other hand, NumLevelsNumLevelsNumLevelsNumLevelsNumLevelsnumLevels must
be chosen such that the model is still recognizable and contains a
sufficient number of points (at least four) on the highest pyramid
level. If not enough model points are
generated, the number of pyramid levels is reduced internally until
enough model points are found on the highest pyramid level. If this
procedure would lead to a model with no pyramid levels, i.e., if the
number of model points is already too small on the lowest pyramid
level, create_aniso_shape_model_xldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldCreateAnisoShapeModelXld returns with an error
message. If NumLevelsNumLevelsNumLevelsNumLevelsNumLevelsnumLevels is set to 'auto'"auto""auto""auto""auto""auto",
create_aniso_shape_model_xldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldCreateAnisoShapeModelXld determines the number of pyramid
levels automatically. The computed number of pyramid
levels can be queried using get_shape_model_paramsget_shape_model_paramsGetShapeModelParamsget_shape_model_paramsGetShapeModelParamsGetShapeModelParams. In rare
cases, it might happen that create_aniso_shape_model_xldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldCreateAnisoShapeModelXld
determines a value for the number of pyramid levels that is too
large or too small. If the number of pyramid levels is chosen too
large, the model may not be recognized in the image or it may be
necessary to select very low parameters for MinScore or Greediness
in find_aniso_shape_modelfind_aniso_shape_modelFindAnisoShapeModelfind_aniso_shape_modelFindAnisoShapeModelFindAnisoShapeModel in order to find the model. If
the number of pyramid levels is chosen too small, the time required
to find the model in find_aniso_shape_modelfind_aniso_shape_modelFindAnisoShapeModelfind_aniso_shape_modelFindAnisoShapeModelFindAnisoShapeModel may increase.
In these cases, the number of pyramid levels should be selected manually.
Note that the transformations are treated internally such that the
scalings are applied first, followed by the rotation. Therefore,
the model should usually be aligned such that it appears
horizontally or vertically in the model image.
Optionally, a second value can be passed in OptimizationOptimizationOptimizationOptimizationOptimizationoptimization.
This value determines whether the model is pregenerated completely
or not. To do so, the second value of OptimizationOptimizationOptimizationOptimizationOptimizationoptimization must be
set to either 'pregeneration'"pregeneration""pregeneration""pregeneration""pregeneration""pregeneration" or
'no_pregeneration'"no_pregeneration""no_pregeneration""no_pregeneration""no_pregeneration""no_pregeneration". If the second value is not used (i.e.,
if only one value is passed), the mode that is set with
set_system('pregenerate_shape_models',...)set_system("pregenerate_shape_models",...)SetSystem("pregenerate_shape_models",...)set_system("pregenerate_shape_models",...)SetSystem("pregenerate_shape_models",...)SetSystem("pregenerate_shape_models",...) is used. With
the default value ('pregenerate_shape_models'"pregenerate_shape_models""pregenerate_shape_models""pregenerate_shape_models""pregenerate_shape_models""pregenerate_shape_models" =
'false'"false""false""false""false""false"), the model is not pregenerated completely. The
complete pregeneration of the model normally leads to slightly lower
runtimes because the model does not need to be transformed at
runtime. However, in this case, the memory requirements and the
time required to create the model are significantly higher. It
should also be noted that it cannot be expected that the two modes
return exactly identical results because transforming the model at
runtime necessarily leads to different internal data for the
transformed models than pregenerating the transformed models. For
example, if the model is not pregenerated completely,
find_aniso_shape_modelfind_aniso_shape_modelFindAnisoShapeModelfind_aniso_shape_modelFindAnisoShapeModelFindAnisoShapeModel typically returns slightly lower
scores, which may require setting a slightly lower value for
MinScore than for a completely pregenerated model. Furthermore, the
poses obtained by interpolation may differ slightly in the two
modes. If maximum accuracy is desired, the pose of the model should
be determined by least-squares adjustment.
The parameter MetricMetricMetricMetricMetricmetric determines the conditions under which
the model is recognized in the image. If MetricMetricMetricMetricMetricmetric =
'use_polarity'"use_polarity""use_polarity""use_polarity""use_polarity""use_polarity", the object in the image and the model must
have the same contrast. If, for example, the model is a bright
object on a dark background, the object is found only if it is also
brighter than the background. If MetricMetricMetricMetricMetricmetric =
'ignore_global_polarity'"ignore_global_polarity""ignore_global_polarity""ignore_global_polarity""ignore_global_polarity""ignore_global_polarity", the object is found in the image
also if the contrast reverses globally. In the above example, the
object hence is also found if it is darker than the background. The
runtime of find_aniso_shape_modelfind_aniso_shape_modelFindAnisoShapeModelfind_aniso_shape_modelFindAnisoShapeModelFindAnisoShapeModel will increase slightly in
this case. If MetricMetricMetricMetricMetricmetric = 'ignore_local_polarity'"ignore_local_polarity""ignore_local_polarity""ignore_local_polarity""ignore_local_polarity""ignore_local_polarity",
the model is found even if the contrast changes locally. This mode
can, for example, be useful if the object consists of a part with
medium gray value, within which either darker or brighter
sub-objects lie. Since in this case the runtime of
find_aniso_shape_modelfind_aniso_shape_modelFindAnisoShapeModelfind_aniso_shape_modelFindAnisoShapeModelFindAnisoShapeModel increases significantly, it is
usually better to create several models that reflect the possible
contrast variations of the object with
create_aniso_shape_model_xldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldCreateAnisoShapeModelXld, and to match them simultaneously
with find_aniso_shape_modelsfind_aniso_shape_modelsFindAnisoShapeModelsfind_aniso_shape_modelsFindAnisoShapeModelsFindAnisoShapeModels. The above three metrics can
only be applied to single-channel images. If a multichannel image
is used as the model image or as the search image only the first
channel will be used (and no error message will be returned). If
MetricMetricMetricMetricMetricmetric = 'ignore_color_polarity'"ignore_color_polarity""ignore_color_polarity""ignore_color_polarity""ignore_color_polarity""ignore_color_polarity", the model is
found even if the color contrast changes locally. This is, for
example, the case if parts of the object can change their color,
e.g., from red to green. In particular, this mode is useful if it
is not known in advance in which channels the object is visible. In
this mode, the runtime of find_aniso_shape_modelfind_aniso_shape_modelFindAnisoShapeModelfind_aniso_shape_modelFindAnisoShapeModelFindAnisoShapeModel can also
increase significantly. The metric 'ignore_color_polarity'"ignore_color_polarity""ignore_color_polarity""ignore_color_polarity""ignore_color_polarity""ignore_color_polarity"
can be used for images with an arbitrary number of channels. If it
is used for single-channel images it has the same effect as
'ignore_local_polarity'"ignore_local_polarity""ignore_local_polarity""ignore_local_polarity""ignore_local_polarity""ignore_local_polarity". It should be noted that for
MetricMetricMetricMetricMetricmetric = 'ignore_color_polarity'"ignore_color_polarity""ignore_color_polarity""ignore_color_polarity""ignore_color_polarity""ignore_color_polarity" the
channels do not need to contain a spectral
subdivision of the light (like in an RGB image). The channels can,
for example, also contain images of the same object that were
obtained by illuminating the object from different directions.
Note that the first two metrics ('use_polarity'"use_polarity""use_polarity""use_polarity""use_polarity""use_polarity" and
'ignore_global_polarity'"ignore_global_polarity""ignore_global_polarity""ignore_global_polarity""ignore_global_polarity""ignore_global_polarity") can only be selected if all
ContoursContoursContoursContoursContourscontours provide the attribute 'edge_direction'"edge_direction""edge_direction""edge_direction""edge_direction""edge_direction", which
defines the polarity of the edges. This attribute is available for contours
created, e.g., with edges_sub_pixedges_sub_pixEdgesSubPixedges_sub_pixEdgesSubPixEdgesSubPix with the parameter MethodMethodMethodMethodMethodmethod
set to, e.g., 'canny'"canny""canny""canny""canny""canny". Otherwise, these two metrics can be
selected with the operator set_shape_model_metricset_shape_model_metricSetShapeModelMetricset_shape_model_metricSetShapeModelMetricSetShapeModelMetric, which determines
the polarity of the edges from an image.
The XLD contours passed in ContoursContoursContoursContoursContourscontours should have been scaled
to approximately the average size of the object in the search images.
This means that the products and
should be
approximately equal to 1.
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
Multithreading scope: global (may be called from any thread).
Processed without parallelization.
This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.
List of values: 'auto'"auto""auto""auto""auto""auto", 'no_pregeneration'"no_pregeneration""no_pregeneration""no_pregeneration""no_pregeneration""no_pregeneration", 'none'"none""none""none""none""none", 'point_reduction_high'"point_reduction_high""point_reduction_high""point_reduction_high""point_reduction_high""point_reduction_high", 'point_reduction_low'"point_reduction_low""point_reduction_low""point_reduction_low""point_reduction_low""point_reduction_low", 'point_reduction_medium'"point_reduction_medium""point_reduction_medium""point_reduction_medium""point_reduction_medium""point_reduction_medium", 'pregeneration'"pregeneration""pregeneration""pregeneration""pregeneration""pregeneration"
List of values: 'ignore_color_polarity'"ignore_color_polarity""ignore_color_polarity""ignore_color_polarity""ignore_color_polarity""ignore_color_polarity", 'ignore_global_polarity'"ignore_global_polarity""ignore_global_polarity""ignore_global_polarity""ignore_global_polarity""ignore_global_polarity", 'ignore_local_polarity'"ignore_local_polarity""ignore_local_polarity""ignore_local_polarity""ignore_local_polarity""ignore_local_polarity", 'use_polarity'"use_polarity""use_polarity""use_polarity""use_polarity""use_polarity"
If the parameters are valid, the operator
create_aniso_shape_model_xldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldcreate_aniso_shape_model_xldCreateAnisoShapeModelXldCreateAnisoShapeModelXld returns the value 2 (H_MSG_TRUE). If necessary an
exception is raised. If the parameter NumLevelsNumLevelsNumLevelsNumLevelsNumLevelsnumLevels is chosen such that
the model contains too few points, the error 8510 is raised.