Skip to content

create_aniso_shape_model_xldCreateAnisoShapeModelXldCreateAnisoShapeModelXldcreate_aniso_shape_model_xldT_create_aniso_shape_model_xldπŸ”—

Short descriptionπŸ”—

create_aniso_shape_model_xldCreateAnisoShapeModelXldCreateAnisoShapeModelXldcreate_aniso_shape_model_xldT_create_aniso_shape_model_xld β€” Prepare an anisotropically scaled shape model for matching from XLD contours.

SignatureπŸ”—

create_aniso_shape_model_xld( xld_cont Contours, integer NumLevels, angle.rad AngleStart, angle.rad AngleExtent, angle.rad AngleStep, number ScaleRMin, number ScaleRMax, number ScaleRStep, number ScaleCMin, number ScaleCMax, number ScaleCStep, string Optimization, string Metric, number MinContrast, out shape_model ModelID )void CreateAnisoShapeModelXld( const HObject& Contours, const HTuple& NumLevels, const HTuple& AngleStart, const HTuple& AngleExtent, const HTuple& AngleStep, const HTuple& ScaleRMin, const HTuple& ScaleRMax, const HTuple& ScaleRStep, const HTuple& ScaleCMin, const HTuple& ScaleCMax, const HTuple& ScaleCStep, const HTuple& Optimization, const HTuple& Metric, const HTuple& MinContrast, HTuple* ModelID )static void HOperatorSet.CreateAnisoShapeModelXld( HObject contours, HTuple numLevels, HTuple angleStart, HTuple angleExtent, HTuple angleStep, HTuple scaleRMin, HTuple scaleRMax, HTuple scaleRStep, HTuple scaleCMin, HTuple scaleCMax, HTuple scaleCStep, HTuple optimization, HTuple metric, HTuple minContrast, out HTuple modelID )def create_aniso_shape_model_xld( contours: HObject, num_levels: Union[int, str], angle_start: float, angle_extent: float, angle_step: Union[float, str], scale_rmin: float, scale_rmax: float, scale_rstep: Union[float, str], scale_cmin: float, scale_cmax: float, scale_cstep: Union[float, str], optimization: MaybeSequence[str], metric: str, min_contrast: int ) -> HHandle

Herror T_create_aniso_shape_model_xld( const Hobject Contours, const Htuple NumLevels, const Htuple AngleStart, const Htuple AngleExtent, const Htuple AngleStep, const Htuple ScaleRMin, const Htuple ScaleRMax, const Htuple ScaleRStep, const Htuple ScaleCMin, const Htuple ScaleCMax, const Htuple ScaleCStep, const Htuple Optimization, const Htuple Metric, const Htuple MinContrast, Htuple* ModelID )

void HShapeModel::HShapeModel( const HXLDCont& Contours, const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, double ScaleRMin, double ScaleRMax, const HTuple& ScaleRStep, double ScaleCMin, double ScaleCMax, const HTuple& ScaleCStep, const HTuple& Optimization, const HString& Metric, Hlong MinContrast )

void HShapeModel::HShapeModel( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const HString& Optimization, const HString& Metric, Hlong MinContrast )

void HShapeModel::HShapeModel( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const char* Optimization, const char* Metric, Hlong MinContrast )

void HShapeModel::HShapeModel( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const wchar_t* Optimization, const wchar_t* Metric, Hlong MinContrast ) (Windows only)

public HShapeModel( HXLDCont contours, HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, double scaleRMin, double scaleRMax, HTuple scaleRStep, double scaleCMin, double scaleCMax, HTuple scaleCStep, HTuple optimization, string metric, int minContrast )

public HShapeModel( HXLDCont contours, int numLevels, double angleStart, double angleExtent, double angleStep, double scaleRMin, double scaleRMax, double scaleRStep, double scaleCMin, double scaleCMax, double scaleCStep, string optimization, string metric, int minContrast )

void HShapeModel::CreateAnisoShapeModelXld( const HXLDCont& Contours, const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, double ScaleRMin, double ScaleRMax, const HTuple& ScaleRStep, double ScaleCMin, double ScaleCMax, const HTuple& ScaleCStep, const HTuple& Optimization, const HString& Metric, Hlong MinContrast )

void HShapeModel::CreateAnisoShapeModelXld( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const HString& Optimization, const HString& Metric, Hlong MinContrast )

