Skip to content

get_component_relationsGetComponentRelationsGetComponentRelationsget_component_relationsT_get_component_relations🔗

Short description🔗

get_component_relationsGetComponentRelationsGetComponentRelationsget_component_relationsT_get_component_relations — Return the relations between the model components that are contained in a training result.

Warning🔗

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

Signature🔗

get_component_relations( out region Relations, component_training ComponentTrainingID, integer ReferenceComponent, string Image, out rectangle2.center.y Row, out rectangle2.center.x Column, out rectangle2.angle.rad Phi, out rectangle2.hwidth Length1, out rectangle2.hheight Length2, out angle.rad AngleStart, out angle.rad AngleExtent )void GetComponentRelations( HObject* Relations, const HTuple& ComponentTrainingID, const HTuple& ReferenceComponent, const HTuple& Image, HTuple* Row, HTuple* Column, HTuple* Phi, HTuple* Length1, HTuple* Length2, HTuple* AngleStart, HTuple* AngleExtent )static void HOperatorSet.GetComponentRelations( out HObject relations, HTuple componentTrainingID, HTuple referenceComponent, HTuple image, out HTuple row, out HTuple column, out HTuple phi, out HTuple length1, out HTuple length2, out HTuple angleStart, out HTuple angleExtent )def get_component_relations( component_training_id: HHandle, reference_component: int, image: Union[str, int] ) -> Tuple[HObject, Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float]]

def get_component_relations_s( component_training_id: HHandle, reference_component: int, image: Union[str, int] ) -> Tuple[HObject, float, float, float, float, float, float, float]Herror T_get_component_relations( Hobject* Relations, const Htuple ComponentTrainingID, const Htuple ReferenceComponent, const Htuple Image, Htuple* Row, Htuple* Column, Htuple* Phi, Htuple* Length1, Htuple* Length2, Htuple* AngleStart, Htuple* AngleExtent )

HRegion HComponentTraining::GetComponentRelations( Hlong ReferenceComponent, const HTuple& Image, HTuple* Row, HTuple* Column, HTuple* Phi, HTuple* Length1, HTuple* Length2, HTuple* AngleStart, HTuple* AngleExtent ) const

HRegion HComponentTraining::GetComponentRelations( Hlong ReferenceComponent, const HString& Image, double* Row, double* Column, double* Phi, double* Length1, double* Length2, double* AngleStart, double* AngleExtent ) const

HRegion HComponentTraining::GetComponentRelations( Hlong ReferenceComponent, const char* Image, double* Row, double* Column, double* Phi, double* Length1, double* Length2, double* AngleStart, double* AngleExtent ) const

HRegion HComponentTraining::GetComponentRelations( Hlong ReferenceComponent, const wchar_t* Image, double* Row, double* Column, double* Phi, double* Length1, double* Length2, double* AngleStart, double* AngleExtent ) const (Windows only)

HRegion HComponentTraining.GetComponentRelations( int referenceComponent, HTuple image, out HTuple row, out HTuple column, out HTuple phi, out HTuple length1, out HTuple length2, out HTuple angleStart, out HTuple angleExtent )

HRegion HComponentTraining.GetComponentRelations( int referenceComponent, string image, out double row, out double column, out double phi, out double length1, out double length2, out double angleStart, out double angleExtent )

Description🔗

get_component_relationsGetComponentRelations returns the relations between model components after training them with train_model_componentsTrainModelComponents. With the parameter ReferenceComponentreferenceComponentreference_component, you can select a reference component. get_component_relationsGetComponentRelations then returns the relations between the reference component and all other components in the model image (if Imageimageimage \(=\) 'model_image'"model_image" or Imageimageimage \(=\) 00) or in a training image (if Imageimageimage >= 11). In order to obtain the relations in the ith training image, Imageimageimage must be set to i. The result of the training returned by train_model_componentsTrainModelComponents must be passed in ComponentTrainingIDcomponentTrainingIDcomponent_training_id. ReferenceComponentreferenceComponentreference_component describes the index of the reference component and must be within the range of 0 and n-1, if n is the number of model components (see train_model_componentsTrainModelComponents).

The relations are returned in form of regions in Relationsrelationsrelations as well as in form of numerical values in Rowrowrow, Columncolumncolumn, Phiphiphi, Length1length1length_1, Length2length2length_2, AngleStartangleStartangle_start, and AngleExtentangleExtentangle_extent.

