I've discovered AForge.net recently because I'm trying to create a basic license plate reader from photo.
I've take this code but reds points are only around the photo.
My code :
- Code: Select all
BlobCounter blobCounter = new BlobCounter();
blobCounter.FilterBlobs = true;
blobCounter.MinHeight = 5;
blobCounter.MinWidth = 5;
blobCounter.ObjectsOrder = AForge.Imaging.ObjectsOrder.Size;
blobCounter.ProcessImage(bmp);
AForge.Imaging.Blob[] blobs = blobCounter.GetObjectsInformation();
//Bitmap.UnlockBits(bmp.LockBits());
blobCounter.ProcessImage(bmp);
blobs = blobCounter.GetObjectsInformation();
// check for rectangles
AForge.Math.Geometry.SimpleShapeChecker shapeChecker = new AForge.Math.Geometry.SimpleShapeChecker();
foreach (var blob in blobs)
{
List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blob);
List<IntPoint> cornerPoints;
// use the shape checker to extract the corner points
if (shapeChecker.IsQuadrilateral(edgePoints, out cornerPoints))
{
// only do things if the corners form a rectangle
if (shapeChecker.CheckPolygonSubType(cornerPoints) == AForge.Math.Geometry.PolygonSubType.Rectangle)
{
// here i use the graphics class to draw an overlay, but you
// could also just use the cornerPoints list to calculate your
// x, y, width, height values.
List<System.Drawing.Point> Points = new List<System.Drawing.Point>();
foreach (var point in cornerPoints)
{
Points.Add(new System.Drawing.Point(point.X, point.Y));
}
Graphics g = Graphics.FromImage(bmp);
g.DrawPolygon(new Pen(Color.Red, 5.0f), Points.ToArray());
bmp.Save(@"D:\devs\abc\lpr\result.jpg");
}
}
}
Found here : http://stackoverflow.com/questions/5945 ... s-in-image
Result :

How can I isolate the license plate? And why my code is only coloring in red around my photo?
Thanks