CogBeadInspectPattern Train Method Cognex VisionPro 9.22
Trains this pattern. If the pattern is already trained then it will be untrained and retrained.
The train operation also computes a set of run parameters that could be used at runtime. These parameters can be extracted from the train result and used at run time.
The FindResultIndexUsedInTrain will be set to the CurrentFindResultIndex.

Namespace: Cognex.VisionPro.EdgeInspect
Assembly: Cognex.VisionPro.EdgeInspect (in Cognex.VisionPro.EdgeInspect.dll) Version: 87.0.0.0
Syntax

public void Train()
Events

Event TypeReason
ICogChangedEvent Changed Fires when this method changes the Trained state of the pattern. The following state flags may be affected:
  • SfTrained
  • SfTrainResult
  • SfFindResultIndexUsedInTrain
Exceptions

ExceptionCondition
CogSecurityViolationException Licensing for this operation cannot be confirmed. See Understanding VisionPro Security for more information.
CogOperatorFindNotRunException The FindResults property is null or empty; the Find  method has not been called, it was called and no paths were located, or the pattern has since become unfound.
CogOperatorNoTrainImageException The TrainImage is null.
ArgumentOutOfRangeException The CurrentFindResultIndex property is outside the valid index range for the current FindResults property. The index must be between 0 and (FindResults.Count - 1), inclusive.
ArgumentOutOfRangeException The FixedWidth property is outside the valid value range. The value can not be 50% greater than or 50% less than the BeadWidth property of the selected CogBeadInspectFindResult.
ArgumentOutOfRangeException The FixedWidth is less than one pixel wide while FixedWidthEnabled is enabled.
CogImageBadTypeException The TrainImage you supplied is not a CogImage8Grey.
CogImageNoPixelsException The TrainImage has no allocated pixels.
Remarks

This method relies on the result from the Find  method and will return an exception if called prior to at least one valid find result being generated.

This method utilizes the CurrentFindResultIndex property in order to specify which path to train.

The result is assigned to the TrainResult property and is not returned by this method directly. The result object may be used to obtain information about the trained path, such as its graphical representation.

A BeadInspect pattern must be trained before it can be used to check for defects (see the CogBeadInspectPattern remarks for the definition of a defect) in a runtime image. The trained pattern holds information needed for performing these comparisons. For example, it holds the expected bead widths along the found path.

See Also