Skip to content

find_component_modelFindComponentModelFindComponentModelfind_component_modelT_find_component_modelπŸ”—

Short descriptionπŸ”—

find_component_modelFindComponentModelFindComponentModelfind_component_modelT_find_component_model β€” Find the best matches of a component model in an image.

WarningπŸ”—

find_component_modelFindComponentModel is obsolete and is only provided for reasons of backward compatibility. The operator will be removed with HALCON 26.11.

SignatureπŸ”—

find_component_model( image Image, component_model ComponentModelID, integer RootComponent, angle.rad AngleStartRoot, angle.rad AngleExtentRoot, real MinScore, integer NumMatches, real MaxOverlap, string IfRootNotFound, string IfComponentNotFound, string PosePrediction, real MinScoreComp, string SubPixelComp, integer NumLevelsComp, real GreedinessComp, out integer ModelStart, out integer ModelEnd, out real Score, out point.y RowComp, out point.x ColumnComp, out angle.rad AngleComp, out real ScoreComp, out integer ModelComp )void FindComponentModel( const HObject& Image, const HTuple& ComponentModelID, const HTuple& RootComponent, const HTuple& AngleStartRoot, const HTuple& AngleExtentRoot, const HTuple& MinScore, const HTuple& NumMatches, const HTuple& MaxOverlap, const HTuple& IfRootNotFound, const HTuple& IfComponentNotFound, const HTuple& PosePrediction, const HTuple& MinScoreComp, const HTuple& SubPixelComp, const HTuple& NumLevelsComp, const HTuple& GreedinessComp, HTuple* ModelStart, HTuple* ModelEnd, HTuple* Score, HTuple* RowComp, HTuple* ColumnComp, HTuple* AngleComp, HTuple* ScoreComp, HTuple* ModelComp )static void HOperatorSet.FindComponentModel( HObject image, HTuple componentModelID, HTuple rootComponent, HTuple angleStartRoot, HTuple angleExtentRoot, HTuple minScore, HTuple numMatches, HTuple maxOverlap, HTuple ifRootNotFound, HTuple ifComponentNotFound, HTuple posePrediction, HTuple minScoreComp, HTuple subPixelComp, HTuple numLevelsComp, HTuple greedinessComp, out HTuple modelStart, out HTuple modelEnd, out HTuple score, out HTuple rowComp, out HTuple columnComp, out HTuple angleComp, out HTuple scoreComp, out HTuple modelComp )def find_component_model( image: HObject, component_model_id: HHandle, root_component: MaybeSequence[int], angle_start_root: MaybeSequence[float], angle_extent_root: MaybeSequence[float], min_score: float, num_matches: int, max_overlap: float, if_root_not_found: str, if_component_not_found: str, pose_prediction: str, min_score_comp: MaybeSequence[float], sub_pixel_comp: MaybeSequence[str], num_levels_comp: MaybeSequence[int], greediness_comp: MaybeSequence[float] ) -> Tuple[Sequence[int], Sequence[int], Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[int]]

def find_component_model_s( image: HObject, component_model_id: HHandle, root_component: MaybeSequence[int], angle_start_root: MaybeSequence[float], angle_extent_root: MaybeSequence[float], min_score: float, num_matches: int, max_overlap: float, if_root_not_found: str, if_component_not_found: str, pose_prediction: str, min_score_comp: MaybeSequence[float], sub_pixel_comp: MaybeSequence[str], num_levels_comp: MaybeSequence[int], greediness_comp: MaybeSequence[float] ) -> Tuple[int, int, float, float, float, float, float, int]Herror T_find_component_model( const Hobject Image, const Htuple ComponentModelID, const Htuple RootComponent, const Htuple AngleStartRoot, const Htuple AngleExtentRoot, const Htuple MinScore, const Htuple NumMatches, const Htuple MaxOverlap, const Htuple IfRootNotFound, const Htuple IfComponentNotFound, const Htuple PosePrediction, const Htuple MinScoreComp, const Htuple SubPixelComp, const Htuple NumLevelsComp, const Htuple GreedinessComp, Htuple* ModelStart, Htuple* ModelEnd, Htuple* Score, Htuple* RowComp, Htuple* ColumnComp, Htuple* AngleComp, Htuple* ScoreComp, Htuple* ModelComp )

HTuple HComponentModel::FindComponentModel( const HImage& Image, const HTuple& RootComponent, const HTuple& AngleStartRoot, const HTuple& AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const HString& IfRootNotFound, const HString& IfComponentNotFound, const HString& PosePrediction, const HTuple& MinScoreComp, const HTuple& SubPixelComp, const HTuple& NumLevelsComp, const HTuple& GreedinessComp, HTuple* ModelEnd, HTuple* Score, HTuple* RowComp, HTuple* ColumnComp, HTuple* AngleComp, HTuple* ScoreComp, HTuple* ModelComp ) const

