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


C# BlobCounter.GetObjectsRectangles方法代码示例

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


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

示例1: getImageColor

        public List<video.VideoProg.Cub> getImageColor(List<HSLFiltering> lst)
        {
            UnmanagedImage tmpCol = null;
            List<video.VideoProg.Cub> tmp = new List<video.VideoProg.Cub>();
            for(int i = 0; i < lst.Count;i++)
            {
                HSLFiltering Filter = lst[i];
                tmpCol = ImgColor.Clone();
                Filter.ApplyInPlace(tmpCol);

                // create blob counter and configure it
                BlobCounter blobCounter1 = new BlobCounter();
                blobCounter1.MinWidth = 15;                    // set minimum size of
                blobCounter1.MinHeight = 15;                   // objects we look for
                blobCounter1.FilterBlobs = true;               // filter blobs by size
                blobCounter1.ObjectsOrder = ObjectsOrder.Size; // order found object by size

                blobCounter1.ProcessImage(tmpCol);
                //Rectangle[] rects = DeleteRectInterne( blobCounter1.GetObjectsRectangles());
                Rectangle[] rects = blobCounter1.GetObjectsRectangles();
                // draw rectangle around the biggest blob
                for (int j = 0; j < rects.Length; j++)
                {
                    if (rects[j] == null)
                        break;
                    tmp.Add(new video.VideoProg.Cub(rects[j],i));
                }
            }
            ImgColor = tmpCol;
            return tmp;
        }
开发者ID:KiLMaN,项目名称:LPIE_Robot_Color,代码行数:31,代码来源:ImgWebCam.cs

示例2: TemplateColorTracking

        /// <summary>
        /// Get rectangle contain object in current frame
        /// </summary>
        /// <param name="templateInfo">Tracking template information</param>
        /// <param name="source">Frame</param>
        /// <returns>Rectangle contain object</returns>
        public static Rectangle TemplateColorTracking(ImageStatistics templateInfo, ref UnmanagedImage source)
        {
            UnmanagedImage image = source.Clone();
            // create filter
            EuclideanColorFiltering filter = new EuclideanColorFiltering();
            // set center colol and radius
            filter.CenterColor = new RGB(
                (byte)templateInfo.Red.Mean,
                (byte)templateInfo.Green.Mean,
                (byte)templateInfo.Blue.Mean);
            filter.Radius = 30;
            // apply the filter
            filter.ApplyInPlace(image);

            image = Grayscale.CommonAlgorithms.BT709.Apply(image);

            OtsuThreshold threshold = new OtsuThreshold();
            threshold.ApplyInPlace(image);

            BlobCounter blobCounter = new BlobCounter();
            blobCounter.ObjectsOrder = ObjectsOrder.Size;
            blobCounter.ProcessImage(image);

            Rectangle rect = blobCounter.ObjectsCount > 0 ? blobCounter.GetObjectsRectangles()[0] : Rectangle.Empty;
            return rect;
        }
开发者ID:pinkuyt,项目名称:a-pod-project-team-3,代码行数:32,代码来源:ObjectDetector.cs

示例3: FinalVideo_NewFrame

 void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
 {
     Icon newIcon = new Icon(@"c:\users\gregster\documents\visual studio 2012\Projects\WebCamTrack\WebCamTrack\bin\Debug\favicon.ico");
     BlobCounter bc = new BlobCounter();
     EuclideanColorFiltering filter = new EuclideanColorFiltering();
     Bitmap video = (Bitmap)eventArgs.Frame.Clone();//sem filtro
     Bitmap video1 = (Bitmap)eventArgs.Frame.Clone();// imagem com filtro
     //
     filter.CenterColor = new RGB(0, 0, 0);
     filter.Radius = 100;
     filter.ApplyInPlace(video1);//aplicando o filtro
     bc.MinWidth = 5;
     bc.MinHeight = 5;
     bc.FilterBlobs = true;
     //  bc.ObjectsOrder = ObjectsOrder.Size;
     bc.ProcessImage(video1);// processando a imagem que ja foi filtrada para identificar objetos
     Rectangle[] rects = bc.GetObjectsRectangles();
     foreach (Rectangle recs in rects)
         if (rects.Length > 0)
         {
             Rectangle objectRect = rects[0];
             Graphics g = Graphics.FromImage(video);//identificar objetos a partir da imagem com filtro
             Graphics h = Graphics.FromImage(video1);
             using (Pen pen = new Pen(Color.FromArgb(160, 255, 160), 5))
             {
                 g.DrawIcon(newIcon, objectRect);
                // g.DrawRectangle(pen, objectRect);
                 h.DrawRectangle(pen, objectRect);
             }
             g.Dispose();
             h.Dispose();
         }
     pictureBox1.Image = video;
     pictureBox2.Image = video1;
 }
