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


C# Contour.GetConvexHull方法代码示例

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


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

示例1: Is_Bin

        bool Is_Bin(Contour<Point> blob)
        {
            Rectangle rec = blob.BoundingRectangle;
            double ratio = rec.Width / (double)rec.Height;
            //return (ratio + 0.3  >= ((BinDiameter / BinHight)) && ratio - error <= (BinDiameterWithHandles / BinHight));
            Seq<Point> convexHull = blob.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
            Double area = convexHull.Area / (blob.BoundingRectangle.Height * blob.BoundingRectangle.Width);

            return ((area > 0.7) && (area < 0.90)) && (ratio + 0.3 >= ((BinDiameter / BinHight)) && ratio - error <= (BinDiameterWithHandles / BinHight)); ;
        }
开发者ID:GreenBlitz4590Programmers,项目名称:StrongHoldVision,代码行数:10,代码来源:ImageProcessor.cs

示例2: FindStopSign

        private void FindStopSign(Image<Bgr, byte> img, List<Image<Gray, Byte>> stopSignList, List<Rectangle> boxList, Contour<Point> contours)
        {
            for (; contours != null; contours = contours.HNext)
            {
                //draw box from any contour


                imageGray.Draw(new CircleF(centerBox(contours.BoundingRectangle), 3), new Gray(150), 2);
                contours.ApproxPoly(contours.Perimeter * 0.02, 0, contours.Storage);
                if (contours.Area > 20)
                {
                    double ratio = CvInvoke.cvMatchShapes(_octagon2, contours, Emgu.CV.CvEnum.CONTOURS_MATCH_TYPE.CV_CONTOURS_MATCH_I3, 0);

                    if (ratio > 0.1) //not a good match of contour shape
                    {
                        Contour<Point> child = contours.VNext;
                        if (child != null)
                            FindStopSign(img, stopSignList, boxList, child);
                        continue;
                    }
                    
                    Rectangle box = contours.BoundingRectangle;
                    
                    
                    Image<Gray, Byte> candidate;
                    using (Image<Bgr, Byte> tmp = img.Copy(box))
                        candidate = tmp.Convert<Gray, byte>();

                    //set the value of pixels not in the contour region to zero
                    using (Image<Gray, Byte> mask = new Image<Gray, byte>(box.Size))
                    {
                        mask.Draw(contours, new Gray(255), new Gray(255), 0, -1, new Point(-box.X, -box.Y));

                        double mean = CvInvoke.cvAvg(candidate, mask).v0;
                        candidate._ThresholdBinary(new Gray(mean), new Gray(255.0));
                        candidate._Not();
                        mask._Not();
                        candidate.SetValue(0, mask);
                    }

                    ImageFeature<float>[] features = _detector2.DetectFeatures(candidate, null);

                    Features2DTracker<float>.MatchedImageFeature[] matchedFeatures = _tracker2.MatchFeature(features, 2);

                    int goodMatchCount = 0;
                    foreach (Features2DTracker<float>.MatchedImageFeature ms in matchedFeatures)
                        if (ms.SimilarFeatures[0].Distance < 0.5) goodMatchCount++;

                    if (goodMatchCount >= 10)
                    {
                        //imageGray.Draw(contours, new Gray(150), 2);
                        imagecolor.Draw(contours, new Bgr(255,0,0), 2);
                        areas.Add(contours.Area);
                        boxList.Add(box);                                                

                        imageGray.Draw(contours.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE), new Gray(150), 2);
                        stopSignList.Add(candidate);
                    }
                }
            }
        }
开发者ID:petrind,项目名称:SRTesis2,代码行数:61,代码来源:SignDetector.cs

示例3: findFingerTips

        private void findFingerTips(Contour<Point> bigContour, int scale)
        {
            Contour<Point> appContour = bigContour.ApproxPoly(bigContour.Perimeter * 0.0025, contourStorage);
            hull = bigContour.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
            defects = bigContour.GetConvexityDefacts(contourStorage, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
            defectArray = defects.ToArray();

            int defectsTotal = defectArray.Count();
            if (defectsTotal > MAX_POINTS)
            {
                defectsTotal = MAX_POINTS;
            }

            // copy defect information from defects sequence into arrays
            for (int i = 0; i < defectsTotal; i++)
            {
                MCvConvexityDefect cdf = defectArray.ElementAt(i);
                Point startPt = cdf.StartPoint;
                Point endPt = cdf.EndPoint;
                Point depthPt = cdf.DepthPoint;

                double sx = startPt.X;
                double sy = startPt.Y;
                tipPts[i] = new Point((int)Math.Round(sx * scale), (int)Math.Round(sy * scale)); // array contains coords of the fingertips

                double dx = depthPt.X;
                double dy = depthPt.Y;
                foldPts[i] = new Point((int)Math.Round(dx * scale), (int)Math.Round(dy * scale)); //array contains coords of the skin fold between fingers
                depths[i] = cdf.Depth * scale; // array contains distances from tips to folds

                reduceTips(defectsTotal, tipPts, foldPts, depths);
            }
        }
开发者ID:hzhiguang,项目名称:AbuseAnalysis,代码行数:33,代码来源:HandDetector.cs

示例4: DecideHand

        private Hands DecideHand(Contour<Point> contour, out double ratio)
        {
            Seq<Point> convex = contour.GetConvexHull(ORIENTATION.CV_CLOCKWISE);
            ratio = contour.Area / convex.Area;

            if (GMAX >= ratio && ratio >= GMIN)
            {
                return Hands.ROCK;
            }
            else if (CMAX >= ratio && ratio >= CMIN){
                return Hands.SCISSORS;
            }
            else if (PMAX >= ratio && ratio >= PMIN)
            {
                return Hands.PAPER;
            }
            else
            {
                return Hands.UNKNOWN;
            }
        }
开发者ID:jgmanz,项目名称:asial-arbeit,代码行数:21,代码来源:Form1.cs


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