get_training_componentsT_get_training_componentsGetTrainingComponentsGetTrainingComponentsget_training_components (Operator)
Name
get_training_componentsT_get_training_componentsGetTrainingComponentsGetTrainingComponentsget_training_components
— Return the initial or model components in a certain image.
Signature
void GetTrainingComponents(HObject* TrainingComponents, const HTuple& ComponentTrainingID, const HTuple& Components, const HTuple& Image, const HTuple& MarkOrientation, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Score)
HRegion HComponentTraining::GetTrainingComponents(const HTuple& Components, const HTuple& Image, const HString& MarkOrientation, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Score) const
HRegion HComponentTraining::GetTrainingComponents(const HString& Components, const HString& Image, const HString& MarkOrientation, double* Row, double* Column, double* Angle, double* Score) const
HRegion HComponentTraining::GetTrainingComponents(const char* Components, const char* Image, const char* MarkOrientation, double* Row, double* Column, double* Angle, double* Score) const
HRegion HComponentTraining::GetTrainingComponents(const wchar_t* Components, const wchar_t* Image, const wchar_t* MarkOrientation, double* Row, double* Column, double* Angle, double* Score) const
(Windows only)
static void HOperatorSet.GetTrainingComponents(out HObject trainingComponents, HTuple componentTrainingID, HTuple components, HTuple image, HTuple markOrientation, out HTuple row, out HTuple column, out HTuple angle, out HTuple score)
HRegion HComponentTraining.GetTrainingComponents(HTuple components, HTuple image, string markOrientation, out HTuple row, out HTuple column, out HTuple angle, out HTuple score)
HRegion HComponentTraining.GetTrainingComponents(string components, string image, string markOrientation, out double row, out double column, out double angle, out double score)
def get_training_components(component_training_id: HHandle, components: Union[str, int], image: Union[str, int], mark_orientation: str) -> Tuple[HObject, Sequence[float], Sequence[float], Sequence[float], Sequence[float]]
def get_training_components_s(component_training_id: HHandle, components: Union[str, int], image: Union[str, int], mark_orientation: str) -> Tuple[HObject, float, float, float, float]
Description
get_training_componentsget_training_componentsGetTrainingComponentsGetTrainingComponentsGetTrainingComponentsget_training_components
returns all initial components (if
ComponentsComponentsComponentsComponentscomponentscomponents
= 'initial_components'"initial_components""initial_components""initial_components""initial_components""initial_components") or all model
components (if ComponentsComponentsComponentsComponentscomponentscomponents
= 'model_components'"model_components""model_components""model_components""model_components""model_components")
in TrainingComponentsTrainingComponentsTrainingComponentsTrainingComponentstrainingComponentstraining_components
in form of contour regions as well as
in numerical form. Alternatively, by directly passing the index of
an initial component, all found poses of that initial component
(i.e., the poses before solving the ambiguities in
train_model_componentstrain_model_componentsTrainModelComponentsTrainModelComponentsTrainModelComponentstrain_model_components
) are returned.
The pose of the returned components corresponds to their pose in the
model image (if ImageImageImageImageimageimage
= 'model_image'"model_image""model_image""model_image""model_image""model_image" or
ImageImageImageImageimageimage
= 0) or in a training image (if
ImageImageImageImageimageimage
>= 1). In order to obtain the
components in the pose at which they were found in the ith
training image, ImageImageImageImageimageimage
must be set to i. Furthermore,
when dealing with rotationally symmetric components, one may wish to
mark the current orientation of the found component. This can be
achieved by setting MarkOrientationMarkOrientationMarkOrientationMarkOrientationmarkOrientationmark_orientation
to 'true'"true""true""true""true""true". In
this case, the contour region of each component is complemented by an
arrow at its reference point pointing in the reference
direction. The reference direction of a component is based on the
orientation of the component in the model image and is represented
by an arrow that starts at the reference point and points to the
right in the horizontal direction.
In addition to the contour regions, the pose and the score of all
found components is returned in RowRowRowRowrowrow
, ColumnColumnColumnColumncolumncolumn
,
AngleAngleAngleAngleangleangle
, and ScoreScoreScoreScorescorescore
(see
find_shape_modelfind_shape_modelFindShapeModelFindShapeModelFindShapeModelfind_shape_model
). If ComponentsComponentsComponentsComponentscomponentscomponents
was set to
'initial_components'"initial_components""initial_components""initial_components""initial_components""initial_components" or 'model_components'"model_components""model_components""model_components""model_components""model_components", the
tuples TrainingComponentsTrainingComponentsTrainingComponentsTrainingComponentstrainingComponentstraining_components
, RowRowRowRowrowrow
, ColumnColumnColumnColumncolumncolumn
,
AngleAngleAngleAngleangleangle
, and ScoreScoreScoreScorescorescore
always contain the same number of
elements as initial components or model components contained in
ComponentTrainingIDComponentTrainingIDComponentTrainingIDComponentTrainingIDcomponentTrainingIDcomponent_training_id
, respectively. If one component was not
found in the image, an empty region is returned in the corresponding
element of TrainingComponentsTrainingComponentsTrainingComponentsTrainingComponentstrainingComponentstraining_components
and the elements of the four
output control parameters are set to the value 0. In
contrast, if the index of an initial component is passed in
ComponentsComponentsComponentsComponentscomponentscomponents
, these tuples contain as many elements as
matches of the corresponding initial component were found in the
image.
The operator get_training_componentsget_training_componentsGetTrainingComponentsGetTrainingComponentsGetTrainingComponentsget_training_components
is particularly useful
in order to visualize the result of the training
ComponentTrainingIDComponentTrainingIDComponentTrainingIDComponentTrainingIDcomponentTrainingIDcomponent_training_id
, which was performed with
train_model_componentstrain_model_componentsTrainModelComponentsTrainModelComponentsTrainModelComponentstrain_model_components
. With this, it is possible to
evaluate the suitability of the training images or to inspect the
influence of the parameters of
train_model_componentstrain_model_componentsTrainModelComponentsTrainModelComponentsTrainModelComponentstrain_model_components
. Sometimes it might be reasonable to
restart the training with train_model_componentstrain_model_componentsTrainModelComponentsTrainModelComponentsTrainModelComponentstrain_model_components
using
a different set of training images or after adjusting the
parameters.
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
TrainingComponentsTrainingComponentsTrainingComponentsTrainingComponentstrainingComponentstraining_components
(output_object) region(-array) →
objectHRegionHObjectHRegionHobject *
Contour regions of the initial components or of
the model components.
ComponentTrainingIDComponentTrainingIDComponentTrainingIDComponentTrainingIDcomponentTrainingIDcomponent_training_id
(input_control) component_training →
HComponentTraining, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Handle of the training result.
ComponentsComponentsComponentsComponentscomponentscomponents
(input_control) string →
HTupleUnion[str, int]HTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)
Type of returned components or index of an initial
component.
Default value:
'model_components'
"model_components"
"model_components"
"model_components"
"model_components"
"model_components"
Suggested values: 'model_components'"model_components""model_components""model_components""model_components""model_components", 'initial_components'"initial_components""initial_components""initial_components""initial_components""initial_components", 0, 1, 2, 3, 4, 5
ImageImageImageImageimageimage
(input_control) string →
HTupleUnion[str, int]HTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)
Image for which the components are to be returned.
Default value:
'model_image'
"model_image"
"model_image"
"model_image"
"model_image"
"model_image"
Suggested values: 'model_image'"model_image""model_image""model_image""model_image""model_image", 0, 1, 2, 3, 4, 5, 6, 7, 8
MarkOrientationMarkOrientationMarkOrientationMarkOrientationmarkOrientationmark_orientation
(input_control) string →
HTuplestrHTupleHtuple (string) (string) (HString) (char*)
Mark the orientation of the components.
Default value:
'false'
"false"
"false"
"false"
"false"
"false"
List of values: 'false'"false""false""false""false""false", 'true'"true""true""true""true""true"
RowRowRowRowrowrow
(output_control) point.y(-array) →
HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)
Row coordinate of the found instances of all
initial components or model components.
ColumnColumnColumnColumncolumncolumn
(output_control) point.x(-array) →
HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)
Column coordinate of the found instances of all
initial components or model components.
AngleAngleAngleAngleangleangle
(output_control) angle.rad(-array) →
HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)
Rotation angle of the found instances of all
components.
ScoreScoreScoreScorescorescore
(output_control) real(-array) →
HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)
Score of the found instances of all components.
Example (HDevelop)
* Get the model image.
read_image (ModelImage, 'model_image.tif')
* Define the regions for the initial components.
gen_rectangle2 (InitialComponentRegions, 212, 233, 0.62, 167, 29)
gen_rectangle2 (Rectangle2, 298, 363, 1.17, 162, 34)
gen_rectangle2 (Rectangle3, 63, 444, -0.26, 50, 27)
gen_rectangle2 (Rectangle4, 120, 473, 0, 33, 20)
concat_obj (InitialComponentRegions, Rectangle2, InitialComponentRegions)
concat_obj (InitialComponentRegions, Rectangle3, InitialComponentRegions)
concat_obj (InitialComponentRegions, Rectangle4, InitialComponentRegions)
* Get the training images.
gen_empty_obj (TrainingImages)
for i := 1 to 4 by 1
read_image (TrainingImage, 'training_image-'+i+'.tif')
concat_obj (TrainingImages, TrainingImage, TrainingImages)
endfor
* Extract the model components and train the relations.
train_model_components (ModelImage, InitialComponentRegions, \
TrainingImages, ModelComponents, 22, 60, 30, 0.6, \
0, 0, rad(60), 'speed', 'rigidity', 0.2, 0.4, \
ComponentTrainingID)
* Visualize the result of the training.
count_obj (InitialComponentRegions, NumInitComp)
count_obj (TrainingImages, NumTrainings)
for i := 1 to NumTrainings by 1
select_obj (TrainingImages, TrainingImage, i)
for j := 0 to NumInitComp-1 by 1
* Visualize the ambiguous poses of each initial component.
get_training_components (TrainingComponents, ComponentTrainingID, \
j, i, 'false', Row, Column, Angle, Score)
endfor
* Visualize the final poses of the initial components.
get_training_components (TrainingComponents, ComponentTrainingID, \
'initial_components', i, 'false', \
Row, Column, Angle, Score)
* Visualize the final poses of the model components.
get_training_components (TrainingComponents, ComponentTrainingID, \
'model_components', i, 'false', \
Row, Column, Angle, Score)
endfor
Result
If the handle of the training result is valid, the operator
get_training_componentsget_training_componentsGetTrainingComponentsGetTrainingComponentsGetTrainingComponentsget_training_components
returns the value 2 (H_MSG_TRUE). If
necessary an exception is raised.
Possible Predecessors
train_model_componentstrain_model_componentsTrainModelComponentsTrainModelComponentsTrainModelComponentstrain_model_components
Possible Successors
train_model_componentstrain_model_componentsTrainModelComponentsTrainModelComponentsTrainModelComponentstrain_model_components
See also
find_shape_modelfind_shape_modelFindShapeModelFindShapeModelFindShapeModelfind_shape_model
Module
Matching