create_trained_component_modelCreateTrainedComponentModelCreateTrainedComponentModelcreate_trained_component_modelT_create_trained_component_model
説明
create_trained_component_modelCreateTrainedComponentModelCreateTrainedComponentModelcreate_trained_component_modelT_create_trained_component_model — トレーニングされた部品に基づくマッチングを行うのための部品モデルを
生成する。
警告
create_trained_component_modelCreateTrainedComponentModelは現在では使用されず、下位互換性のためだけに提供されます。
このオペレータはHALCON 26.11で削除予定です。
書式
create_trained_component_model( component_training ComponentTrainingID, angle.rad AngleStart, angle.rad AngleExtent, integer MinContrastComp, real MinScoreComp, integer NumLevelsComp, angle.rad AngleStepComp, string OptimizationComp, string MetricComp, string PregenerationComp, out component_model ComponentModelID, out integer RootRanking )void CreateTrainedComponentModel( const HTuple& ComponentTrainingID, const HTuple& AngleStart, const HTuple& AngleExtent, const HTuple& MinContrastComp, const HTuple& MinScoreComp, const HTuple& NumLevelsComp, const HTuple& AngleStepComp, const HTuple& OptimizationComp, const HTuple& MetricComp, const HTuple& PregenerationComp, HTuple* ComponentModelID, HTuple* RootRanking )static void HOperatorSet.CreateTrainedComponentModel( HTuple componentTrainingID, HTuple angleStart, HTuple angleExtent, HTuple minContrastComp, HTuple minScoreComp, HTuple numLevelsComp, HTuple angleStepComp, HTuple optimizationComp, HTuple metricComp, HTuple pregenerationComp, out HTuple componentModelID, out HTuple rootRanking )def create_trained_component_model( component_training_id: HHandle, angle_start: float, angle_extent: float, min_contrast_comp: MaybeSequence[Union[int, str]], min_score_comp: MaybeSequence[float], num_levels_comp: MaybeSequence[Union[int, str]], angle_step_comp: MaybeSequence[Union[float, str]], optimization_comp: str, metric_comp: MaybeSequence[str], pregeneration_comp: MaybeSequence[str] ) -> Tuple[HHandle, Sequence[int]]
def create_trained_component_model_s( component_training_id: HHandle, angle_start: float, angle_extent: float, min_contrast_comp: MaybeSequence[Union[int, str]], min_score_comp: MaybeSequence[float], num_levels_comp: MaybeSequence[Union[int, str]], angle_step_comp: MaybeSequence[Union[float, str]], optimization_comp: str, metric_comp: MaybeSequence[str], pregeneration_comp: MaybeSequence[str] ) -> Tuple[HHandle, int]Herror T_create_trained_component_model( const Htuple ComponentTrainingID, const Htuple AngleStart, const Htuple AngleExtent, const Htuple MinContrastComp, const Htuple MinScoreComp, const Htuple NumLevelsComp, const Htuple AngleStepComp, const Htuple OptimizationComp, const Htuple MetricComp, const Htuple PregenerationComp, Htuple* ComponentModelID, Htuple* RootRanking )
void HComponentModel::HComponentModel( const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, const HTuple& MinContrastComp, const HTuple& MinScoreComp, const HTuple& NumLevelsComp, const HTuple& AngleStepComp, const HString& OptimizationComp, const HTuple& MetricComp, const HTuple& PregenerationComp, HTuple* RootRanking )
void HComponentModel::HComponentModel( const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const HString& OptimizationComp, const HString& MetricComp, const HString& PregenerationComp, Hlong* RootRanking )
void HComponentModel::HComponentModel( const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const char* OptimizationComp, const char* MetricComp, const char* PregenerationComp, Hlong* RootRanking )
void HComponentModel::HComponentModel( const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const wchar_t* OptimizationComp, const wchar_t* MetricComp, const wchar_t* PregenerationComp, Hlong* RootRanking ) (Windows only)
public HComponentModel( HComponentTraining componentTrainingID, double angleStart, double angleExtent, HTuple minContrastComp, HTuple minScoreComp, HTuple numLevelsComp, HTuple angleStepComp, string optimizationComp, HTuple metricComp, HTuple pregenerationComp, out HTuple rootRanking )
public HComponentModel( HComponentTraining componentTrainingID, double angleStart, double angleExtent, int minContrastComp, double minScoreComp, int numLevelsComp, double angleStepComp, string optimizationComp, string metricComp, string pregenerationComp, out int rootRanking )
HComponentModel HComponentTraining::CreateTrainedComponentModel( double AngleStart, double AngleExtent, const HTuple& MinContrastComp, const HTuple& MinScoreComp, const HTuple& NumLevelsComp, const HTuple& AngleStepComp, const HString& OptimizationComp, const HTuple& MetricComp, const HTuple& PregenerationComp, HTuple* RootRanking ) const
HComponentModel HComponentTraining::CreateTrainedComponentModel( double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const HString& OptimizationComp, const HString& MetricComp, const HString& PregenerationComp, Hlong* RootRanking ) const
HComponentModel HComponentTraining::CreateTrainedComponentModel( double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const char* OptimizationComp, const char* MetricComp, const char* PregenerationComp, Hlong* RootRanking ) const
HComponentModel HComponentTraining::CreateTrainedComponentModel( double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const wchar_t* OptimizationComp, const wchar_t* MetricComp, const wchar_t* PregenerationComp, Hlong* RootRanking ) const (Windows only)
HTuple HComponentModel::CreateTrainedComponentModel( const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, const HTuple& MinContrastComp, const HTuple& MinScoreComp, const HTuple& NumLevelsComp, const HTuple& AngleStepComp, const HString& OptimizationComp, const HTuple& MetricComp, const HTuple& PregenerationComp )
Hlong HComponentModel::CreateTrainedComponentModel( const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const HString& OptimizationComp, const HString& MetricComp, const HString& PregenerationComp )
Hlong HComponentModel::CreateTrainedComponentModel( const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const char* OptimizationComp, const char* MetricComp, const char* PregenerationComp )
Hlong HComponentModel::CreateTrainedComponentModel( const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const wchar_t* OptimizationComp, const wchar_t* MetricComp, const wchar_t* PregenerationComp ) (Windows only)
HComponentModel HComponentTraining.CreateTrainedComponentModel( double angleStart, double angleExtent, HTuple minContrastComp, HTuple minScoreComp, HTuple numLevelsComp, HTuple angleStepComp, string optimizationComp, HTuple metricComp, HTuple pregenerationComp, out HTuple rootRanking )
HComponentModel HComponentTraining.CreateTrainedComponentModel( double angleStart, double angleExtent, int minContrastComp, double minScoreComp, int numLevelsComp, double angleStepComp, string optimizationComp, string metricComp, string pregenerationComp, out int rootRanking )
HTuple HComponentModel.CreateTrainedComponentModel( HComponentTraining componentTrainingID, double angleStart, double angleExtent, HTuple minContrastComp, HTuple minScoreComp, HTuple numLevelsComp, HTuple angleStepComp, string optimizationComp, HTuple metricComp, HTuple pregenerationComp )
int HComponentModel.CreateTrainedComponentModel( HComponentTraining componentTrainingID, double angleStart, double angleExtent, int minContrastComp, double minScoreComp, int numLevelsComp, double angleStepComp, string optimizationComp, string metricComp, string pregenerationComp )
説明
create_trained_component_modelCreateTrainedComponentModel は、マッチングのための部品
モデルとして ComponentTrainingIDcomponentTrainingIDcomponent_training_id に渡されたトレーニング結
果を生成します。出力パラメーター ComponentModelIDcomponentModelIDcomponent_model_id はこの
モデルのハンドルで、その後の find_component_modelFindComponentModel の呼び出
しに使用されます。create_component_modelCreateComponentModel と比べ、モデルの
部品は create_trained_component_modelCreateTrainedComponentModel を呼び出す前に
train_model_componentsTrainModelComponents を用いて確実にトレーニングされている必
要があります。
パラメーター AngleStartangleStartangle_start と AngleExtentangleExtentangle_extent は、画像
内における部品モデルの可能な回転角度範囲を指定します。
内部的に、分割された形状モデルが各モデルの部品に対して生成されます
(create_shape_modelCreateShapeModel 参照)。従って、パラメーター
MinContrastCompminContrastCompmin_contrast_comp、~ MinScoreCompminScoreCompmin_score_comp、~
NumLevelsCompnumLevelsCompnum_levels_comp、~ AngleStepCompangleStepCompangle_step_comp、~
OptimizationCompoptimizationCompoptimization_comp、~ MetricCompmetricCompmetric_comp、および ~
PregenerationComppregenerationComppregeneration_comp は create_shape_modelCreateShapeModel のパラ
メーターに対応しますが、以下の点が異なります。まず1つ目に、
create_shape_modelCreateShapeModel ではパラメーター Optimizationoptimizationoptimization
によって、モデル点の数が減少する可能性および形状モデルを完全に事前
生成できる可能性があります。また、オペレーター
create_trained_component_modelCreateTrainedComponentModel では、形状モデルを事前に生
成するか否かを決定するために、独立したパラメーター
PregenerationComppregenerationComppregeneration_comp を使用します。2つ目に、パラメーター
MinScoreCompminScoreCompmin_score_comp に関する違いに注意してください。
形状ベースマッチングを使用する場合、create_shape_modelCreateShapeModel を使
用して形状モデルを準備する際にこのパラメーターを渡す必要はなく、
find_shape_modelFindShapeModelにて検査する際にのみ設定する必要
があります。対照的に、部品モデルを用意する際、モデルの部品の回転におけ
る対称性とモデルの部品間の類似性を解析することは有効です。しかしこれは、
探索の際に使われる MinScoreCompminScoreCompmin_score_comp(
find_component_modelFindComponentModel 参照)の値が、すでに近似的に既知であ
る場合にのみ、意味のある結果を導くことができます。
find_component_modelFindComponentModel での探索後、探索画像における部品の姿
勢パラメーターが返されます。姿勢パラメーターは部品の参照点に関連し
ていることに注意してください。部品の参照点は、
train_model_componentsTrainModelComponents の ModelComponentsmodelComponentsmodel_components で返さ
れた、それに対応する領域の重心です。
パラメーター MinContrastCompminContrastCompmin_contrast_comp、NumLevelsCompnumLevelsCompnum_levels_comp、
AngleStepCompangleStepCompangle_step_comp、および OptimizationCompoptimizationCompoptimization_comp は各パラ
メーターに 'auto'"auto" を渡すことによって自動的に決定すること
ができます。
部品に関するすべての明示的な入力パラメーター(名前の最後に texttt
{Comp} がついている)は、すべてのモデルの部品に同じ値を使う場合は 1 つの
要素、ComponentTrainingIDcomponentTrainingIDcomponent_training_id の対応する部品ごとに各パラメー
ターを使用する場合、ComponentTrainingIDcomponentTrainingIDcomponent_training_id に含まれるモデル
の部品数と同じ数の要素を含む必要があります。
個々の形状モデルに加え、部品モデルには、探索を最小の時間で行うため
に、find_component_modelFindComponentModel で 1 つのモデル部品と他それぞれの
部品との関連付けのために探索する方法に関する情報も含まれます。この
ために、部品はツリー構造で表現されます。まず、探索ツリー(ルート部
品)の一番上の親の部品を探索します。それから残りの部品を、探索ツ
リーにおける前のモデルの姿勢との関係性を用いて探索します。
ルートの部品は、探索の際に find_component_modelFindComponentModel の入力パラ
メーターとして渡されます。いくつかの要素により、モデルの部品が探索
ツリーでどのように関係するのかを適合します。原則として、画像内で高い確
率で見つけられるモデルの部品を選択してください。したがって、回転に
よって隠れが起こったり、消失が度々起きるような部品は、ルートの部品
として適していません。加えて、探索における実行時間をルートの部品が
適切かどうかの基準にすることもできます。後述する基準をもとにしたモ
デル部品のランキングが RootRankingrootRankingroot_ranking に返されます。このパラ
メーターにおいて、モデル部品のインデックスは、その計算時間を考慮し
た順でソートされます。例えば、RootRankingrootRankingroot_ranking[0] は、もっとも
早く探索できる部品がルートの部品として選択しています。なお、
RootRankingrootRankingroot_ranking に返されたランキングは、粗い概算のみを表すこ
とに注意してください。さらに、ルートランキングの計算は、
create_trained_component_modelCreateTrainedComponentModel と
find_component_modelFindComponentModel の呼び出し時、画像サイズおよびシステ
ムパラメーター 'border_shape_models'"border_shape_models" の値は同一であると仮
定して行われます。
実行情報
実行情報
このオペレータはハンドルを返します。このハンドルタイプのインスタンスの状態は、特定のオペレータにおいては、入力パラメータとして使われている場合であっても変更されることがあります。
パラメーター
ComponentTrainingIDcomponentTrainingIDcomponent_training_id (input_control) component_training → (handle)HTuple (HHandle)HComponentTraining, HTuple (IntPtr)HHandleHtuple (handle)
トレーニング結果のハンドル
AngleStartangleStartangle_start (input_control) angle.rad → (real)HTuple (double)HTuple (double)floatHtuple (double)
部品モデルの最小の角度
初期値: -0.39-0.39
推奨値: -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)
部品モデルの回転の幅
初期値: 0.790.79
推奨値: 6.28, 3.14, 1.57, 0.79, 0.396.28, 3.14, 1.57, 0.79, 0.39
制限: AngleExtent >= 0
MinContrastCompminContrastCompmin_contrast_comp (input_control) integer(-array) → (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)MaybeSequence[Union[int, str]]Htuple (Hlong / char*)
探索画像での部品の最小コントラスト
初期値: 'auto'"auto"
推奨値: 'auto', 10, 20, 20, 40"auto", 10, 20, 20, 40
制限: MinContrastComp >= 0
MinScoreCompminScoreCompmin_score_comp (input_control) real(-array) → (real)HTuple (double)HTuple (double)MaybeSequence[float]Htuple (double)
検出部品の最小スコア
初期値: 0.50.5
推奨値: 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.00.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0
最小増分: 0.01
推奨増分: 0.05
制限: 0 <= MinScoreComp && MinScoreComp <= 1
NumLevelsCompnumLevelsCompnum_levels_comp (input_control) integer(-array) → (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)MaybeSequence[Union[int, str]]Htuple (Hlong / char*)
部品のためのピラミッドレベルの最大値
初期値: 'auto'"auto"
値のリスト: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'auto'1, 2, 3, 4, 5, 6, 7, 8, 9, 10, "auto"
AngleStepCompangleStepCompangle_step_comp (input_control) angle.rad(-array) → (real / string)HTuple (double / HString)HTuple (double / string)MaybeSequence[Union[float, str]]Htuple (double / char*)
部品の角度のステップ幅(分解能)
初期値: 'auto'"auto"
推奨値: 'auto', 0.0175, 0.0349, 0.0524, 0.0698, 0.0873"auto", 0.0175, 0.0349, 0.0524, 0.0698, 0.0873
制限: AngleStepComp >= 0
OptimizationCompoptimizationCompoptimization_comp (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)
部品の最適化の種類
初期値: 'auto'"auto"
値のリスト: 'auto', 'none', 'point_reduction_high', 'point_reduction_low', 'point_reduction_medium'"auto", "none", "point_reduction_high", "point_reduction_low", "point_reduction_medium"
MetricCompmetricCompmetric_comp (input_control) string(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)
部品に使用するマッチ測定基準
初期値: 'use_polarity'"use_polarity"
値のリスト: 'ignore_color_polarity', 'ignore_global_polarity', 'ignore_local_polarity', 'use_polarity'"ignore_color_polarity", "ignore_global_polarity", "ignore_local_polarity", "use_polarity"
PregenerationComppregenerationComppregeneration_comp (input_control) string(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)
もし 'true'"true" である場合、部品の形状モデ ルを事前に生成
初期値: 'false'"false"
値のリスト: 'false', 'true'"false", "true"
ComponentModelIDcomponentModelIDcomponent_model_id (output_control) component_model → (handle)HTuple (HHandle)HComponentModel, HTuple (IntPtr)HHandleHtuple (handle)
部品モデルのハンドル
RootRankingrootRankingroot_ranking (output_control) integer(-array) → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)
ルートの部品として適切に表現されるモデル部品のランキ ング
結果
パラメーターが有効ならば、オペレーター
create_trained_component_modelCreateTrainedComponentModel は値 2 (H_MSG_TRUE) を返します。必要
に応じて、例外処理が発生します。
モジュール
Matching