CogBlobMeasure Mode Property Cognex VisionPro
Mode indicating how the specified measure will be used during execution of blob analysis. It may indicate no special run- time usage, the measure is to be used as a filter criterion, or that the measure will be computed at run-time.

Namespace: Cognex.VisionPro.Blob
Assembly: Cognex.VisionPro.Blob (in Cognex.VisionPro.Blob.dll) Version: 65.1.0.0
Syntax

public CogBlobMeasureModeConstants Mode { get; set; }

Property Value

Type: CogBlobMeasureModeConstants
The default is PreCompute.
Events

Event TypeReason
ICogChangedEvent Changed

Fires when the value of this property changes.

The following state flag may be affected:

Exceptions

ExceptionCondition
ArgumentException The supplied value is not a member of CogBlobMeasureModeConstants
Remarks

Mode that indicates how the measure is used during execution of blob analysis.

If this property is None, no run-time action is taken regarding the measure. If this property is Filter, then the values specified for FilterMode, FilterRangeLow, and FilterRangeHigh are used to filter blobs at run time. If this property is PreCompute, then the specified measure is computed at run-time for all blobs in the image.

Note that by default, blob measures are only computed when your program specifically requests them. Specifying PreCompute forces the tool to compute the specified measure for all blobs at once, making it easier to determine how much time blob analysis requires during your program's operation.

Examples

Imports Cognex.VisionPro
Imports Cognex.VisionPro.Blob

Dim myBlob As New CogBlob
Dim myAreaMeasure As New CogBlobMeasure
Dim myPerimeterMeasure As New CogBlobMeasure
Dim myBlobResults As CogBlobResults

Try
  ' Find all blobs with an area greater than 10 and' a perimeter greater than 100 pixels
  myAreaMeasure.Measure = CogBlobMeasureConstants.Area
  myAreaMeasure.FilterMode = CogBlobFilterModeConstants.IncludeBlobsInRange
  myAreaMeasure.FilterRangeLow = 10
  myAreaMeasure.FilterRangeHigh = 500000
  myAreaMeasure.Mode = CogBlobMeasureModeConstants.Filter

  myPerimeterMeasure.Measure = CogBlobMeasureConstants.Perimeter
  myPerimeterMeasure.FilterMode = CogBlobFilterModeConstants.IncludeBlobsInRange
  myPerimeterMeasure.FilterRangeLow = 100
  myPerimeterMeasure.FilterRangeHigh = 500000
  myPerimeterMeasure.Mode = CogBlobMeasureModeConstants.Filter
  myBlob.RunTimeMeasures.Add(myAreaMeasure)
  myBlob.RunTimeMeasures.Add(myPerimeterMeasure)

  myBlob.ConnectivityCleanup = CogBlobConnectivityCleanupConstants.Fill
  myBlob.SegmentationParams.Mode = CogBlobSegmentationModeConstants.HardDynamicThreshold
  myBlob.MorphologyOperations.Add(CogBlobMorphologyConstants.CloseSquare)
  ' mobjImage is an acquired image
  myBlobResults = myBlob.Execute(mobjImage, r)
  Debug.WriteLine(myBlobResults.GetBlobs.Count.ToString)
  Dim aResult As CogBlobResult
  Dim avgArea As Double
  For Each aResult In myBlobResults.GetBlobs
    avgArea = avgArea + aResult.Area
  Next

  avgArea = avgArea / myBlobResults.GetBlobs.Count
  Debug.WriteLine(" AvgArea:" + avgArea.ToString)

Catch ex As Exception
  Debug.WriteLine("Following Error Occurred:" + ex.Message)

End Try
using Cognex.VisionPro; 
using Cognex.VisionPro.Blob;

private void doBlob()
{
  CogBlob myBlob=new CogBlob(); 
  CogBlobMeasure myAreaMeasure=new CogBlobMeasure();  
  CogBlobMeasure myPerimeterMeasure=new CogBlobMeasure(); 
  CogBlobResults myBlobResults; 
  Double avgArea=0;
  try
{
  // Find all blobs with an area greater than 10 and' a perimeter greater than 100 pixels
  myAreaMeasure.Measure = CogBlobMeasureConstants.Area;
  myAreaMeasure.FilterMode = CogBlobFilterModeConstants.IncludeBlobsInRange;
  myAreaMeasure.FilterRangeLow = 10;
  myAreaMeasure.FilterRangeHigh = 500000;
  myAreaMeasure.Mode = CogBlobMeasureModeConstants.Filter;

  myPerimeterMeasure.Measure = CogBlobMeasureConstants.Perimeter;
  myPerimeterMeasure.FilterMode = CogBlobFilterModeConstants.IncludeBlobsInRange;
  myPerimeterMeasure.FilterRangeLow = 100;
  myPerimeterMeasure.FilterRangeHigh = 500000;
  myPerimeterMeasure.Mode = CogBlobMeasureModeConstants.Filter;
  myBlob.RunTimeMeasures.Add(myAreaMeasure);
  myBlob.RunTimeMeasures.Add(myPerimeterMeasure);

  myBlob.ConnectivityCleanup = CogBlobConnectivityCleanupConstants.Fill;
  myBlob.SegmentationParams.Mode = CogBlobSegmentationModeConstants.HardDynamicThreshold;
  myBlob.MorphologyOperations.Add(CogBlobMorphologyConstants.CloseSquare);
  // mobjImage is an acquired image
  myBlobResults = myBlob.Execute(mobjImage, r);
  Debug.WriteLine(myBlobResults.GetBlobs(true).Count.ToString());

  foreach (CogBlobResult aResult in myBlobResults.GetBlobs(true))
  {
    avgArea = avgArea + aResult.Area;
  }

  avgArea =avgArea / myBlobResults.GetBlobs(true).Count;
  Debug.WriteLine(" AvgArea:" + avgArea.ToString());
}
  catch (System.Exception ex)
  {
    Debug.WriteLine("Following Error Occurred:" + ex.Message);
  }


}
See Also