The region object tuple Relationsrelationsrelations is designed as follows. For each component a separate region is returned. Consequently, Relationsrelationsrelations contains n regions, where the order of the regions within the tuple is determined by the index of the corresponding components. The positions of all components in the image are represented by circles with a radius of 3 pixels. For each component other than the reference component ReferenceComponentreferenceComponentreference_component, additionally the position relation and the orientation relation relative to the reference component are represented. The position relation is represented by a rectangle and the orientation relation is represented by a circle sector with a radius of 30 pixels. The center of the circle is placed at the mean relative position of the component. The rectangle describes the movement of the reference point of the respective component relative to the pose of the reference component, while the circle sector describes the variation of the relative orientation (see train_model_componentsTrainModelComponents). A relative orientation of 0 corresponds to the relative orientation of both components in the model image. If both components appear in the same relative orientation in all images, the circle sector consequently degenerates to a straight line.

In addition to the region object tuple Relationsrelationsrelations, the relations are also returned in form of numerical values in Rowrowrow, Columncolumncolumn, Phiphiphi, Length1length1length_1, Length2length2length_2, AngleStartangleStartangle_start, and AngleExtentangleExtentangle_extent. These parameters are tuples of length n and contain the relations of all components relative to the reference component, where the order of the values within the tuples is determined by the index of the corresponding component. The position relation is described by the parameters of the corresponding rectangle Rowrowrow, Columncolumncolumn, Phiphiphi, Length1length1length_1, and Length2length2length_2 (see gen_rectangle2GenRectangle2). The orientation relation is described by the starting angle AngleStartangleStartangle_start and the angle extent AngleExtentangleExtentangle_extent. For the reference component only the position within the image is returned in Rowrowrow and Columncolumncolumn. All other values are set to 00.

If the reference component has not been found in the current image, an array of empty regions is returned and the corresponding parameter values are set to 00.

The operator get_component_relationsGetComponentRelations is particularly useful in order to visualize the result of the training that was performed with train_model_componentsTrainModelComponents. With this, it is possible to evaluate the variations that are contained in the training images. Sometimes it might be reasonable to restart the training with train_model_componentsTrainModelComponents while using a different set of training images.

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🔗

Relationsrelationsrelations (output_object) region(-array) → objectHObjectHRegionHObjectHobject *

Region representation of the relations.

ComponentTrainingIDcomponentTrainingIDcomponent_training_id (input_control) component_training → (handle)HTuple (HHandle)HComponentTraining, HTuple (IntPtr)HHandleHtuple (handle)

Handle of the training result.

ReferenceComponentreferenceComponentreference_component (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Index of reference component.

Restriction: ReferenceComponent >= 0

Imageimageimage (input_control) string → (string / integer)HTuple (HString / Hlong)HTuple (string / int / long)Union[str, int]Htuple (char* / Hlong)

Image for which the component relations are to be returned.

Default: 'model_image'"model_image"
Suggested values: 'model_image', 0, 1, 2, 3, 4, 5, 6, 7, 8"model_image", 0, 1, 2, 3, 4, 5, 6, 7, 8

Rowrowrow (output_control) rectangle2.center.y(-array) → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Row coordinate of the center of the rectangle representing the relation.

Columncolumncolumn (output_control) rectangle2.center.x(-array) → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Column index of the center of the rectangle representing the relation.

Phiphiphi (output_control) rectangle2.angle.rad(-array) → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Orientation of the rectangle representing the relation (radians).

Assertion: -pi / 2 < Phi && Phi <= pi / 2

Length1length1length_1 (output_control) rectangle2.hwidth(-array) → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

First radius (half length) of the rectangle representing the relation.

Assertion: Length1 >= 0.0

Length2length2length_2 (output_control) rectangle2.hheight(-array) → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Second radius (half width) of the rectangle representing the relation.

Assertion: Length2 >= 0.0 && Length2 <= Length1

AngleStartangleStartangle_start (output_control) angle.rad(-array) → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Smallest relative orientation angle.

AngleExtentangleExtentangle_extent (output_control) angle.rad(-array) → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Extent of the relative orientation angles.

Result🔗

If the handle of the training result is valid, the operator get_component_relationsGetComponentRelations returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

See also

gen_rectangle2GenRectangle2

Module🔗

Matching