当前位置: 首页>>代码示例>>C#>>正文


C# BlobCounter.GetBlobsTopAndBottomEdges方法代码示例

本文整理汇总了C#中AForge.Imaging.BlobCounter.GetBlobsTopAndBottomEdges方法的典型用法代码示例。如果您正苦于以下问题:C# BlobCounter.GetBlobsTopAndBottomEdges方法的具体用法?C# BlobCounter.GetBlobsTopAndBottomEdges怎么用?C# BlobCounter.GetBlobsTopAndBottomEdges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AForge.Imaging.BlobCounter的用法示例。


在下文中一共展示了BlobCounter.GetBlobsTopAndBottomEdges方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: detectionGlyph

        public double[] detectionGlyph(bool CalculTailleTerrain)
        {
            bool Trouve = false;
            double[] ratio = new double[2] { 0, 0 };
            SimpleShapeChecker shapeChecker = new SimpleShapeChecker();
            BlobCounter blobCounter = new BlobCounter();

            blobCounter.MinHeight = 23;
            blobCounter.MinWidth = 23;
            blobCounter.FilterBlobs = true;
            blobCounter.ObjectsOrder = ObjectsOrder.Size;

            // 4 - find all stand alone blobs
            blobCounter.ProcessImage(imgContour);
            Blob[] blobs = blobCounter.GetObjectsInformation();

            // 5 - check each blob
            for (int i = 0, n = blobs.Length; i < n; i++)
            {
                List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]);
                List<IntPoint> corners = null;

                // Test de la forme selectionnée
                if (shapeChecker.IsQuadrilateral(edgePoints, out corners))
                {
                    // Détection des points de coutour
                    List<IntPoint> leftEdgePoints, rightEdgePoints, topEdgePoints, bottomEdgePoints;

                    Line Horizontale = Line.FromPoints(new IntPoint(0,0),new IntPoint(10,0));
                    blobCounter.GetBlobsLeftAndRightEdges(blobs[i], out leftEdgePoints, out rightEdgePoints);
                    blobCounter.GetBlobsTopAndBottomEdges(blobs[i], out topEdgePoints, out bottomEdgePoints);

                    // calculate average difference between pixel values from outside of the
                    // shape and from inside
                    float diff = CalculateAverageEdgesBrightnessDifference(leftEdgePoints, rightEdgePoints, imgNB);
                    // check average difference, which tells how much outside is lighter than
                    // inside on the average
                    if (diff > 20)
                    {
                        // Transformation de l'image reçu en un carré pour la reconnaissance
                        QuadrilateralTransformation quadrilateralTransformation = new QuadrilateralTransformation(corners, 60, 60);
                        UnmanagedImage glyphImage = quadrilateralTransformation.Apply(imgNB);

                        // Filtre de contraste
                        OtsuThreshold otsuThresholdFilter = new OtsuThreshold();
                        otsuThresholdFilter.ApplyInPlace(glyphImage);
                        imgContour = glyphImage;
                        // Reconnaissance du Glyph
                        Glyph Gl = new Glyph(glyphImage, GlyphSize);

                        Gl.ReconnaissanceGlyph(corners, imgNB);

                        // Si le Glyph est valide
                        if (Gl.getIdentifiant() > 0)
                        {
                            if (AutAffichage[0])
                            {
                                // Coloration des contours des zones détectées
                                UnImgReel.SetPixels(leftEdgePoints, Color.Red);
                                UnImgReel.SetPixels(rightEdgePoints, Color.Red);
                                UnImgReel.SetPixels(topEdgePoints, Color.Red);
                                UnImgReel.SetPixels(bottomEdgePoints, Color.Red);
                            }

                            // Détection du milieu
                            Line line = Line.FromPoints(corners[0], corners[2]);
                            Line line2 = Line.FromPoints(corners[1], corners[3]);
                            IntPoint intersection = (IntPoint)line.GetIntersectionWith(line2);
                            if (AutAffichage[1])
                            {
                                dessinePoint(intersection, UnImgReel, 4, Color.Yellow);
                            }

                            // Calcul de la rotation
                            Line ComparasionAngle = Line.FromPoints(corners[0], corners[1]);
                            Double rotation = (int) ComparasionAngle.GetAngleBetweenLines(Horizontale);
                            rotation += 90 * Gl.getNbRotation();
                            Gl.rotation = 360 - rotation;
                            rotation *= (Math.PI / 180.0);

                            // Calcul d'un point en bout de pince
                            float Taille = corners[0].DistanceTo(corners[1]);

                            float taille = (Taille / BibliotequeGlyph.Biblioteque[Gl.getPosition()].taille) * BibliotequeGlyph.Biblioteque[Gl.getPosition()].DistancePince;
                            int x = -(int)(System.Math.Sin(rotation) * taille);
                            int y = -(int)(System.Math.Cos(rotation) * taille);
                            x += (int)intersection.X;
                            y += (int)intersection.Y;
                            Gl.Position = new int[2]{x,y};
                            if (AutAffichage[2])
                            {
                                dessinePoint(new IntPoint(x, y), UnImgReel, 4, Color.Cyan);
                            }
                            imgContour = Gl.getImage();
                            addGlyph(Gl);

                            if (CalculTailleTerrain == true && Trouve == false)
                            {
                                Trouve = true;
                                int tailleglyph = BibliotequeGlyph.Biblioteque[Gl.getPosition()].taille;
//.........这里部分代码省略.........
开发者ID:KiLMaN,项目名称:LPIE_Robot_Color,代码行数:101,代码来源:ImgWebCam.cs

示例2: process

        //functions
        public void process()
        {
            while (true)
            {
                FeatureExtracting.Notifier.WaitOne();
                foreach (Bitmap image in queue.GetConsumingEnumerable())
                {

                    BlobCounter bc = new BlobCounter();
                    bc.MinWidth = 5;
                    bc.MinHeight = 5;
                    bc.FilterBlobs = true;
                    bc.ObjectsOrder = ObjectsOrder.Size;
                    bc.ProcessImage(image);
                    Rectangle[] rects = bc.GetObjectsRectangles();
                    Rectangle biggest = new Rectangle(0, 0, 0, 0);
                    Graphics g = Graphics.FromImage(image);
                    //double ratio = 0;

            foreach (Blob blob in bc.GetObjectsInformation())
            {
             List<IntPoint> edgePoints = bc.GetBlobsEdgePoints(blob);
             List<IntPoint> top;
             List<IntPoint> bottom;
             bc.GetBlobsTopAndBottomEdges(blob, out top, out bottom);

            }

                    foreach (Rectangle r in rects)
                    {

                        biggest = rects[0];
                        g.DrawRectangle(new Pen(Color.Green, 3), r);
                    }

                    int objectCeter = 0;
                    if (biggest.Width > 70)
                    {
                        objectCeter = (((biggest.Width / 2) + biggest.X) - image.Width / 2);
                    }

                    g.DrawRectangle(new Pen(Color.Blue), biggest);

                    if (biggest.Height < 20)
                    {

                    }

                    string drawString = biggest.Height + " <-- Height    Width --> " + biggest.Width + "\n Image Center = " + objectCeter;
                    System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 8);
                    System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
                    float x = 10.0F;
                    float y = 10.0F;
                    System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
                    g.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
                    drawFont.Dispose();
                    drawBrush.Dispose();
                    //Merge a = new Merge(image);
                    // Program.mainForm.VideoViewer.Image = a.Apply(crop.Apply(this.Camera.Image));

                    Stats a = new Stats();
                    a.blobCount = 0;
                    ActionPlanning.queue.Add(a);
                    ActionPlanning.Notifier.Set();

                    #if DEBUG
                    Program.mainForm.VideoViewer.Image = image;
                    #endif
                }
            }
        }
开发者ID:pet1330,项目名称:RovioAssignment,代码行数:72,代码来源:FeatureExtracting.cs


注:本文中的AForge.Imaging.BlobCounter.GetBlobsTopAndBottomEdges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。