开发者ID:GustavoGregorio,项目名称:Projetos-pessoais,代码行数:35,代码来源:Form1.cs

示例4: blob_setter

        public static void blob_setter(Bitmap video , Bitmap grayImage , int height , int width)
        {
            BlobCounter blobCounter = new BlobCounter();
            // configure it to filter out small objects
            blobCounter.MinWidth = width;
            blobCounter.MinHeight = height;
             //       blobCounter.FilterBlobs = true;
            // set ordering - bigger objects go first
            blobCounter.ObjectsOrder = ObjectsOrder.Size;
            // locate blobs
            blobCounter.ProcessImage(grayImage);
            Rectangle[] rects = blobCounter.GetObjectsRectangles();

            foreach (Rectangle recs in rects)
                if (rects.Length > 0)
                {
                    Rectangle objectRect = rects[0];
                    Graphics g = Graphics.FromImage(video);
                    using (Pen pen = new Pen(Color.FromArgb(160, 255, 160), 3))
                    {
                        g.DrawRectangle(pen, objectRect);
                    }
                    g.Dispose();
                }
        }
开发者ID:Rohail1,项目名称:OOP-Project,代码行数:25,代码来源:Blob+Detection.cs

示例5: GetRedBlobCenter

        public static AForge.Point GetRedBlobCenter(Bitmap image)
        {
            BlobCounter bCounter = new BlobCounter();
            bCounter.ProcessImage(image);

            Blob[] blobs = bCounter.GetObjectsInformation();
            Rectangle[] rects = bCounter.GetObjectsRectangles();

            Pen pen = new Pen(Color.Red, 2);
            Brush brush = new SolidBrush(Color.Red);
            Graphics g = Graphics.FromImage(image);

            if (rects.Length > 0) { g.FillRectangle(brush, rects[0]); }

            if (blobs.Length > 0)
            {

                detected = true;
                lastPos = blobs[0].CenterOfGravity;

                AForge.Point rPos = new AForge.Point();
                rPos.Y = ((lastPos.Y / 5) / 100) * 768;
                rPos.X = ((lastPos.X / 5) / 100) * 1366;

                return rPos;
            }
            else
            {
                detected = false;
                if (lastPos != null)
                {
                    return lastPos;
                }
                else
                {
                    return new AForge.Point(50.0f, 50.0f);
                }
            }
        }
开发者ID:Cosmin-Parvulescu,项目名称:Kamaus,代码行数:39,代码来源:BlobDetector.cs

示例6: RgrectBobberCandidate

        private List<Rectangle> RgrectBobberCandidate(Bitmap imgBefore, Bitmap imgAfter)
        {
            var img = XXX(imgBefore, imgAfter);
            var blobCounter = new BlobCounter();
            blobCounter.ProcessImage(img);

            return blobCounter.GetObjectsRectangles().ToList();
        }
开发者ID:encse,项目名称:horgaszbot,代码行数:8,代码来源:MainWindow.xaml.cs

示例7: ProcessImage

        private void ProcessImage()
        {
            m_selectedBlobs.Clear();
            pictureBox1.Controls.Clear();
            pictureBox1.Image = null;

            if (m_original != null)
                m_original.Dispose();
            if (m_binarized != null)
                m_binarized.Dispose();

            m_original = new Bitmap(txtFile.Text);

            // create grayscale filter (BT709)
            Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);
            m_binarized = filter.Apply(m_original);

            // Binarize Picture.
            Threshold bin = new Threshold((int)txtBinThershold.Value);
            bin.ApplyInPlace(m_binarized);

            // create filter
            Invert inv = new Invert();
            inv.ApplyInPlace(m_binarized);

            // create an instance of blob counter algorithm
            BlobCounter bc = new BlobCounter();
            bc.ObjectsOrder = ObjectsOrder.XY;
            bc.ProcessImage(m_binarized);
            Rectangle[] blobsRect = bc.GetObjectsRectangles();
            Dictionary<int, List<Rectangle>> orderedBlobs = ReorderBlobs(blobsRect);

            foreach (KeyValuePair<int, List<Rectangle>> orderedBlob in orderedBlobs)
            {
                orderedBlob.Value.ForEach(r => AddBlobPanel(orderedBlob.Key, r));
            }

            pictureBox1.Image = chkShowBinarize.Checked ? m_binarized : m_original;

            pictureBox1.Invalidate();
        }
