我找不到光学表格条(A-Forge)

时间:2016-12-07 13:21:27

标签: c# emgucv image-recognition aforge

我是这样写的,但矩形条没有出现。我该如何检测这些条形图?

我在图片中指定了问题。

谢谢..

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();

https://i.stack.imgur.com/PM4mj.jpg

0 个答案:

没有答案