Hlong HComponentModel::FindComponentModel( const HImage& Image, Hlong RootComponent, double AngleStartRoot, double AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const HString& IfRootNotFound, const HString& IfComponentNotFound, const HString& PosePrediction, double MinScoreComp, const HString& SubPixelComp, Hlong NumLevelsComp, double GreedinessComp, Hlong* ModelEnd, double* Score, double* RowComp, double* ColumnComp, double* AngleComp, double* ScoreComp, Hlong* ModelComp ) const

Hlong HComponentModel::FindComponentModel( const HImage& Image, Hlong RootComponent, double AngleStartRoot, double AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const char* IfRootNotFound, const char* IfComponentNotFound, const char* PosePrediction, double MinScoreComp, const char* SubPixelComp, Hlong NumLevelsComp, double GreedinessComp, Hlong* ModelEnd, double* Score, double* RowComp, double* ColumnComp, double* AngleComp, double* ScoreComp, Hlong* ModelComp ) const

Hlong HComponentModel::FindComponentModel( const HImage& Image, Hlong RootComponent, double AngleStartRoot, double AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const wchar_t* IfRootNotFound, const wchar_t* IfComponentNotFound, const wchar_t* PosePrediction, double MinScoreComp, const wchar_t* SubPixelComp, Hlong NumLevelsComp, double GreedinessComp, Hlong* ModelEnd, double* Score, double* RowComp, double* ColumnComp, double* AngleComp, double* ScoreComp, Hlong* ModelComp ) const (Windows only)

HTuple HImage::FindComponentModel( const HComponentModel& ComponentModelID, const HTuple& RootComponent, const HTuple& AngleStartRoot, const HTuple& AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const HString& IfRootNotFound, const HString& IfComponentNotFound, const HString& PosePrediction, const HTuple& MinScoreComp, const HTuple& SubPixelComp, const HTuple& NumLevelsComp, const HTuple& GreedinessComp, HTuple* ModelEnd, HTuple* Score, HTuple* RowComp, HTuple* ColumnComp, HTuple* AngleComp, HTuple* ScoreComp, HTuple* ModelComp ) const

Hlong HImage::FindComponentModel( const HComponentModel& ComponentModelID, Hlong RootComponent, double AngleStartRoot, double AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const HString& IfRootNotFound, const HString& IfComponentNotFound, const HString& PosePrediction, double MinScoreComp, const HString& SubPixelComp, Hlong NumLevelsComp, double GreedinessComp, Hlong* ModelEnd, double* Score, double* RowComp, double* ColumnComp, double* AngleComp, double* ScoreComp, Hlong* ModelComp ) const

Hlong HImage::FindComponentModel( const HComponentModel& ComponentModelID, Hlong RootComponent, double AngleStartRoot, double AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const char* IfRootNotFound, const char* IfComponentNotFound, const char* PosePrediction, double MinScoreComp, const char* SubPixelComp, Hlong NumLevelsComp, double GreedinessComp, Hlong* ModelEnd, double* Score, double* RowComp, double* ColumnComp, double* AngleComp, double* ScoreComp, Hlong* ModelComp ) const

Hlong HImage::FindComponentModel( const HComponentModel& ComponentModelID, Hlong RootComponent, double AngleStartRoot, double AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const wchar_t* IfRootNotFound, const wchar_t* IfComponentNotFound, const wchar_t* PosePrediction, double MinScoreComp, const wchar_t* SubPixelComp, Hlong NumLevelsComp, double GreedinessComp, Hlong* ModelEnd, double* Score, double* RowComp, double* ColumnComp, double* AngleComp, double* ScoreComp, Hlong* ModelComp ) const (Windows only)

HTuple HComponentModel.FindComponentModel( HImage image, HTuple rootComponent, HTuple angleStartRoot, HTuple angleExtentRoot, double minScore, int numMatches, double maxOverlap, string ifRootNotFound, string ifComponentNotFound, string posePrediction, HTuple minScoreComp, HTuple subPixelComp, HTuple numLevelsComp, HTuple greedinessComp, out HTuple modelEnd, out HTuple score, out HTuple rowComp, out HTuple columnComp, out HTuple angleComp, out HTuple scoreComp, out HTuple modelComp )

int HComponentModel.FindComponentModel( HImage image, int rootComponent, double angleStartRoot, double angleExtentRoot, double minScore, int numMatches, double maxOverlap, string ifRootNotFound, string ifComponentNotFound, string posePrediction, double minScoreComp, string subPixelComp, int numLevelsComp, double greedinessComp, out int modelEnd, out double score, out double rowComp, out double columnComp, out double angleComp, out double scoreComp, out int modelComp )