void HShapeModel::CreateAnisoShapeModelXld( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const char* Optimization, const char* Metric, Hlong MinContrast )

void HShapeModel::CreateAnisoShapeModelXld( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const wchar_t* Optimization, const wchar_t* Metric, Hlong MinContrast ) (Windows only)

HShapeModel HXLDCont::CreateAnisoShapeModelXld( const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, double ScaleRMin, double ScaleRMax, const HTuple& ScaleRStep, double ScaleCMin, double ScaleCMax, const HTuple& ScaleCStep, const HTuple& Optimization, const HString& Metric, Hlong MinContrast ) const

HShapeModel HXLDCont::CreateAnisoShapeModelXld( Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const HString& Optimization, const HString& Metric, Hlong MinContrast ) const

HShapeModel HXLDCont::CreateAnisoShapeModelXld( Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const char* Optimization, const char* Metric, Hlong MinContrast ) const

HShapeModel HXLDCont::CreateAnisoShapeModelXld( Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const wchar_t* Optimization, const wchar_t* Metric, Hlong MinContrast ) const (Windows only)

void HShapeModel.CreateAnisoShapeModelXld( HXLDCont contours, HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, double scaleRMin, double scaleRMax, HTuple scaleRStep, double scaleCMin, double scaleCMax, HTuple scaleCStep, HTuple optimization, string metric, int minContrast )

void HShapeModel.CreateAnisoShapeModelXld( HXLDCont contours, int numLevels, double angleStart, double angleExtent, double angleStep, double scaleRMin, double scaleRMax, double scaleRStep, double scaleCMin, double scaleCMax, double scaleCStep, string optimization, string metric, int minContrast )

HShapeModel HXLDCont.CreateAnisoShapeModelXld( HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, double scaleRMin, double scaleRMax, HTuple scaleRStep, double scaleCMin, double scaleCMax, HTuple scaleCStep, HTuple optimization, string metric, int minContrast )

HShapeModel HXLDCont.CreateAnisoShapeModelXld( int numLevels, double angleStart, double angleExtent, double angleStep, double scaleRMin, double scaleRMax, double scaleRStep, double scaleCMin, double scaleCMax, double scaleCStep, string optimization, string metric, int minContrast )

DescriptionπŸ”—

The operator create_aniso_shape_model_xldCreateAnisoShapeModelXld creates an anisotropically scaled shape model used for matching from the XLD contours passed in Contourscontourscontours. The XLD contours represent the gray value edges of the object to be searched for. In contrast to the operator create_aniso_shape_modelCreateAnisoShapeModel, which creates a shape model from a template image, the operator create_aniso_shape_model_xldCreateAnisoShapeModelXld creates the shape model from XLD contours, i.e., without the use of a template image.

The output parameter ModelIDmodelIDmodel_id is a handle for this model, which is used in subsequent calls to find_aniso_shape_modelFindAnisoShapeModel. The center of gravity of the smallest surrounding rectangle of the Contourscontourscontours that is parallel to the coordinate axes is used as the origin (reference point) of the model. A different origin can be set with set_shape_model_originSetShapeModelOrigin. The model is generated for multiple image pyramid levels and is stored in memory. If a complete pregeneration of the model is selected (see below), the model is generated at multiple rotations and anisotropic scales (i.e., independent scales in the row and column direction) on each level. The model can be extended by clutter parameters with set_shape_model_clutterSetShapeModelClutter.

Input parameters in detailπŸ”—

Complete pregeneration of the modelπŸ”—

