CogPMAlignPattern Trained Property Cognex VisionPro 9.20
True if the pattern is trained.

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

public bool Trained { get; }

Property Value

Type: Boolean
Remarks

True if the pattern is trained.

Examples

Imports Cognex.VisionPro
Imports Cognex.VisionPro.PMAlign


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


Private Sub doSearch()
    Dim i As Integer
    Dim cross As CogPointMarker


    myParams.ApproximateNumberToFind = 4
    myParams.AcceptThreshold = 0.5
    myParams.RunAlgorithm = CogPMAlignRunAlgorithmConstants.BestTrained

    myParams.ZoneAngle.Configuration = CogPMAlignZoneConstants.LowHigh
    myParams.ZoneAngle.High = Math.PI / 8
    myParams.ZoneAngle.Low = -(Math.PI / 4)

    myParams.ZoneScale.Configuration = CogPMAlignZoneConstants.LowHigh
    myParams.ZoneScale.High = 1.3
    myParams.ZoneScale.Low = 0.75


    If Not myPattern.Trained Then
        MsgBox("The pattern is not trained")
        Exit Sub
    End If

    myResults = myPattern.Execute(anImage, Nothing, myParams)

    For i = 0 To myResults.Count - 1
        cross = New CogPointMarker
        cross.Interactive = True
        cross.X = myResults.Item(i).GetPose.TranslationX
        cross.Y = myResults.Item(i).GetPose.TranslationY
        cross.TipText = "result " & myResults.Item(i).ID & ": " & myResults.Item(i).Score
        If myResults.Item(i).Accepted Then
            cross.Color = CogColorConstants.Green
        Else
            cross.Color = CogColorConstants.Red
        End If

        CogDisplay1.InteractiveGraphics.Add(cross, "crosses", False)
    Next

    CogDisplay1.InteractiveGraphicTipsEnabled = True
End Sub
using Cognex.VisionPro;
using Cognex.VisionPro.PMAlign;

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

private void doSearch()
{
  int i=0;
  CogPointMarker cross; 


  myParams.ApproximateNumberToFind = 4;
  myParams.AcceptThreshold = 0.5;
  myParams.RunAlgorithm = CogPMAlignRunAlgorithmConstants.BestTrained;

  myParams.ZoneAngle.Configuration = CogPMAlignZoneConstants.LowHigh;
  myParams.ZoneAngle.High = Math.PI / 8;
  myParams.ZoneAngle.Low = -(Math.PI / 4);

  myParams.ZoneScale.Configuration = CogPMAlignZoneConstants.LowHigh;
  myParams.ZoneScale.High = 1.3;
  myParams.ZoneScale.Low = 0.75;


  if ( !myPattern.Trained ) 
  {
    MessageBox.Show("The pattern is not trained");
    return;     
  }

  myResults = myPattern.Execute(anImage, null, myParams);

  for( i=0; i < myResults.Count; i++ )
  {
    cross = new CogPointMarker();
    cross.Interactive = true;
    cross.X = myResults[i].GetPose().TranslationX;
    cross.Y = myResults[i].GetPose().TranslationY;
    cross.TipText = "result " + myResults[i].ID + ": " + myResults[i].Score;
    if ( myResults[i].Accepted )
      cross.Color = CogColorConstants.Green;
    else
      cross.Color = CogColorConstants.Red;

    CogDisplay1.InteractiveGraphics.Add(cross, "crosses", false);
  }
  CogDisplay1.InteractiveGraphicTipsEnabled = true;

}
See Also