determine_shape_model_paramsT_determine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params (算子)
名称
determine_shape_model_paramsT_determine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params — 确定形状模型的参数。
签名
determine_shape_model_params(Template : : NumLevels, AngleStart, AngleExtent, ScaleMin, ScaleMax, Optimization, Metric, Contrast, MinContrast, Parameters : ParameterName, ParameterValue)
Herror T_determine_shape_model_params(const Hobject Template, const Htuple NumLevels, const Htuple AngleStart, const Htuple AngleExtent, const Htuple ScaleMin, const Htuple ScaleMax, const Htuple Optimization, const Htuple Metric, const Htuple Contrast, const Htuple MinContrast, const Htuple Parameters, Htuple* ParameterName, Htuple* ParameterValue)
void DetermineShapeModelParams(const HObject& Template, const HTuple& NumLevels, const HTuple& AngleStart, const HTuple& AngleExtent, const HTuple& ScaleMin, const HTuple& ScaleMax, const HTuple& Optimization, const HTuple& Metric, const HTuple& Contrast, const HTuple& MinContrast, const HTuple& Parameters, HTuple* ParameterName, HTuple* ParameterValue)
HTuple HImage::DetermineShapeModelParams(const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& ScaleMin, const HTuple& ScaleMax, const HString& Optimization, const HString& Metric, const HTuple& Contrast, const HTuple& MinContrast, const HTuple& Parameters, HTuple* ParameterValue) const
HTuple HImage::DetermineShapeModelParams(Hlong NumLevels, double AngleStart, double AngleExtent, double ScaleMin, double ScaleMax, const HString& Optimization, const HString& Metric, Hlong Contrast, Hlong MinContrast, const HString& Parameters, HTuple* ParameterValue) const
HTuple HImage::DetermineShapeModelParams(Hlong NumLevels, double AngleStart, double AngleExtent, double ScaleMin, double ScaleMax, const char* Optimization, const char* Metric, Hlong Contrast, Hlong MinContrast, const char* Parameters, HTuple* ParameterValue) const
HTuple HImage::DetermineShapeModelParams(Hlong NumLevels, double AngleStart, double AngleExtent, double ScaleMin, double ScaleMax, const wchar_t* Optimization, const wchar_t* Metric, Hlong Contrast, Hlong MinContrast, const wchar_t* Parameters, HTuple* ParameterValue) const
(
Windows only)
static void HOperatorSet.DetermineShapeModelParams(HObject template, HTuple numLevels, HTuple angleStart, HTuple angleExtent, HTuple scaleMin, HTuple scaleMax, HTuple optimization, HTuple metric, HTuple contrast, HTuple minContrast, HTuple parameters, out HTuple parameterName, out HTuple parameterValue)
HTuple HImage.DetermineShapeModelParams(HTuple numLevels, double angleStart, double angleExtent, HTuple scaleMin, HTuple scaleMax, string optimization, string metric, HTuple contrast, HTuple minContrast, HTuple parameters, out HTuple parameterValue)
HTuple HImage.DetermineShapeModelParams(int numLevels, double angleStart, double angleExtent, double scaleMin, double scaleMax, string optimization, string metric, int contrast, int minContrast, string parameters, out HTuple parameterValue)
def determine_shape_model_params(template: HObject, num_levels: Union[int, str], angle_start: float, angle_extent: float, scale_min: MaybeSequence[float], scale_max: MaybeSequence[float], optimization: str, metric: str, contrast: MaybeSequence[Union[int, str]], min_contrast: Union[int, str], parameters: MaybeSequence[str]) -> Tuple[Sequence[str], Sequence[Union[int, float]]]
描述
determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params determines certain parameters
of a shape model automatically from the model image
TemplateTemplateTemplateTemplatetemplatetemplate. The parameters to be determined can be specified
with ParametersParametersParametersParametersparametersparameters. determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params can
be used to determine the same parameters that are determined
automatically when the respective parameter in
create_shape_modelcreate_shape_modelCreateShapeModelCreateShapeModelCreateShapeModelcreate_shape_model, create_scaled_shape_modelcreate_scaled_shape_modelCreateScaledShapeModelCreateScaledShapeModelCreateScaledShapeModelcreate_scaled_shape_model, or
create_aniso_shape_modelcreate_aniso_shape_modelCreateAnisoShapeModelCreateAnisoShapeModelCreateAnisoShapeModelcreate_aniso_shape_model is set to 'auto'"auto""auto""auto""auto""auto":the
number of pyramid levels (ParametersParametersParametersParametersparametersparameters =
'num_levels'"num_levels""num_levels""num_levels""num_levels""num_levels"), the angle step length (ParametersParametersParametersParametersparametersparameters
= 'angle_step'"angle_step""angle_step""angle_step""angle_step""angle_step"), the scale step length
(ParametersParametersParametersParametersparametersparameters = 'scale_step'"scale_step""scale_step""scale_step""scale_step""scale_step" for isotropic scaling
and 'scale_r_step'"scale_r_step""scale_r_step""scale_r_step""scale_r_step""scale_r_step" and/or 'scale_c_step'"scale_c_step""scale_c_step""scale_c_step""scale_c_step""scale_c_step" for
anisotropic scaling), the kind of optimization (ParametersParametersParametersParametersparametersparameters
= 'optimization'"optimization""optimization""optimization""optimization""optimization"), the threshold (ParametersParametersParametersParametersparametersparameters =
'contrast'"contrast""contrast""contrast""contrast""contrast") or the hysteresis thresholds
(ParametersParametersParametersParametersparametersparameters = 'contrast_hyst'"contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst") for the contrast,
the minimum size of the object parts (ParametersParametersParametersParametersparametersparameters =
'min_size'"min_size""min_size""min_size""min_size""min_size"), and the minimum contrast (ParametersParametersParametersParametersparametersparameters
= 'min_contrast'"min_contrast""min_contrast""min_contrast""min_contrast""min_contrast"). By passing a tuple of the above
values in ParametersParametersParametersParametersparametersparameters, an arbitrary combination of these
parameters can be determined. If all of the above parameters should
be determined, the value 'all'"all""all""all""all""all" can be passed. In this case
both hysteresis thresholds are determined, i.e., the operator
behaves like passing 'contrast_hyst'"contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst" instead of
'contrast'"contrast""contrast""contrast""contrast""contrast".
determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params is mainly useful to determine
the above parameters before creating the model, e.g., in an
interactive system, which makes suggestions for these parameters to
the user, but enables the user to modify the suggested values.
The automatically determined parameters are returned as a name-value
pair in ParameterNameParameterNameParameterNameParameterNameparameterNameparameter_name and ParameterValueParameterValueParameterValueParameterValueparameterValueparameter_value. The
parameter names in ParameterNameParameterNameParameterNameParameterNameparameterNameparameter_name are identical to the names
in ParametersParametersParametersParametersparametersparameters, where, of course, the value 'all'"all""all""all""all""all"
is replaced by the actual parameter names. An exception is the
parameter 'contrast_hyst'"contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst", for which the two values
'contrast_low'"contrast_low""contrast_low""contrast_low""contrast_low""contrast_low" and 'contrast_high'"contrast_high""contrast_high""contrast_high""contrast_high""contrast_high" are returned.
The remaining parameters (NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels, AngleStartAngleStartAngleStartAngleStartangleStartangle_start,
AngleExtentAngleExtentAngleExtentAngleExtentangleExtentangle_extent, ScaleMinScaleMinScaleMinScaleMinscaleMinscale_min, ScaleMaxScaleMaxScaleMaxScaleMaxscaleMaxscale_max,
OptimizationOptimizationOptimizationOptimizationoptimizationoptimization, MetricMetricMetricMetricmetricmetric, ContrastContrastContrastContrastcontrastcontrast, and
MinContrastMinContrastMinContrastMinContrastminContrastmin_contrast) have the same meaning as in
create_shape_modelcreate_shape_modelCreateShapeModelCreateShapeModelCreateShapeModelcreate_shape_model, create_scaled_shape_modelcreate_scaled_shape_modelCreateScaledShapeModelCreateScaledShapeModelCreateScaledShapeModelcreate_scaled_shape_model, and
create_aniso_shape_modelcreate_aniso_shape_modelCreateAnisoShapeModelCreateAnisoShapeModelCreateAnisoShapeModelcreate_aniso_shape_model。The description of these
parameters can be looked up with these operators. These parameters
are used by determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params to calculate the
parameters to be determined in the same manner as in
create_shape_modelcreate_shape_modelCreateShapeModelCreateShapeModelCreateShapeModelcreate_shape_model, create_scaled_shape_modelcreate_scaled_shape_modelCreateScaledShapeModelCreateScaledShapeModelCreateScaledShapeModelcreate_scaled_shape_model, and
create_aniso_shape_modelcreate_aniso_shape_modelCreateAnisoShapeModelCreateAnisoShapeModelCreateAnisoShapeModelcreate_aniso_shape_model。It should be noted that if the
parameters of a shape model with isotropic scaling should be
determined, i.e., if ParametersParametersParametersParametersparametersparameters contains
'scale_step'"scale_step""scale_step""scale_step""scale_step""scale_step" either explicitly or implicitly via
'all'"all""all""all""all""all", the parameters ScaleMinScaleMinScaleMinScaleMinscaleMinscale_min and
ScaleMaxScaleMaxScaleMaxScaleMaxscaleMaxscale_max must contain one value each. If the parameters of
a shape model with anisotropic scaling should be determined, i.e.,
if ParametersParametersParametersParametersparametersparameters contains 'scale_r_step'"scale_r_step""scale_r_step""scale_r_step""scale_r_step""scale_r_step" or
'scale_c_step'"scale_c_step""scale_c_step""scale_c_step""scale_c_step""scale_c_step" either explicitly or implicitly, the
parameters ScaleMinScaleMinScaleMinScaleMinscaleMinscale_min and ScaleMaxScaleMaxScaleMaxScaleMaxscaleMaxscale_max must contain two
values each. In this case, the first value of the respective
parameter refers to the scaling in the row direction, while the
second value refers to the scaling in the column direction.
Note that in determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params some parameters
appear that can also be determined automatically
(NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels, OptimizationOptimizationOptimizationOptimizationoptimizationoptimization, ContrastContrastContrastContrastcontrastcontrast,
MinContrastMinContrastMinContrastMinContrastminContrastmin_contrast). If these parameters should not be determined
automatically, i.e., their name is not passed in
ParametersParametersParametersParametersparametersparameters, the corresponding parameters must contain
valid values and must not be set to 'auto'"auto""auto""auto""auto""auto". In contrast, if
these parameters are to be determined automatically, their values
are treated in the following way: If the optimization or the
(hysteresis) contrast is to be determined automatically, i.e.,
ParametersParametersParametersParametersparametersparameters contains the value 'optimization'"optimization""optimization""optimization""optimization""optimization" or
'contrast'"contrast""contrast""contrast""contrast""contrast" ('contrast_hyst'"contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst"), the values passed in
OptimizationOptimizationOptimizationOptimizationoptimizationoptimization and ContrastContrastContrastContrastcontrastcontrast are ignored. In
contrast, if the maximum number of pyramid levels or the minimum
contrast is to be determined automatically, i.e.,
ParametersParametersParametersParametersparametersparameters contains the value 'num_levels'"num_levels""num_levels""num_levels""num_levels""num_levels" or
'min_contrast'"min_contrast""min_contrast""min_contrast""min_contrast""min_contrast", you can let HALCON determine suitable
values and at the same time specify an upper or lower boundary,
respectively:
If the maximum number of pyramid levels should be specified in
advance, NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels can be set to the particular value. If
in this case ParametersParametersParametersParametersparametersparameters contains the value
'num_levels'"num_levels""num_levels""num_levels""num_levels""num_levels", the computed number of pyramid levels is at
most NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels. If NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels is set to
'auto'"auto""auto""auto""auto""auto" (or 0 for backwards compatibility), the
number of pyramid levels is determined without restrictions as large
as possible.
If the minimum contrast should be specified in advance,
MinContrastMinContrastMinContrastMinContrastminContrastmin_contrast can be set to the particular value. If in this
case ParametersParametersParametersParametersparametersparameters contains the value 'min_contrast'"min_contrast""min_contrast""min_contrast""min_contrast""min_contrast",
the computed minimum contrast is at least MinContrastMinContrastMinContrastMinContrastminContrastmin_contrast. If
MinContrastMinContrastMinContrastMinContrastminContrastmin_contrast is set to 'auto'"auto""auto""auto""auto""auto", the minimum contrast
is determined without restrictions.
注意
In some cases, the maximum number of pyramid levels that is returned by
determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params is higher than the number of levels
that are actually used in the shape model. The latter
can be queried by using get_shape_model_paramsget_shape_model_paramsGetShapeModelParamsGetShapeModelParamsGetShapeModelParamsget_shape_model_params after creating
the model. This might happen if the model is created by using
create_scaled_shape_modelcreate_scaled_shape_modelCreateScaledShapeModelCreateScaledShapeModelCreateScaledShapeModelcreate_scaled_shape_model or create_aniso_shape_modelcreate_aniso_shape_modelCreateAnisoShapeModelCreateAnisoShapeModelCreateAnisoShapeModelcreate_aniso_shape_model
and ScaleMin, ScaleRMin, or ScaleCMin is below 1.0.
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
参数
TemplateTemplateTemplateTemplatetemplatetemplate (输入对象) (multichannel-)image → objectHImageHObjectHImageHobject (byte / uint2)
Input image whose domain will be used to create
the model.
NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels (输入控制) integer → HTupleUnion[int, str]HTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)
Maximum number of pyramid levels.
默认值:
'auto'
"auto"
"auto"
"auto"
"auto"
"auto"
值列表:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'auto'"auto""auto""auto""auto""auto"
AngleStartAngleStartAngleStartAngleStartangleStartangle_start (输入控制) angle.rad → HTuplefloatHTupleHtuple (real) (double) (double) (double)
Smallest rotation of the model.
默认值:
-0.39
建议值:
-3.14, -1.57, -0.79, -0.39, -0.20, 0.0
AngleExtentAngleExtentAngleExtentAngleExtentangleExtentangle_extent (输入控制) angle.rad → HTuplefloatHTupleHtuple (real) (double) (double) (double)
Extent of the rotation angles.
默认值:
0.79
建议值:
6.29, 3.14, 1.57, 0.79, 0.39
限制:
AngleExtent >= 0
ScaleMinScaleMinScaleMinScaleMinscaleMinscale_min (输入控制) number(-array) → HTupleMaybeSequence[float]HTupleHtuple (real) (double) (double) (double)
Minimum scale of the model.
默认值:
0.9
建议值:
0.5, 0.6, 0.7, 0.8, 0.9, 1.0
限制:
ScaleMin > 0
ScaleMaxScaleMaxScaleMaxScaleMaxscaleMaxscale_max (输入控制) number(-array) → HTupleMaybeSequence[float]HTupleHtuple (real) (double) (double) (double)
Maximum scale of the model.
默认值:
1.1
建议值:
1.0, 1.1, 1.2, 1.3, 1.4, 1.5
限制:
ScaleMax >= ScaleMin
OptimizationOptimizationOptimizationOptimizationoptimizationoptimization (输入控制) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
Kind of optimization.
默认值:
'auto'
"auto"
"auto"
"auto"
"auto"
"auto"
值列表:
'auto'"auto""auto""auto""auto""auto", '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"
MetricMetricMetricMetricmetricmetric (输入控制) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
Match metric.
默认值:
'use_polarity'
"use_polarity"
"use_polarity"
"use_polarity"
"use_polarity"
"use_polarity"
值列表:
'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"
ContrastContrastContrastContrastcontrastcontrast (输入控制) number(-array) → HTupleMaybeSequence[Union[int, str]]HTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)
Threshold or hysteresis thresholds for the contrast
of the object in the template image and optionally
minimum size of the object parts.
默认值:
'auto'
"auto"
"auto"
"auto"
"auto"
"auto"
建议值:
'auto'"auto""auto""auto""auto""auto", 'auto_contrast'"auto_contrast""auto_contrast""auto_contrast""auto_contrast""auto_contrast", 'auto_contrast_hyst'"auto_contrast_hyst""auto_contrast_hyst""auto_contrast_hyst""auto_contrast_hyst""auto_contrast_hyst", 'auto_min_size'"auto_min_size""auto_min_size""auto_min_size""auto_min_size""auto_min_size", 10, 20, 30, 40, 60, 80, 100, 120, 140, 160
MinContrastMinContrastMinContrastMinContrastminContrastmin_contrast (输入控制) integer → HTupleUnion[int, str]HTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)
Minimum contrast of the objects in the search images.
默认值:
'auto'
"auto"
"auto"
"auto"
"auto"
"auto"
建议值:
'auto'"auto""auto""auto""auto""auto", 1, 2, 3, 5, 7, 10, 20, 30, 40
限制:
MinContrast < Contrast
ParametersParametersParametersParametersparametersparameters (输入控制) string(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Parameters to be determined automatically.
默认值:
'all'
"all"
"all"
"all"
"all"
"all"
值列表:
'all'"all""all""all""all""all", 'angle_step'"angle_step""angle_step""angle_step""angle_step""angle_step", 'contrast'"contrast""contrast""contrast""contrast""contrast", 'contrast_hyst'"contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst", 'min_contrast'"min_contrast""min_contrast""min_contrast""min_contrast""min_contrast", 'min_size'"min_size""min_size""min_size""min_size""min_size", 'num_levels'"num_levels""num_levels""num_levels""num_levels""num_levels", 'optimization'"optimization""optimization""optimization""optimization""optimization", 'scale_c_step'"scale_c_step""scale_c_step""scale_c_step""scale_c_step""scale_c_step", 'scale_r_step'"scale_r_step""scale_r_step""scale_r_step""scale_r_step""scale_r_step", 'scale_step'"scale_step""scale_step""scale_step""scale_step""scale_step"
ParameterNameParameterNameParameterNameParameterNameparameterNameparameter_name (输出控制) string-array → HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Name of the automatically determined parameter.
ParameterValueParameterValueParameterValueParameterValueparameterValueparameter_value (输出控制) number-array → HTupleSequence[Union[int, float]]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)
Value of the automatically determined parameter.
结果
如果参数有效,算子
determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params 返回值 2 ( H_MSG_TRUE )。如有必要,则抛出异常。 If the parameters
NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels and ContrastContrastContrastContrastcontrastcontrast are chosen such that the
model contains too few points, or the input image does not contain a
sufficient number of significant features, the error 8510 is
raised.
可能的前趋
draw_regiondraw_regionDrawRegionDrawRegionDrawRegiondraw_region,
reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain,
thresholdthresholdThresholdThresholdThresholdthreshold
可能的后继
create_generic_shape_modelcreate_generic_shape_modelCreateGenericShapeModelCreateGenericShapeModelCreateGenericShapeModelcreate_generic_shape_model
模块
匹配