开发者ID:hongzuL,项目名称:ml-ocr-tool,代码行数:41,代码来源:OCRTool.cs

示例8: 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

示例9: VideoSourcePlayerNewFrame

        void VideoSourcePlayerNewFrame(object sender, ref Bitmap image)
        {
            lock (this)
            {
                Bitmap img_copy = new Bitmap(image);
                Grayscale gray_filter = new Grayscale(0.2125, 0.7154, 0.0721);
                img_copy = gray_filter.Apply(img_copy);
                Threshold thresh = new Threshold(thresh_val);
                img_copy = thresh.Apply(img_copy);
                BlobCounter bc = new BlobCounter();
                bc.FilterBlobs = true;
                bc.MinHeight = min_size_val;
                bc.MinWidth = min_size_val;
                bc.MaxHeight = min_size_val + 50;
                bc.MaxWidth = min_size_val + 50;
                bc.ProcessImage(img_copy);
                Rectangle[] rects = bc.GetObjectsRectangles();

                Graphics g = videoSourcePlayer.CreateGraphics();
                using (Pen p = new Pen(Color.Red))
                {
                    foreach (Rectangle r in rects)
                    {
                        g.DrawRectangle(p,r);
                        g.DrawString("a",new Font("Consolas",10),Brushes.Red,r.X,r.Y);
                    }
                }
                image = img_copy;
            }
        }
开发者ID:jotux,项目名称:ObjectDetect,代码行数:30,代码来源:MainForm.cs

