CogPMAlignPattern TrainRegion Property Cognex VisionPro 9.5
Region of interest indicating portion of TrainImage or TrainShapeModels that will be used to train the pattern. A NULL TrainRegion indicates that the entire TrainImage or TrainShapeModels will be used to train the PMAlign pattern.

Namespace: Cognex.VisionPro.PMAlign
Assembly: Cognex.VisionPro.PMAlign (in Cognex.VisionPro.PMAlign.dll) Version: 69.0.0.0
Syntax

public ICogRegion TrainRegion { get; set; }

Property Value

Type: ICogRegion
Events

Remarks

Region of interest in the TrainImage that will be used to train the pattern. A NULL TrainRegion indicates that the entire TrainImage will be used to train the PMAlign pattern.

You can specify any type of region for the training region (CogRectangle, CogRectangleAffine, CogCircle, CogEllipse, and so on). If you specify a region type other than a Rectangle, the tool uses PatMax masking to train only the features within the specified region.

Note: This CogPMAlignPattern will sink changed events for the region that you supply. Whenever the region changes, this CogPMAlignPattern will become untrained.

Default Value: An CogRectangleAffine

Examples

Imports Cognex.VisionPro
Imports Cognex.VisionPro.PMAlign

Private myPattern As New CogPMAlignPattern
Private myParams As New CogPMAlignRunParams
Private myResults As CogPMAlignResults

Private Sub doTrain()


  myPattern.TrainAlgorithm = CogPMAlignTrainAlgorithmConstants.PatMaxAndPatQuick
  myPattern.TrainMode = CogPMAlignTrainModeConstants.Image

  myPattern.TrainImage = anImage
  myPattern.TrainRegion = trainRect
  myPattern.TrainRegionMode = CogRegionModeConstants.PixelAlignedBoundingBox
  myPattern.Origin.TranslationX = trainRect.CenterX
  myPattern.Origin.TranslationY = trainRect.CenterY



  myPattern.Train()
end sub
using Cognex.VisionPro;
using Cognex.VisionPro.PMAlign;

private CogPMAlignPattern myPattern = new CogPMAlignPattern();
private CogPMAlignRunParams myParams =new CogPMAlignRunParams();
private CogPMAlignResults myResults;

private void doTrain()
{

  myPattern.TrainAlgorithm = CogPMAlignTrainAlgorithmConstants.PatMaxAndPatQuick;
  myPattern.TrainMode = CogPMAlignTrainModeConstants.Image;


  myPattern.TrainImage = anImage;
  myPattern.TrainRegion = trainRect;
  myPattern.TrainRegionMode = CogRegionModeConstants.PixelAlignedBoundingBox;
  myPattern.Origin.TranslationX = trainRect.CenterX;
  myPattern.Origin.TranslationY = trainRect.CenterY;


  myPattern.Train();
}
See Also