ImageEn, unit ievision

TIEVisionBlobDetector


Declaration

TIEVisionBlobDetector = interface(TIEVisionBase)


Description

An interface to search for blobs/shapes in an image and return a list of keypoints for detected blobs.



Note: A shortcut method for this available: DetectBlobs


Demo

Demo  Demos\IEVision\BlobDetection\BlobDetection.dpr


Example

var
  detector: TIEVisionBlobDetector;
  keyPoints: TIEVisionVectorKeyPoint;
  kp: TIEVisionKeyPoint;
  i: integer;
  x1, y1, x2, y2: double;
begin
  detector := IEVisionLib().createBlobDetector();

  // Setup parameters
  detector.setThreshold( StrToFlt( EditThresholdMin.Text, 50), StrToFlt( EditThresholdMax.Text, 220), StrToFlt( EditThresholdStep.Text, 10 ));
  detector.setMinDistBetweenBlobs( StrToFlt( EditMinBlobDistance.Text, 10 ));
  detector.setFilterByGrayLevel( CheckBoxGrayLevelFilter.Checked, ComboBoxColorFilter.ItemIndex * 255 );
  detector.setFilterByArea( CheckBoxAreaFilter.Checked, StrToFlt( EditMinArea.Text, 25 ), StrToFlt( EditMaxArea.Text, 5000 ));
  detector.setFilterByCircularity( CheckBoxCircularityFilter.Checked, StrToFlt( EditMinCircularity.Text, 0.8 ), StrToFlt(EditMaxCircularity.Text, 3.4e+38 ));
  detector.setFilterByInertia( CheckBoxInertiaFilter.Checked, StrToFlt( EditMinInertia.Text, 0.1), StrToFlt( EditMaxInertia.Text, 3.4e+38 ));
  detector.setFilterByConvexity( CheckBoxConvexityFilter.Checked, StrToFlt( EditMinConvexity.Text, 0.95), StrToFlt( EditMaxConvexity.Text, 3.4e+38 ));

  keyPoints := detector.detect( ImageEnView1.IEBitmap.GetIEVisionImage() );

  lblCount.Caption := 'Count: ' + IntToStr( keyPoints.size() );
  for i := 0 to keyPoints.size() - 1 do
  begin
    kp := keyPoints.getKeyPoint(i);

    // Draw onto bitmap
    with ImageEnView1.IEBitmap.Canvas do
    begin
      Pen.Color := clRed;
      Pen.Width := 4;
      Brush.Style := bsClear;
      x1 := kp.pt.x - kp.size / 2;
      y1 := kp.pt.y - kp.size / 2;
      x2 := kp.pt.x + kp.size / 2;
      y2 := kp.pt.y + kp.size / 2;
      Ellipse( Round(x1), Round(y1), Round(x2), Round(y2));
    end;
  end;

  ImageEnView1.Update();
end;


Methods and Properties

Public Method  detect
Public Method  setFilterByArea
Public Method  setFilterByCircularity
Public Method  setFilterByConvexity
Public Method  setFilterByGrayLevel
Public Method  setFilterByInertia
Public Method  setMinDistBetweenBlobs
Public Method  setThreshold


See Also

createBlobDetector
DrawRects