HTuple HImage.FindComponentModel( HComponentModel componentModelID, HTuple rootComponent, HTuple angleStartRoot, HTuple angleExtentRoot, double minScore, int numMatches, double maxOverlap, string ifRootNotFound, string ifComponentNotFound, string posePrediction, HTuple minScoreComp, HTuple subPixelComp, HTuple numLevelsComp, HTuple greedinessComp, out HTuple modelEnd, out HTuple score, out HTuple rowComp, out HTuple columnComp, out HTuple angleComp, out HTuple scoreComp, out HTuple modelComp )

int HImage.FindComponentModel( HComponentModel componentModelID, int rootComponent, double angleStartRoot, double angleExtentRoot, double minScore, int numMatches, double maxOverlap, string ifRootNotFound, string ifComponentNotFound, string posePrediction, double minScoreComp, string subPixelComp, int numLevelsComp, double greedinessComp, out int modelEnd, out double score, out double rowComp, out double columnComp, out double angleComp, out double scoreComp, out int modelComp )

DescriptionπŸ”—

The operator find_component_modelFindComponentModel finds the best NumMatchesnumMatchesnum_matches instances of the component model ComponentModelIDcomponentModelIDcomponent_model_id in the input image Imageimageimage.

The result of the search can be visualized using get_found_component_modelGetFoundComponentModel. Also the operator can be used to extract the component matches of a certain component model instance.

Further information about input parametersπŸ”—

Further information about output parametersπŸ”—

Internally, the shape-based matching is used for the component-based matching in order to search the individual components (see find_shape_modelFindShapeModel).

The domain of the Imageimageimage determines the search space for the reference point, i.e., the allowed positions, of the root component.

Usually the component model is searched only within those points of the image domain in which the model fits completely into the image. This means that the components will not be found if they extend beyond the borders of the image, even if they would achieve a score greater than MinScoreCompminScoreCompmin_score_comp (see above).

Note that, if for a certain pyramid level the component model touches the image border, it might not be found even if it lies completely within the original image. As a rule of thumb, the model might not be found if its distance to an image border falls below \(2^{NumLevels-1}\). This behavior can be changed with set_system('border_shape_models','true'), which will cause components that extend beyond the image border to be found if they achieve a score greater than MinScoreCompminScoreCompmin_score_comp. Here, points lying outside the image are regarded as being occluded, i.e., they lower the score. It should be noted that this mode increases the runtime of the search.

Note further, that in rare cases, which occur typically only for artificial images, the model might not be found also if for certain pyramid levels the model touches the border of the reduced domain. Then, it may help to enlarge the reduced domain by \(2^{NumLevels-1}\) using, e.g., dilation_circleDilationCircle.

When tracking the matches through the image pyramid, on each level, some less promising matches are rejected based on NumMatchesnumMatchesnum_matches. Thus, it is possible that some matches are rejected that would have had a higher score on the lowest pyramid level. Due to this, for example, the found match for NumMatchesnumMatchesnum_matches set to 11 might be different from the match with the highest score returned when setting NumMatchesnumMatchesnum_matches to 00 or > 11.

RecommendationsπŸ”—

If multiple objects with a similar score are expected, but only the one with the highest score should be returned, it might be preferable to raise NumMatchesnumMatchesnum_matches, and then select the match with the highest score.

To get a meaningful score value and to avoid erroneous matches, we recommend to always combine the allowance of a deformation with a subpixel extraction that applies a least-squares adjustment. If the subpixel extraction and/or the maximum object deformation is specified separately for each component, for each component in ComponentModelIDcomponentModelIDcomponent_model_id exactly one value for the subpixel extraction must be passed in SubPixelCompsubPixelCompsub_pixel_comp. After each value for the subpixel extraction optionally a second value can be passed, which describes the maximum object deformation of the corresponding mode. If for a certain component no value for the maximum object deformation is passed, the component is searched without taking deformations into account. Further details can be found in the documentation of find_shape_modelsFindShapeModels.

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.

ParametersπŸ”—

Imageimageimage (input_object) (multichannel-)image β†’ object (byte / uint2)HObject (byte / uint2)HImage (byte / uint2)HObject (byte / uint2)Hobject (byte / uint2)

Input image in which the component model should be found.

ComponentModelIDcomponentModelIDcomponent_model_id (input_control) component_model β†’ (handle)HTuple (HHandle)HComponentModel, HTuple (IntPtr)HHandleHtuple (handle)

Handle of the component model.

RootComponentrootComponentroot_component (input_control) integer(-array) β†’ (integer)HTuple (Hlong)HTuple (int / long)MaybeSequence[int]Htuple (Hlong)

Index of the root component.

Suggested values: 0, 1, 2, 3, 4, 5, 6, 7, 80, 1, 2, 3, 4, 5, 6, 7, 8

AngleStartRootangleStartRootangle_start_root (input_control) angle.rad(-array) β†’ (real)HTuple (double)HTuple (double)MaybeSequence[float]Htuple (double)

