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


C# MemStorage.Dispose方法代码示例

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


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

示例1: ExtractContourAndHull

        public static TouchImage ExtractContourAndHull(Image<Bgr, Byte> newImg)
        {
            TouchImage touchImage = new TouchImage();
            touchImage.Image = newImg;
            //Image<Gray, byte> skin = new Image<Gray, byte>(newImg);
            using (MemStorage storage = new MemStorage())
            {
                Image<Gray, Byte> grayImage = touchImage.Image.Convert<Gray, Byte>();
                Contour<System.Drawing.Point> contours = grayImage.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_LIST, storage);
                Contour<System.Drawing.Point> biggestContour = null;

                Double Result1 = 0;
                Double Result2 = 0;
                while (contours != null)
                {
                    Result1 = contours.Area;
                    if (Result1 > Result2)
                    {
                        Result2 = Result1;
                        biggestContour = contours;
                    }
                    contours = contours.HNext;
                }

                if (biggestContour != null)
                {
                    //   currentFrame.Draw(biggestContour, new Bgr(Color.DarkViolet), 2);
                    Contour<System.Drawing.Point> currentContour = biggestContour.ApproxPoly(biggestContour.Perimeter * 0.0025, storage);
                    //  currentFrame.Draw(currentContour, new Bgr(Color.LimeGreen), 2);
                    //   currentFrame.Draw(currentContour, new Bgr(Color.Red), 2);
                    biggestContour = currentContour;

                    //      Seq<System.Drawing.Point> hull = biggestContour.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
                    touchImage.Box = biggestContour.GetMinAreaRect();

                    /*

                                        PointF[] points = touchImage.Box.GetVertices();
                                        Rectangle handRect = touchImage.Box.MinAreaRect();
                                        touchImage.Image.Draw(handRect, new Bgr(200, 0, 0), 1);
                                        touchImage.Image.Save(".\\aft\\BEFORE" + DateTime.Now.ToString("hh-mm-ss-fff") + ".jpg");*/
                    /*   System.Drawing.Point[] ps = new System.Drawing.Point[points.Length];
                       for (int i = 0; i < points.Length; i++)
                           ps[i] = new System.Drawing.Point((int)points[i].X, (int)points[i].Y);
                       */

                    // currentFrame.DrawPolyline(hull.ToArray(), true, new Bgr(200, 125, 75), 2);
                    //currentFrame.DrawPolyline(hull.ToArray(), true, new Bgr(Color.White), 2);
                    //  currentFrame.Draw(new CircleF(new PointF(box.center.X, box.center.Y), 3), new Bgr(200, 125, 75), 2);

                    /*  Seq<System.Drawing.Point> filteredHull = new Seq<System.Drawing.Point>(storage);
                        for (int i = 0; i < hull.Total; i++)
                        {
                            if (Math.Sqrt(Math.Pow(hull[i].X - hull[i + 1].X, 2) + Math.Pow(hull[i].Y - hull[i + 1].Y, 2)) > touchImage.Box.size.Width / 10)
                            {
                                filteredHull.Push(hull[i]);
                            }
                        }
                        */

                    touchImage.Defects = biggestContour.GetConvexityDefacts(storage, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE).ToArray();
                    //   touchImage.Image.Save(".\\aft\\BEFORE" + DateTime.Now.ToString("hh-mm-ss-fff") + ".jpg");
                    //     string orientatio = "";
                    //   ComputeFingersNum(touchImage, out  orientatio);
                }
                storage.Dispose();
            }
            return touchImage;
        }
开发者ID:tuliosouza,项目名称:ASG,代码行数:69,代码来源:ImageHelper.cs


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