示例10: traitementimage

        private void traitementimage(ref Bitmap image)
        {

            ColorFiltering filter = new ColorFiltering();
            filter.Red = new IntRange(254, 255);
            filter.Green = new IntRange(0, 240);
            filter.Blue = new IntRange(0, 240);
            Bitmap tmp = filter.Apply(image);
            IFilter grayscale = new GrayscaleBT709();
            tmp = grayscale.Apply(tmp);
            BitmapData bitmapData = tmp.LockBits(new Rectangle(0, 0, image.Width, image.Height),
            ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
            BlobCounter blobCounter = new BlobCounter();
            blobCounter.ProcessImage(bitmapData);
            blobCounter.ObjectsOrder = ObjectsOrder.Size;
            Rectangle[] rects = blobCounter.GetObjectsRectangles();
            tmp.UnlockBits(bitmapData);
            tmp.Dispose();
            if (rects.Length != 0)
            {
                backpoint = Centre(rects[0]);
                lignes(ref image, backpoint);

            }

        }
开发者ID:jalelderbali,项目名称:robotsoft-v1.0,代码行数:26,代码来源:Form1.cs

示例11: FinalVideo_NewFrame2

        void FinalVideo_NewFrame2(object sender, NewFrameEventArgs eventArgs)
        {
            Icon newIcon = new Icon(@"c:\users\gregster\documents\visual studio 2012\Projects\WebCamTrack\WebCamTrack\bin\Debug\Aqua-Ball-Red-icon.ico");
            BlobCounter bc = new BlobCounter();
            EuclideanColorFiltering filter = new EuclideanColorFiltering();
            Bitmap video = (Bitmap)eventArgs.Frame.Clone();//sem filtro
            Bitmap video1 = (Bitmap)eventArgs.Frame.Clone();// imagem com filtro
            //
            filter.CenterColor = new RGB(10, 10, 10);
            filter.Radius = 20;
            filter.ApplyInPlace(video1);//aplicando o filtro
            bc.MinWidth = 12;
            bc.MinHeight = 12;
            bc.FilterBlobs = true;
            //  bc.ObjectsOrder = ObjectsOrder.Size;
            bc.ProcessImage(video1);// processando a imagem que ja foi filtrada para identificar objetos
            Rectangle[] rects = bc.GetObjectsRectangles();
            foreach (Rectangle recs in rects)
                if (rects.Length > 0)
                {

                    foreach (Rectangle objectRect in rects)
                    {

                        Graphics g = Graphics.FromImage(video);//Desenhar quadrado em frente da imagem
                        Graphics i = Graphics.FromImage(video);
                        Graphics h = Graphics.FromImage(video1);
                        if (objectRect.Width < 50 && objectRect.Height < 50)
                        {
                            count = count + 1;
                        }

                        using (Pen pen = new Pen(Color.FromArgb(160, 255, 160), 5))
                        {
                            g.DrawIcon(newIcon, objectRect);
                            h.DrawRectangle(pen, objectRect);

                        }
                        string strNumber = Convert.ToString(count);
                        // Create font and brush.
                        Font drawFont = new Font("Arial", 16);
                        SolidBrush drawBrush = new SolidBrush(Color.Black);
                        // Create point for upper-left corner of drawing.
                        PointF drawPoint = new PointF(150.0F, 150.0F);
                        // Draw string to screen.
                        i.DrawString(strNumber, drawFont, drawBrush, drawPoint);

                        i.Dispose();
                        g.Dispose();
                        h.Dispose();
                    }
                }
            pictureBox1.Image = video;
            pictureBox2.Image = video1;
        }
开发者ID:GustavoGregorio,项目名称:Projetos-pessoais,代码行数:55,代码来源:Form1.cs

示例12: Video_NewFrame

        public void Video_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            UnmanagedImage image = UnmanagedImage.FromManagedImage((Bitmap) eventArgs.Frame.Clone());

            var extractChannel = new ExtractChannel(RGB.R);
            UnmanagedImage channel = extractChannel.Apply(image);
            //		UnmanagedImage originalRed = channel.Clone();
            if (true) {
                var threshold = new Threshold(200);
                threshold.ApplyInPlace(channel);

                ////filter to convert RGB image to 8bpp gray scale for image processing
                //IFilter gray_filter = new GrayscaleBT709();
                //gray_image = gray_filter.Apply(gray_image);

                ////thresholding a image
                //Threshold th_filter = new Threshold(color_data.threshold);
                //th_filter.ApplyInPlace(gray_image);

                //erosion filter to filter out small unwanted pixels
                Erosion3x3 erosion = new Erosion3x3();
                erosion.ApplyInPlace(channel);

                //dilation filter
                //Dilatation3x3 dilatation = new Dilatation3x3();
                //dilatation.ApplyInPlace(channel);

                //GrayscaleToRGB filter = new GrayscaleToRGB();
                //image = filter.Apply(channel);

                //ReplaceChannel replaceFilter = new ReplaceChannel(RGB.B, channel);
                //replaceFilter.ApplyInPlace(image);
            }

            BlobCounter bc = new BlobCounter();
            //arrange blobs by area
            bc.ObjectsOrder = ObjectsOrder.Area;
            bc.FilterBlobs = true;
            bc.MinHeight = minObjectSize;
            bc.MinWidth = minObjectSize;
            bc.MaxHeight = maxObjectSize;
            bc.MaxWidth = maxObjectSize;

            //process image for blobs
            bc.ProcessImage(channel);
            channel.Dispose();

            //	if (motionDetector.ProcessFrame(image) > 0.02) {
            //	for (int i = 0; i < blobCountingObjectsProcessing.ObjectRectangles.Length; i++) {
            Rectangle[] rectangles = bc.GetObjectsRectangles();
            Blob[] blobs = bc.GetObjectsInformation();
            for (int i = 0; i < bc.ObjectsCount; i++) {
                Rectangle rectangle = rectangles[i];
                int width = rectangle.Width;
                int height = rectangle.Height;

            //		if (width < maxObjectSize && height < maxObjectSize && width > minObjectSize && height > minObjectSize) {
                    Drawing.Rectangle(image, rectangle, colorList[i % colorList.Length]);

                    if (i == 0) {
                        Position = GetCenterOfMass(image, rectangle);
                        Drawing.FillRectangle(image, rectangle, Color.BlanchedAlmond);
                        Drawing.FillRectangle(image, new Rectangle((int) Position.U - dotSize, (int) Position.V - dotSize, dotSize * 3, dotSize * 3), Color.Indigo);
                    }
            //		}
            }
            //	}

            Image = image.ToManagedImage();
            //	videoForm.ImageDestination.Image = image.ToManagedImage();
        }
开发者ID:bcourter,项目名称:SpaceClaim-Addins-Experimental,代码行数:71,代码来源:TrackingCamera.cs