Smallest rotation of the root component

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

AngleExtentRootangleExtentRootangle_extent_root (input_control) angle.rad(-array) β†’ (real)HTuple (double)HTuple (double)MaybeSequence[float]Htuple (double)

Extent of the rotation of the root component.

Default: 0.790.79
Suggested values: 6.28, 3.14, 1.57, 0.79, 0.39, 0.06.28, 3.14, 1.57, 0.79, 0.39, 0.0
Restriction: AngleExtentRoot >= 0

MinScoreminScoremin_score (input_control) real β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Minimum score of the instances of the component model to be found.

Default: 0.50.5
Suggested values: 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
Minimum increment: 0.01
Recommended increment: 0.05
Restriction: 0 <= MinScore && MinScore <= 1

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

Number of instances of the component model to be found (or 0 for all matches).

Default: 11
Suggested values: 0, 1, 2, 3, 4, 5, 10, 200, 1, 2, 3, 4, 5, 10, 20

MaxOverlapmaxOverlapmax_overlap (input_control) real β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Maximum overlap of the instances of the component models to be found.

Default: 0.50.5
Suggested values: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.00.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0
Minimum increment: 0.01
Recommended increment: 0.05
Restriction: 0 <= MaxOverlap && MaxOverlap <= 1

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

Behavior if the root component is missing.

Default: 'stop_search'"stop_search"
List of values: 'select_new_root', 'stop_search'"select_new_root", "stop_search"

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

Behavior if a component is missing.

Default: 'prune_branch'"prune_branch"
List of values: 'prune_branch', 'search_from_best', 'search_from_upper'"prune_branch", "search_from_best", "search_from_upper"

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

Pose prediction of components that are not found.

Default: 'none'"none"
List of values: 'from_all', 'from_neighbors', 'none'"from_all", "from_neighbors", "none"

MinScoreCompminScoreCompmin_score_comp (input_control) real(-array) β†’ (real)HTuple (double)HTuple (double)MaybeSequence[float]Htuple (double)

Minimum score of the instances of the components to be found.

Default: 0.50.5
Suggested values: 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
Minimum increment: 0.01
Recommended increment: 0.05
Restriction: 0 <= MinScoreComp && MinScoreComp <= 1

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

Subpixel accuracy of the component poses if not equal to 'none'"none".

Default: 'least_squares'"least_squares"
Suggested values: 'none', 'interpolation', 'least_squares', 'least_squares_high', 'least_squares_very_high', 'max_deformation 1', 'max_deformation 2', 'max_deformation 3', 'max_deformation 4', 'max_deformation 5', 'max_deformation 6'"none", "interpolation", "least_squares", "least_squares_high", "least_squares_very_high", "max_deformation 1", "max_deformation 2", "max_deformation 3", "max_deformation 4", "max_deformation 5", "max_deformation 6"

NumLevelsCompnumLevelsCompnum_levels_comp (input_control) integer(-array) β†’ (integer)HTuple (Hlong)HTuple (int / long)MaybeSequence[int]Htuple (Hlong)

Number of pyramid levels for the components used in the matching (and lowest pyramid level to use if \(|\textrm{NumLevelsComp}| = 2n\)).

Default: 00
List of values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

GreedinessCompgreedinessCompgreediness_comp (input_control) real(-array) β†’ (real)HTuple (double)HTuple (double)MaybeSequence[float]Htuple (double)

β€œGreediness” of the search heuristic for the components (0: safe but slow; 1: fast but matches may be missed).

Default: 0.90.9
Suggested values: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.00.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0
Minimum increment: 0.01
Recommended increment: 0.05
Restriction: 0 <= GreedinessComp && GreedinessComp <= 1

ModelStartmodelStartmodel_start (output_control) integer(-array) β†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Start index of each found instance of the component model in the tuples describing the component matches.

ModelEndmodelEndmodel_end (output_control) integer(-array) β†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

End index of each found instance of the component model in the tuples describing the component matches.

Scorescorescore (output_control) real(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Score of the found instances of the component model.

RowComprowComprow_comp (output_control) point.y(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Row coordinate of the found component matches.

ColumnCompcolumnCompcolumn_comp (output_control) point.x(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Column coordinate of the found component matches.

AngleCompangleCompangle_comp (output_control) angle.rad(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Rotation angle of the found component matches.

ScoreCompscoreCompscore_comp (output_control) real(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Score of the found component matches.

ModelCompmodelCompmodel_comp (output_control) integer(-array) β†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Index of the found components.

ResultπŸ”—

If the parameter values are correct, the operator find_component_modelFindComponentModel returns the value 2 (H_MSG_TRUE). If the input is empty (no input image available) the behavior can be set via set_system('no_object_result',<Result>). If necessary, an exception is raised.

ModuleπŸ”—

Matching