train_variation_model ( Images : : ModelID : )

Train a variation model.

train_variation_model trains the variation model that is passed in ModelID with one or more images, which are passed in Images.

As described for create_variation_model, a variation model that has been created using the mode 'standard' can be trained iteratively, i.e., as soon as images of good objects become available, they can be trained with train_variation_model. The ideal image of the object is computed as the mean of all previous training images and the images that are passed in Images. The corresponding variation image is computed as the standard deviation of the training images and the images that are passed in Images.

If the variation model has been created using the mode 'robust', the model cannot be trained iteratively, i.e., all training images must be accumulated using concat_obj and be trained with train_variation_model in a single call. If any images have been trained previously, the training information of the previous call is discarded. The image of the ideal object is computed as the median of all training images passed in Images. The corresponding variation image is computed as a suitably scaled median absolute deviation of the training images and the median image.


Parameters

Images (input_object)
image(-array) -> object : byte / int2 / uint2
Images of the object to be trained.

ModelID (input_control)
variation_model -> integer
ID of the variation model.


Example
open_framegrabber ('File', 1, 1, 0, 0, 0, 0, 'default', -1,
                   'default', -1, 'default', 'model.seq', 'default',
                   -1, -1, FGHandle)
grab_image (Image, FGHandle)
get_image_pointer1 (Image, Pointer, Type, Width, Height)
disp_obj (Image, WindowHandle)
draw_region (Region, WindowHandle)
reduce_domain (Image, Region, ImageReduced)
area_center (Region, Area, RowRef, ColumnRef)
create_shape_model (ImageReduced, 4, 0, rad(360), rad(1), 'none',
                    'use_polarity', 40, 10, TemplateID)
create_variation_model (Width, Height, Type, 'standard', ModelID)
for K := 1 to 100 by 1
    grab_image (Image, FGHandle)
    find_shape_model (Image, TemplateID, 0, rad(360), 0.5, 1, 0.5,
                      'true', 4, 0.9, Row, Column, Angle, Score)
    if (|Score| = 1)
        vector_angle_to_rigid (Row, Column, Angle, RowRef,
                               ColumnRef, 0, HomMat2D)
        affine_trans_image (Image, ImageTrans, HomMat2D, 'constant',
                            'false')
        train_variation_model (ImageTrans, ModelID)
    endif
endfor
prepare_variation_model (ModelID, 10, 4)
write_region (Region, 'model.reg')
write_shape_model (TemplateID, 'model.shape')
write_variation_model (ModelID, 'model.var')
clear_shape_model (TemplateID)
clear_variation_model (ModelID)
close_framegrabber (FGHandle)

Result

train_variation_model returns 2 (H_MSG_TRUE) if all parameters are correct.


Parallelization Information

train_variation_model is processed under mutual exclusion against itself and without parallelization.


Possible Predecessors

create_variation_model, find_shape_model, affine_trans_image, concat_obj


Possible Successors

prepare_variation_model


See also

prepare_variation_model, compare_variation_model, clear_variation_model


Module

Matching



Copyright © 1996-2008 MVTec Software GmbH