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 | Demos\IEVision\BlobDetection\BlobDetection.dpr |
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;
See Also
◼createBlobDetector◼DrawRects