示例13: Cam_NewFrame

        void Cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            //put screen into memory
            System.Drawing.Image imgforms = (Bitmap)eventArgs.Frame.Clone();
            var ms = new MemoryStream();
            imgforms.Save(ms, ImageFormat.Bmp);
            ms.Seek(0, SeekOrigin.Begin);

            //new bitmap
            var bip = new Bitmap(ms);

            //filter
            var filter = new ColorFiltering();
            switch (_filterSwitchState)
            {
                case "filter1" :
                    filter.Red = new IntRange(0, 255);
                    filter.Green = new IntRange(0, 100);
                    filter.Blue = new IntRange(0, 100);
                    break;
                case "filter2":
                    filter.Red = new IntRange(0, 50);
                    filter.Green = new IntRange(0, 50);
                    filter.Blue = new IntRange(0, 50);
                    break;
                case "filter3":
                    filter.Red = new IntRange(175, 255);
                    filter.Green = new IntRange(130, 250);
                    filter.Blue = new IntRange(100, 200);
                    break;
                case "none":
                    filter.Red = new IntRange(0, 255);
                    filter.Green = new IntRange(0, 255);
                    filter.Blue = new IntRange(0, 255);
                    break;
            }
            filter.ApplyInPlace(bip);
            var ms2 = new MemoryStream();
            bip.Save(ms2, ImageFormat.Bmp);

            //blobs
            BlobCounterBase bc = new BlobCounter();
            bc.FilterBlobs = true;
            bc.MinWidth = 10;
            bc.MaxHeight = 400;
            bc.MaxWidth = 400;
            bc.MinHeight = 10;
            bc.ObjectsOrder = ObjectsOrder.Size;
            bc.ProcessImage(bip);
            Rectangle[] rects = bc.GetObjectsRectangles();

            var ms3 = new MemoryStream();

            if (_drawBlobState)
            {
                using (var bitmap = new Bitmap(640, 480))
                {
                    using (var canvas = Graphics.FromImage(bitmap))
                    {
                        canvas.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        canvas.DrawImage(bip, new Rectangle(0, 0, 640, 480), new Rectangle(0, 0, 640, 480), GraphicsUnit.Pixel);
                        int i = 0;
                        foreach (Rectangle rect in rects)
                        {
                            if (_refineBlobState)
                            {
                                if (i < 4)
                                {
                                    using (var pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(255, 255, 0), 2))
                                    {
                                        canvas.DrawRectangle(pen, rect);
                                    }
                                }
                            }
                            else
                            {
                                using (var pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(255, 255, 0), 2))
                                {
                                    canvas.DrawRectangle(pen, rect);
                                }
                            }

                            i++;
                        }
                        ms3.Seek(0, SeekOrigin.Begin);
                        bitmap.Save(ms3, ImageFormat.Bmp);
                    }
                }
            }

            //read mem into bitmap for feed
            var bi = new BitmapImage();
            bi.BeginInit();
            ms2.Seek(0, SeekOrigin.Begin);
            if (_drawBlobState)
            {
                bi.StreamSource = ms3;
            }
            else
            {
//.........这里部分代码省略.........
开发者ID:kfwls,项目名称:MotionTrackeeer,代码行数:101,代码来源:MainWindow.xaml.cs

示例14: GetBlobRectangles

 public List<Rectangle> GetBlobRectangles(Blob blob)
 {
     BlobCounter blobCounter = new BlobCounter();
     blobCounter.ProcessImage(ImageBitmap);
     return blobCounter.GetObjectsRectangles().ToList();
 }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:6,代码来源:ImageProcessor.cs

示例15: ExtractGreenFeatures

        private Stats ExtractGreenFeatures(Bitmap Filtered)
        {
            BlobCounter bc = new BlobCounter();
            Stats greenStats = new Stats();
            bc.MinWidth = 15;
            bc.MinHeight = 15;
            bc.FilterBlobs = true;
            bc.ObjectsOrder = ObjectsOrder.Size;
            bc.ProcessImage(Filtered);
            Rectangle[] rects = bc.GetObjectsRectangles();
            // Graphics g = Graphics.FromImage(Filtered);

            if ((rects.Length > 0) && (rects[0].Height > 0))
            {
                greenStats.GreenBlockDetected = true;
                greenStats.GreenBlockCenterLocation = new System.Drawing.Point(((((rects[0].Width / 2) + rects[0].X))), (rects[0].Y + rects[0].Height / 2));
                greenStats.GreenBlockHeight = rects[0].Height;
                greenStats.GreenBlockWidth = rects[0].Width;
                greenStats.GreenBlockDistance = (130.0f / rects[0].Height);
            }
            else
            {
                greenStats.GreenBlockDetected = false;
            }

            //UpdateVideo(Filtered);
            return greenStats;

            // User Feedback for debug
            //string objectString = Math.Round((130.0f / biggest.Height), 2).ToString();
            //string drawString = biggest.Height + " <-- Height    Width --> " + biggest.Width + "\n Image Center = " + (greenStats.RedBlockCenterLocation.X);
            //g.DrawRectangle(new Pen(Color.Blue), biggest);
            //g.DrawString(objectString, drawFont, Brushes.White, greenStats.RedBlockCenterLocation.X, greenStats.RedBlockCenterLocation.Y, drawFormat);
            //g.DrawString(drawString, drawFont, Brushes.White, x, y, drawFormat);
            //return Filtered;
        }
开发者ID:pet1330,项目名称:RovioAssignment,代码行数:36,代码来源:Vision.cs


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