Skip to content

create_shape_model_xldCreateShapeModelXldCreateShapeModelXldcreate_shape_model_xldT_create_shape_model_xldπŸ”—

Short descriptionπŸ”—

create_shape_model_xldCreateShapeModelXldCreateShapeModelXldcreate_shape_model_xldT_create_shape_model_xld β€” Prepare a shape model for matching from XLD contours.

SignatureπŸ”—

create_shape_model_xld( xld_cont Contours, integer NumLevels, angle.rad AngleStart, angle.rad AngleExtent, angle.rad AngleStep, string Optimization, string Metric, number MinContrast, out shape_model ModelID )void CreateShapeModelXld( const HObject& Contours, const HTuple& NumLevels, const HTuple& AngleStart, const HTuple& AngleExtent, const HTuple& AngleStep, const HTuple& Optimization, const HTuple& Metric, const HTuple& MinContrast, HTuple* ModelID )static void HOperatorSet.CreateShapeModelXld( HObject contours, HTuple numLevels, HTuple angleStart, HTuple angleExtent, HTuple angleStep, HTuple optimization, HTuple metric, HTuple minContrast, out HTuple modelID )def create_shape_model_xld( contours: HObject, num_levels: Union[int, str], angle_start: float, angle_extent: float, angle_step: Union[float, str], optimization: MaybeSequence[str], metric: str, min_contrast: int ) -> HHandle

Herror T_create_shape_model_xld( const Hobject Contours, const Htuple NumLevels, const Htuple AngleStart, const Htuple AngleExtent, const Htuple AngleStep, 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, const HTuple& Optimization, const HString& Metric, Hlong MinContrast )

void HShapeModel::HShapeModel( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const HString& Optimization, const HString& Metric, Hlong MinContrast )

void HShapeModel::HShapeModel( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const char* Optimization, const char* Metric, Hlong MinContrast )

void HShapeModel::HShapeModel( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const wchar_t* Optimization, const wchar_t* Metric, Hlong MinContrast ) (Windows only)

public HShapeModel( HXLDCont contours, HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, HTuple optimization, string metric, int minContrast )

public HShapeModel( HXLDCont contours, int numLevels, double angleStart, double angleExtent, double angleStep, string optimization, string metric, int minContrast )

void HShapeModel::CreateShapeModelXld( const HXLDCont& Contours, const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, const HTuple& Optimization, const HString& Metric, Hlong MinContrast )

void HShapeModel::CreateShapeModelXld( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const HString& Optimization, const HString& Metric, Hlong MinContrast )

void HShapeModel::CreateShapeModelXld( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const char* Optimization, const char* Metric, Hlong MinContrast )

void HShapeModel::CreateShapeModelXld( const HXLDCont& Contours, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const wchar_t* Optimization, const wchar_t* Metric, Hlong MinContrast ) (Windows only)

HShapeModel HXLDCont::CreateShapeModelXld( const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, const HTuple& Optimization, const HString& Metric, Hlong MinContrast ) const

HShapeModel HXLDCont::CreateShapeModelXld( Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const HString& Optimization, const HString& Metric, Hlong MinContrast ) const

HShapeModel HXLDCont::CreateShapeModelXld( Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const char* Optimization, const char* Metric, Hlong MinContrast ) const

HShapeModel HXLDCont::CreateShapeModelXld( Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const wchar_t* Optimization, const wchar_t* Metric, Hlong MinContrast ) const (Windows only)

void HShapeModel.CreateShapeModelXld( HXLDCont contours, HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, HTuple optimization, string metric, int minContrast )

void HShapeModel.CreateShapeModelXld( HXLDCont contours, int numLevels, double angleStart, double angleExtent, double angleStep, string optimization, string metric, int minContrast )

HShapeModel HXLDCont.CreateShapeModelXld( HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, HTuple optimization, string metric, int minContrast )

HShapeModel HXLDCont.CreateShapeModelXld( int numLevels, double angleStart, double angleExtent, double angleStep, string optimization, string metric, int minContrast )

DescriptionπŸ”—

The operator create_shape_model_xldCreateShapeModelXld creates a 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_shape_modelCreateShapeModel, which creates a shape model from a template image, the operator create_shape_model_xldCreateShapeModelXld 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_shape_modelFindShapeModel. 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 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_shape_modelFindShapeModel 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 range and stored in memory. The memory required to store the model is proportional to the number of angle steps and the number of points in the model. Hence, if AngleStepangleStepangle_step is too small or AngleExtentangleExtentangle_extent too big, it may happen that the model no longer fits into the (virtual) memory. In this case, either AngleStepangleStepangle_step must be enlarged or AngleExtentangleExtentangle_extent 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_shape_modelFindShapeModel, AngleStep >= 1 can be selected for models of a diameter smaller than about 200 pixels.

If AngleStep = β€˜auto’ is selected, create_shape_model_xldCreateShapeModelXld automatically determines a suitable angle step length based on the size of the model. The automatically computed angle step length 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_shape_modelFindShapeModel. 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πŸ”—

Note that, in contrast to the operator create_shape_modelCreateShapeModel, 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_shape_model_xldCreateShapeModelXld 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

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_shape_model_xldCreateShapeModelXld 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_shape_modelFindShapeModel, find_shape_modelsFindShapeModels, 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