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 可根据模型图像
TemplateTemplateTemplateTemplatetemplatetemplate 自动确定形状模型的某些参数。待确定的参数可通过 ParametersParametersParametersParametersparametersparameters 进行指定。determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params 可用于确定与在
create_shape_modelcreate_shape_modelCreateShapeModelCreateShapeModelCreateShapeModelcreate_shape_model、create_scaled_shape_modelcreate_scaled_shape_modelCreateScaledShapeModelCreateScaledShapeModelCreateScaledShapeModelcreate_scaled_shape_model 或 create_aniso_shape_modelcreate_aniso_shape_modelCreateAnisoShapeModelCreateAnisoShapeModelCreateAnisoShapeModelcreate_aniso_shape_model 中将相应参数设置为 'auto'"auto""auto""auto""auto""auto" 时自动确定的参数相同的参数:金字塔层数(ParametersParametersParametersParametersparametersparameters =
'num_levels'"num_levels""num_levels""num_levels""num_levels""num_levels")、角度步长(ParametersParametersParametersParametersparametersparameters
= 'angle_step'"angle_step""angle_step""angle_step""angle_step""angle_step")、 缩放步长(各向同性缩放时ParametersParametersParametersParametersparametersparameters = 'scale_step'"scale_step""scale_step""scale_step""scale_step""scale_step",各向异性缩放时 'scale_r_step'"scale_r_step""scale_r_step""scale_r_step""scale_r_step""scale_r_step" 和/或 'scale_c_step'"scale_c_step""scale_c_step""scale_c_step""scale_c_step""scale_c_step"),优化类型(ParametersParametersParametersParametersparametersparameters
= 'optimization'"optimization""optimization""optimization""optimization""optimization"), 对比度的阈值(ParametersParametersParametersParametersparametersparameters =
'contrast'"contrast""contrast""contrast""contrast""contrast")或滞后阈值(ParametersParametersParametersParametersparametersparameters = 'contrast_hyst'"contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst")、对象部分的最小尺寸(ParametersParametersParametersParametersparametersparameters =
'min_size'"min_size""min_size""min_size""min_size""min_size")以及最小对比度(ParametersParametersParametersParametersparametersparameters
= 'min_contrast'"min_contrast""min_contrast""min_contrast""min_contrast""min_contrast")。通过在 ParametersParametersParametersParametersparametersparameters 中传递上述值的元组,可以确定这些参数的任意组合。若需同时确定上述所有参数,可传入值 'all'"all""all""all""all""all"。此时将同时确定两个滞后阈值,即该算子的行为等同于传入 'contrast_hyst'"contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst" 而非
'contrast'"contrast""contrast""contrast""contrast""contrast"。
determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params 主要用于在创建模型之前确定上述参数,例如在交互式系统中,该系统会向用户提供这些参数的建议值,但允许用户修改建议值。
自动确定的参数将作为名称-值对返回至 ParameterNameParameterNameParameterNameParameterNameparameterNameparameter_name 和 ParameterValueParameterValueParameterValueParameterValueparameterValueparameter_value 中。ParameterNameParameterNameParameterNameParameterNameparameterNameparameter_name 中的参数名称与 ParametersParametersParametersParametersparametersparameters 中的名称完全一致,当然,其中的值 'all'"all""all""all""all""all" 会被替换为实际的参数名称。唯一例外是参数 'contrast_hyst'"contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst",该参数将返回两个值:
'contrast_low'"contrast_low""contrast_low""contrast_low""contrast_low""contrast_low" 和
'contrast_high'"contrast_high""contrast_high""contrast_high""contrast_high""contrast_high"。
其余参数(NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels、AngleStartAngleStartAngleStartAngleStartangleStartangle_start、AngleExtentAngleExtentAngleExtentAngleExtentangleExtentangle_extent、ScaleMinScaleMinScaleMinScaleMinscaleMinscale_min、ScaleMaxScaleMaxScaleMaxScaleMaxscaleMaxscale_max、OptimizationOptimizationOptimizationOptimizationoptimizationoptimization、MetricMetricMetricMetricmetricmetric、ContrastContrastContrastContrastcontrastcontrast 和 MinContrastMinContrastMinContrastMinContrastminContrastmin_contrast)的含义与
create_shape_modelcreate_shape_modelCreateShapeModelCreateShapeModelCreateShapeModelcreate_shape_model、create_scaled_shape_modelcreate_scaled_shape_modelCreateScaledShapeModelCreateScaledShapeModelCreateScaledShapeModelcreate_scaled_shape_model 和 create_aniso_shape_modelcreate_aniso_shape_modelCreateAnisoShapeModelCreateAnisoShapeModelCreateAnisoShapeModelcreate_aniso_shape_model 中相同。可通过这些算子查阅这些参数的说明。determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params 使用这些参数来计算待确定的参数,其方式与
create_shape_modelcreate_shape_modelCreateShapeModelCreateShapeModelCreateShapeModelcreate_shape_model、create_scaled_shape_modelcreate_scaled_shape_modelCreateScaledShapeModelCreateScaledShapeModelCreateScaledShapeModelcreate_scaled_shape_model 和 create_aniso_shape_modelcreate_aniso_shape_modelCreateAnisoShapeModelCreateAnisoShapeModelCreateAnisoShapeModelcreate_aniso_shape_model 中相同。需要注意的是,如果需要确定具有各向同性缩放的形状模型的参数,即如果 ParametersParametersParametersParametersparametersparameters 显式或通过 'all'"all""all""all""all""all" 隐式包含
'scale_step'"scale_step""scale_step""scale_step""scale_step""scale_step",则参数 ScaleMinScaleMinScaleMinScaleMinscaleMinscale_min 和 ScaleMaxScaleMaxScaleMaxScaleMaxscaleMaxscale_max 必须各包含一个值。如果需要确定具有各向异性缩放的形状模型的参数,即如果 ParametersParametersParametersParametersparametersparameters 显式或隐式地包含 'scale_r_step'"scale_r_step""scale_r_step""scale_r_step""scale_r_step""scale_r_step" 或
'scale_c_step'"scale_c_step""scale_c_step""scale_c_step""scale_c_step""scale_c_step",则参数 ScaleMinScaleMinScaleMinScaleMinscaleMinscale_min 和 ScaleMaxScaleMaxScaleMaxScaleMaxscaleMaxscale_max 必须各包含两个值。在这种情况下,相应参数的第一个值指行方向的缩放,而第二个值指列方向的缩放。
请注意,在 determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params 中,某些参数也可以自动确定(如 NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels、OptimizationOptimizationOptimizationOptimizationoptimizationoptimization、ContrastContrastContrastContrastcontrastcontrast、MinContrastMinContrastMinContrastMinContrastminContrastmin_contrast)。如果这些参数不应自动确定(即在
ParametersParametersParametersParametersparametersparameters 中未传入其名称),则相应的参数必须包含有效值,且不得设置为 'auto'"auto""auto""auto""auto""auto"。相反,如果这些参数需要自动确定,则其值将按以下方式处理:如果优化或(滞后)对比度需自动确定,即
ParametersParametersParametersParametersparametersparameters 包含值 'optimization'"optimization""optimization""optimization""optimization""optimization" 或
'contrast'"contrast""contrast""contrast""contrast""contrast"('contrast_hyst'"contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst""contrast_hyst"),则传递给
OptimizationOptimizationOptimizationOptimizationoptimizationoptimization 和 ContrastContrastContrastContrastcontrastcontrast 的值将被忽略。相反,如果金字塔层数上限或最小对比度需自动确定,即
ParametersParametersParametersParametersparametersparameters 中包含值 'num_levels'"num_levels""num_levels""num_levels""num_levels""num_levels" 或
'min_contrast'"min_contrast""min_contrast""min_contrast""min_contrast""min_contrast",您可以让 HALCON 确定合适的值,同时分别指定上限或下限:
如果需要预先指定金字塔层数的上限,可以将 NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels 设置为特定值。在此情况下,如果 ParametersParametersParametersParametersparametersparameters 包含值
'num_levels'"num_levels""num_levels""num_levels""num_levels""num_levels",则计算出的金字塔层数最多为 NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels。如果将 NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels 设置为
'auto'"auto""auto""auto""auto""auto"(或为向后兼容而设置为 0),则金字塔层数将不受限制地尽可能设为最大。
如果需要预先指定最小对比度,可以将
MinContrastMinContrastMinContrastMinContrastminContrastmin_contrast 设置为特定值。如果此时 ParametersParametersParametersParametersparametersparameters 包含值 'min_contrast'"min_contrast""min_contrast""min_contrast""min_contrast""min_contrast",则计算出的最小对比度不小于 MinContrastMinContrastMinContrastMinContrastminContrastmin_contrast。如果
MinContrastMinContrastMinContrastMinContrastminContrastmin_contrast 设置为 'auto'"auto""auto""auto""auto""auto",则最小对比度将不受限制地确定。
注意
在某些情况下,determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params 返回的金字塔层数上限会高于形状模型中实际使用的层数。创建模型后,可通过调用 get_shape_model_paramsget_shape_model_paramsGetShapeModelParamsGetShapeModelParamsGetShapeModelParamsget_shape_model_params 查询实际层数。如果模型是通过
create_scaled_shape_modelcreate_scaled_shape_modelCreateScaledShapeModelCreateScaledShapeModelCreateScaledShapeModelcreate_scaled_shape_model 或 create_aniso_shape_modelcreate_aniso_shape_modelCreateAnisoShapeModelCreateAnisoShapeModelCreateAnisoShapeModelcreate_aniso_shape_model
创建的,且 ScaleMin、ScaleRMin 或 ScaleCMin 的值小于 1.0,则可能会出现这种情况。
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
参数
TemplateTemplateTemplateTemplatetemplatetemplate (输入对象) (multichannel-)image → objectHImageHObjectHImageHobject (byte / uint2)
输入图像,其域将用于创建模型。
NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels (输入控制) integer → HTupleUnion[int, str]HTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)
金字塔层数的最大值。
默认值:
'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)
该模型的最小旋转。
默认值:
-0.39
建议值:
-3.14, -1.57, -0.79, -0.39, -0.20, 0.0
AngleExtentAngleExtentAngleExtentAngleExtentangleExtentangle_extent (输入控制) angle.rad → HTuplefloatHTupleHtuple (real) (double) (double) (double)
旋转角度的范围。
默认值:
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)
模型的最小缩放。
默认值:
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)
模型的最大缩放。
默认值:
1.1
建议值:
1.0, 1.1, 1.2, 1.3, 1.4, 1.5
限制:
ScaleMax >= ScaleMin
OptimizationOptimizationOptimizationOptimizationoptimizationoptimization (输入控制) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
某种优化。
默认值:
'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*)
匹配指标。
默认值:
'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*)
模板图像中对象对比度的阈值或迟滞阈值,以及可选的对象部件最小尺寸。
默认值:
'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*)
搜索图像中对象的最小对比度。
默认值:
'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*)
参数将自动确定。
默认值:
'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*)
自动确定的参数名称。
ParameterValueParameterValueParameterValueParameterValueparameterValueparameter_value (输出控制) number-array → HTupleSequence[Union[int, float]]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)
自动确定的参数值。
结果
如果参数有效,算子
determine_shape_model_paramsdetermine_shape_model_paramsDetermineShapeModelParamsDetermineShapeModelParamsDetermineShapeModelParamsdetermine_shape_model_params 返回值 2 (H_MSG_TRUE)。如有必要,则抛出异常。如果
NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels 和 ContrastContrastContrastContrastcontrastcontrast 参数的选择导致模型包含的点数过少,或者输入图像中不包含足够数量的显著特征,则会触发错误 8510。
可能的前趋
draw_regiondraw_regionDrawRegionDrawRegionDrawRegiondraw_region,
reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain,
thresholdthresholdThresholdThresholdThresholdthreshold
可能的后继
create_generic_shape_modelcreate_generic_shape_modelCreateGenericShapeModelCreateGenericShapeModelCreateGenericShapeModelcreate_generic_shape_model
模块
匹配