VTrain Method

Description
This command allows you to train objects in an entire sequence or individual objects.

Syntax
Function VTrain (Sequence As String [, Object As String] [, Flags as Integer] [, Parent as Form]) As Boolean

Parameters

  • Sequence
    The name of a vision sequence in the current project.
  • Object
    The object name in Sequence. You can register any type of object. If Object is an empty string, then the entire sequence can be trained.
  • Flags
    VTrain dialog configuration. (Optional)1 - Displays the Teach button. 2 - Do not display the model window.
  • Parent
    Optional. A .NET form that is the parent of the window.

Return Value
If the operator clicks the OK button, VTrain returns True, otherwise it returns False.

Remarks
When VTrain is executed, a dialog is opened showing a live video image with the specified object displayed. The operator can size/move the search window, and train the model window (for correlation and geometric objects). When the operator is finished, he can click on OK to save the changes, or Cancel to ignore the changes. If OK is clicked, then the new information is automatically saved in the current project.

If flags bit 1 is set, a teach button will be displayed. For Correlation, Geometric, and Polar objects, the model will be taught if the teach button is clicked. You can retrieve the ModelOK property after running VTrain to check if a model was trained. For Blob objects, the button will open the Histogram dialog and the operator can adjust both high and low thresholds and then view the effects of changes.

If flags bit 2 is set, model windows will not be displayed. The operator can only change search windows.

For correlation and geometric objects, you can call VTeach after calling VTrain to teach the model if you are not displaying the teach button.

See Also
VTeach Method, VSaveModel Method

VTrain Example
VB Example:

Dim status As Integer  
Dim trainOK As Boolean  
  
' First let the operator change the window position  
trainOK = m_spel.VTrain("seq01", "corr01")  
  
' Now teach the model  
If trainOK Then  
    m_spel.VTeach("seq01", "corr01", status)  
EndIf  

C# Example:

int status;  
bool trainOK;  
  
// First let the operator change the window position  
trainOK = m_spel.VTrain("seq01", "corr01");  
  
// Now teach the model  
if (trainOK)  
    m_spel.VTeach("seq01", "corr01", out status);