private void check_Click(object sender, EventArgs e) { // locate objects using blob counter BlobCounter blobCounter = new BlobCounter(); blobCounter.ProcessImage((Bitmap)PictureBox1.Image); Blob[] blobs = blobCounter.GetObjectsInformation(); // create Graphics object to draw on the image and a pen Graphics g = Graphics.FromImage((Bitmap)TargetPic.Image); Pen redPen = new Pen(Color.Red, 2); // check each object and draw circle around objects, which // are recognized as circles for (int i = 0, n = blobs.Length; i < n; i++) { List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blob[i]); AForge.Point center; float radius; if (shapeChecker.IsCircle(edgePoints, out center, out radius)) { g.DrawEllipse(redPen, (int)(center.X - radius), (int)(center.Y - radius), (int)(radius * 2), (int)(radius * 2)); } } redPen.Dispose(); g.Dispose(); }
shapeChecker
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)