ImageEn, unit ievision

TIEVisionBlobDetector


Declaration

TIEVisionBlobDetector = interface(TIEVisionBase)


Description

TIEVisionBlobDetector searches blobs/shapes in an image and return a list of keypoints which describe detected blobs.




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(XStrToFlt(EditThresholdMin.Text, 50), XStrToFlt(EditThresholdMax.Text, 220), XStrToFlt(EditThresholdStep.Text, 10));
  detector.setMinDistBetweenBlobs(XStrToFlt(EditMinBlobDistance.Text, 10));
  detector.setFilterByGrayLevel(CheckBoxGrayLevelFilter.Checked, ComboBoxColorFilter.ItemIndex * 255);
  detector.setFilterByArea(CheckBoxAreaFilter.Checked, XStrToFlt(EditMinArea.Text, 25), XStrToFlt(EditMaxArea.Text, 5000));
  detector.setFilterByCircularity(CheckBoxCircularityFilter.Checked, XStrToFlt(EditMinCircularity.Text, 0.8), XStrToFlt(EditMaxCircularity.Text, 3.4e+38));
  detector.setFilterByInertia(CheckBoxInertiaFilter.Checked, XStrToFlt(EditMinInertia.Text, 0.1), XStrToFlt(EditMaxInertia.Text, 3.4e+38));
  detector.setFilterByConvexity(CheckBoxConvexityFilter.Checked, XStrToFlt(EditMinConvexity.Text, 0.95), XStrToFlt(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

Public Method  createBlobDetector