我在图片中指定了问题。
谢谢..
Bitmap bitmap = (Bitmap)panel1.BackgroundImage;
BlobCounter blobCounter = new BlobCounter();
blobCounter.FilterBlobs = true;
blobCounter.MinHeight = 1;
blobCounter.MinWidth = 1;
blobCounter.ObjectsOrder = ObjectsOrder.Size;
blobCounter.ProcessImage(bitmap);
Pen yellowPen = new Pen(Color.Red, 6);
Graphics g = Graphics.FromImage(bitmap);
Blob[] blobs = blobCounter.GetObjectsInformation();
SimpleShapeChecker shapeChecker = new SimpleShapeChecker();
foreach (var blob in blobs)
{
List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blob);
List<IntPoint> cornerPoints;
if (shapeChecker.IsQuadrilateral(edgePoints, out cornerPoints))
{
if (shapeChecker.CheckPolygonSubType(cornerPoints) == PolygonSubType.RectangledTriangle)
{
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));
}
g.DrawPolygon(new Pen(Color.Red, 5.0f), Points.ToArray());
bitmap.Save(@"C:\Users\OkanBerk\Desktop\result.png");
}
}
}
panel1.BackgroundImage = bitmap;
panel1.Invalidate();