public static void DebugDrawBlobs(Bitmap debugBitmap, FoundBlobs foundBlobs) { using (Graphics g = Graphics.FromImage(debugBitmap)) { foreach (Blob blob in foundBlobs.Blobs) { g.DrawRectangle(new Pen(Brushes.Red, 3), blob.Rectangle); } } }
public static FoundBlobs FindAny(FoundColorSpaces colorSpaces) { FoundBlobs foundBlobs = new FoundBlobs(); SobelEdgeDetector edge = new SobelEdgeDetector(); Bitmap edges = edge.Apply(colorSpaces.GrayColorSpace); Threshold threshold = new Threshold(50); threshold.ApplyInPlace(edges); BlobCounter blobCounter = new BlobCounter(); blobCounter.ProcessImage(edges); foundBlobs.Blobs = blobCounter.GetObjects(colorSpaces.GrayColorSpace, false).ToArray(); foundBlobs.BlobCounter = blobCounter; return foundBlobs; }