0

http://img5.imageshack.us/img5/3315/yenidusuk100003.jpg

如何使用 Aforge 或任何 c# 库在上图中找到矩形的坐标?

我努力了。但它太慢了。

并且这些矩形的位置和大小是静态的。

我找到了以下代码。但不能得到任何结果。

Bitmap image = sourceImage; //(Bitmap)Bitmap.FromFile(path);


     BlobCounter blobCounter = new BlobCounter();

     blobCounter.FilterBlobs = true;
     blobCounter.MinHeight = 1;
     blobCounter.MinWidth = 1;

     blobCounter.ProcessImage(image);
     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.Rectangle)
             {

                 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(image);
                 g.DrawPolygon(new Pen(Color.Red, 5.0f), Points.ToArray());

                 image.Save("result.png");
             }
         }
     }
4

0 回答 0