Optionally, a second value can be passed in Optimizationoptimizationoptimization. This value determines whether the model is pregenerated completely or not. To do so, the second value of Optimizationoptimizationoptimization must be set to either 'pregeneration'"pregeneration" or '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',...) is used. With the default value ('pregenerate_shape_models'"pregenerate_shape_models" \(=\) '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_modelFindAnisoShapeModel typically returns slightly lower scores, which may require setting a slightly lower value for MinScoreminScoremin_score 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.

If a complete pregeneration of the model is selected, the model is pregenerated for the selected angle and scale range and stored in memory. The memory required to store the model is proportional to the number of angle steps, the number of scale steps, and the number of points in the model. Hence, if AngleStepangleStepangle_step, ScaleRStepscaleRStepscale_rstep, or ScaleCStepscaleCStepscale_cstep are too small or AngleExtentangleExtentangle_extent or the range of scales are too big, it may happen that the model no longer fits into the (virtual) memory. In this case, AngleStepangleStepangle_step, ScaleRStepscaleRStepscale_rstep, or ScaleCStepscaleCStepscale_cstep must be enlarged or AngleExtentangleExtentangle_extent or the range of scales must be reduced. In any case, it is desirable that the model completely fits into the main memory, because this avoids paging by the operating system, and hence the time to find the object will be much smaller. Since angles can be determined with subpixel resolution by find_aniso_shape_modelFindAnisoShapeModel, AngleStep >= 1Β° and ScaleRStep, ScaleCStep >= 0.02 can be selected for models of a diameter smaller than about 200 pixels.

If AngleStep = β€˜auto’ or ScaleRStep, ScaleCStep = β€˜auto’ is selected, create_aniso_shape_model_xldCreateAnisoShapeModelXld automatically determines a suitable angle or scale step length, respectively, based on the size of the model. The automatically computed angle and scale step lengths can be queried using get_shape_model_paramsGetShapeModelParams.

If a complete pregeneration of the model is not selected, the model is only created in a reference pose on each pyramid level. In this case, the model must be transformed to the different angles and scales at runtime in find_aniso_shape_modelFindAnisoShapeModel. Because of this, the recognition of the model might require slightly more time.

Note that pregenerated shape models are tailored to a specific image size. For runtime reasons using images of different sizes during the search with the same model in parallel is not supported. In this case, copies of the same model must be used, otherwise the program may crash!

AttentionπŸ”—

The XLD contours passed in Contourscontourscontours should have been scaled to approximately the average size of the object in the search images. This means that the products \(\textrm{ScaleRMin} \times \textrm{ScaleRMax}\) and \(\textrm{ScaleCMin} \times \textrm{ScaleCMax}\) should be approximately equal to 1.

Note that, in contrast to the operator create_aniso_shape_modelCreateAnisoShapeModel, it is not possible to specify a minimum size of the model components. To avoid small model components in the shape model, short contours can be eliminated before calling create_aniso_shape_model_xldCreateAnisoShapeModelXld with the operator select_contours_xldSelectContoursXld.

Execution informationπŸ”—

Execution information
  • 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.

ParametersπŸ”—

Contourscontourscontours (input_object) xld_cont(-array) β†’ objectHObjectHXLDContHObjectHobject

Input contours that will be used to create the model.

NumLevelsnumLevelsnum_levels (input_control) integer β†’ (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)Union[int, str]Htuple (Hlong / char*)

Maximum number of pyramid levels.

Default: 'auto'"auto"
List of values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'auto'1, 2, 3, 4, 5, 6, 7, 8, 9, 10, "auto"

AngleStartangleStartangle_start (input_control) angle.rad β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Smallest rotation of the pattern.

Default: -0.39-0.39
Suggested values: -3.14, -1.57, -0.79, -0.39, -0.20, 0.0-3.14, -1.57, -0.79, -0.39, -0.20, 0.0

AngleExtentangleExtentangle_extent (input_control) angle.rad β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Extent of the rotation angles.

Default: 0.790.79
Suggested values: 6.29, 3.14, 1.57, 0.79, 0.396.29, 3.14, 1.57, 0.79, 0.39
Restriction: AngleExtent >= 0

AngleStepangleStepangle_step (input_control) angle.rad β†’ (real / string)HTuple (double / HString)HTuple (double / string)Union[float, str]Htuple (double / char*)

Step length of the angles (resolution).

Default: 'auto'"auto"
Suggested values: 'auto', 0.0175, 0.0349, 0.0524, 0.0698, 0.0873"auto", 0.0175, 0.0349, 0.0524, 0.0698, 0.0873
Restriction: AngleStep >= 0 && AngleStep <= pi/2

ScaleRMinscaleRMinscale_rmin (input_control) number β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Minimum scale of the pattern in the row direction.

Default: 0.90.9
Suggested values: 0.5, 0.6, 0.7, 0.8, 0.9, 1.00.5, 0.6, 0.7, 0.8, 0.9, 1.0
Restriction: ScaleRMin > 0

ScaleRMaxscaleRMaxscale_rmax (input_control) number β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Maximum scale of the pattern in the row direction.

Default: 1.11.1
Suggested values: 1.0, 1.1, 1.2, 1.3, 1.4, 1.51.0, 1.1, 1.2, 1.3, 1.4, 1.5
Restriction: ScaleRMax >= ScaleRMin

ScaleRStepscaleRStepscale_rstep (input_control) number β†’ (real / string)HTuple (double / HString)HTuple (double / string)Union[float, str]Htuple (double / char*)

Scale step length (resolution) in the row direction.

Default: 'auto'"auto"
Suggested values: 'auto', 0.01, 0.02, 0.05, 0.1, 0.15, 0.2"auto", 0.01, 0.02, 0.05, 0.1, 0.15, 0.2
Restriction: ScaleRStep >= 0

ScaleCMinscaleCMinscale_cmin (input_control) number β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Minimum scale of the pattern in the column direction.

Default: 0.90.9
Suggested values: 0.5, 0.6, 0.7, 0.8, 0.9, 1.00.5, 0.6, 0.7, 0.8, 0.9, 1.0
Restriction: ScaleCMin > 0

ScaleCMaxscaleCMaxscale_cmax (input_control) number β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Maximum scale of the pattern in the column direction.

Default: 1.11.1
Suggested values: 1.0, 1.1, 1.2, 1.3, 1.4, 1.51.0, 1.1, 1.2, 1.3, 1.4, 1.5
Restriction: ScaleCMax >= ScaleCMin

ScaleCStepscaleCStepscale_cstep (input_control) number β†’ (real / string)HTuple (double / HString)HTuple (double / string)Union[float, str]Htuple (double / char*)

Scale step length (resolution) in the column direction.

Default: 'auto'"auto"
Suggested values: 'auto', 0.01, 0.02, 0.05, 0.1, 0.15, 0.2"auto", 0.01, 0.02, 0.05, 0.1, 0.15, 0.2
Restriction: ScaleCStep >= 0

Optimizationoptimizationoptimization (input_control) string(-array) β†’ (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Kind of optimization and optionally method used for generating the model.

Default: 'auto'"auto"
List of values: 'auto', 'no_pregeneration', 'none', 'point_reduction_high', 'point_reduction_low', 'point_reduction_medium', 'pregeneration'"auto", "no_pregeneration", "none", "point_reduction_high", "point_reduction_low", "point_reduction_medium", "pregeneration"

Metricmetricmetric (input_control) string β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Match metric.

Default: 'ignore_local_polarity'"ignore_local_polarity"
List of values: 'ignore_color_polarity', 'ignore_global_polarity', 'ignore_local_polarity', 'use_polarity'"ignore_color_polarity", "ignore_global_polarity", "ignore_local_polarity", "use_polarity"

MinContrastminContrastmin_contrast (input_control) number β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Minimum contrast of the objects in the search images.

Default: 55
Suggested values: 1, 2, 3, 5, 7, 10, 20, 30, 401, 2, 3, 5, 7, 10, 20, 30, 40

ModelIDmodelIDmodel_id (output_control) shape_model β†’ (handle)HTuple (HHandle)HShapeModel, HTuple (IntPtr)HHandleHtuple (handle)

Handle of the model.

ResultπŸ”—

If the parameters are valid, the operator create_aniso_shape_model_xldCreateAnisoShapeModelXld returns the value 2 (H_MSG_TRUE). If necessary an exception is raised. If the parameter NumLevelsnumLevelsnum_levels is chosen such that the model contains too few points, the error 8510 is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

read_contour_xld_dxfReadContourXldDxf, edges_sub_pixEdgesSubPix, select_contours_xldSelectContoursXld

Possible successors

find_aniso_shape_modelFindAnisoShapeModel, find_aniso_shape_modelsFindAnisoShapeModels, get_shape_model_paramsGetShapeModelParams, clear_shape_modelClearShapeModel, write_shape_modelWriteShapeModel, set_shape_model_originSetShapeModelOrigin, set_shape_model_paramSetShapeModelParam, set_shape_model_metricSetShapeModelMetric, set_shape_model_clutterSetShapeModelClutter

Alternatives

create_generic_shape_modelCreateGenericShapeModel

See also

set_systemSetSystem, get_systemGetSystem

ModuleπŸ”—

Matching