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


C# PointF.OrderBy方法代码示例

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


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

示例1: splitVertical

        /// <summary>
        /// Split the triangle in two parts, North and South
        /// </summary>
        /// <param name="ps"></param>
        /// <returns></returns>
        IEnumerable<PointF[]> splitVertical(PointF[] points)
        {
            var ps = points.OrderBy(p => p.Y).ThenBy(p => p.X).ToArray();

            Func<float, float> calcX = (y) => (ps[2].X - ps[0].X) / (ps[2].Y - ps[0].Y) * (y - ps[0].Y) + ps[0].X;

            PointF p4 = new PointF(calcX(ps[1].Y), ps[1].Y);

            yield return new PointF[] { ps[0], ps[1], p4 };
            yield return new PointF[] { ps[2], ps[1], p4 };
        }
开发者ID:gousiosg,项目名称:teapots,代码行数:16,代码来源:Form1.cs

示例2: splitHorizontal

        /// <summary>
        /// Split the triangle in East - West orientation
        /// </summary>
        /// <param name="points"></param>
        /// <returns></returns>
        IEnumerable<PointF[]> splitHorizontal(PointF[] points)
        {
            var ps = points.OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();

            Func<float, float> calcY = (x) => (ps[0].Y - ps[2].Y) / (ps[0].X - ps[2].X) * (x - ps[2].X) + ps[2].Y;

            PointF p4 = new PointF(ps[1].X, calcY(ps[1].X));

            yield return new PointF[] { ps[0], ps[1], p4 };
            yield return new PointF[] { ps[2], ps[1], p4 };
        }
开发者ID:gousiosg,项目名称:teapots,代码行数:16,代码来源:Form1.cs

示例3: SortLRUB

 public static PointF[] SortLRUB(PointF[] points)
 {
     return points.OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();
 }
开发者ID:virrkharia,项目名称:dynamight,代码行数:4,代码来源:StereoCalibration.cs

示例4: Detect

        public static Boolean Detect(ObjectDetectee observedScene, ObjectDetectee obj)
        {
            HomographyMatrix homography = null;

            VectorOfKeyPoint observedKeyPoints;
            Matrix<int> indices;

            Matrix<byte> mask;
            int k = 2;
            double uniquenessThreshold = 0.8;
            int testsPassed = 0;

            // extract features from the observed image
            observedKeyPoints = observedScene.objectKeyPoints;
            Matrix<float> observedDescriptors = observedScene.objectDescriptors;
            BruteForceMatcher<float> matcher = new BruteForceMatcher<float>(DistanceType.L2);
            matcher.Add(obj.objectDescriptors);
            if (observedDescriptors == null)
            {
                return false;
            }
            indices = new Matrix<int>(observedDescriptors.Rows, k);
            using (Matrix<float> dist = new Matrix<float>(observedDescriptors.Rows, k))
            {
                matcher.KnnMatch(observedDescriptors, indices, dist, k, null);
                mask = new Matrix<byte>(dist.Rows, 1);
                mask.SetValue(255);
                Features2DToolbox.VoteForUniqueness(dist, uniquenessThreshold, mask);
            }

            int nonZero = 0;
            int nonZeroCount = CvInvoke.cvCountNonZero(mask);
            if (nonZeroCount >= 4)
            {
                nonZeroCount = Features2DToolbox.VoteForSizeAndOrientation(obj.objectKeyPoints, observedKeyPoints, indices, mask, 1.5, 20);
                if (nonZeroCount >= 4)
                {
                    homography = Features2DToolbox.GetHomographyMatrixFromMatchedFeatures(obj.objectKeyPoints, observedKeyPoints, indices, mask, 2);
                    for (int i = 0; i < mask.Height; i++)
                    {
                        for (int j = 0; j < mask.Width; j++)
                        {
                            if (mask[i, j] != 0)
                            {
                                nonZero++;
                            }
                        }
                    }
                    if (nonZero > 4)
                    {
                        testsPassed++;
                    }
                }

            }

            if (homography != null)
            {
                //draw a rectangle along the projected model
                Rectangle rect = obj.objectImage.ROI;
                PointF[] pts = new PointF[] {
               new PointF(rect.Left, rect.Bottom),
               new PointF(rect.Right, rect.Bottom),
               new PointF(rect.Right, rect.Top),
               new PointF(rect.Left, rect.Top)};

                using (MemStorage m1 = new MemStorage())
                using (MemStorage m2 = new MemStorage())
                {

                    Contour<PointF> objPoly = new Contour<PointF>(m1);
                    Contour<PointF> scenePoly = new Contour<PointF>(m2);
                    pts.OrderBy(p => p.X).ThenBy(p => p.Y);
                    foreach (PointF i in pts)
                    {
                        objPoly.Push(i);
                    }
                    homography.ProjectPoints(pts);
                    pts.OrderBy(p => p.X).ThenBy(p => p.Y);
                    foreach (PointF i in pts)
                    {
                        scenePoly.Push(i);
                    }
                    double shapeMatch = CvInvoke.cvMatchShapes(objPoly, scenePoly, Emgu.CV.CvEnum.CONTOURS_MATCH_TYPE.CV_CONTOURS_MATCH_I3, 0);
                    double ratio = scenePoly.Area / objPoly.Area;
                    foreach (PointF i in pts)
                    {
                        if (i.X < 0 || i.Y < 0)
                        {
                            return false;
                        }
                    }
                    if (shapeMatch != 0 && shapeMatch <= 2)
                    {
                        testsPassed++;
                    }
                    if (ratio > 0.001 && ratio < 5.25)
                    {
                        testsPassed++;
                    }
//.........这里部分代码省略.........
开发者ID:NeoValkyrion,项目名称:ubiquidine,代码行数:101,代码来源:ObjectMatcher.cs

示例5: DetermineBounds

 private static RectangleF DetermineBounds(PointF[] points, float width, float height)
 {
     var ulx = points.OrderBy(row => row.X).First().X / width;
     var uly = (height - points.OrderByDescending(row => row.Y).First().Y) / height;
     var brx = points.OrderByDescending(row => row.X).First().X / width;
     var bry = (height - points.OrderBy(row => row.Y).First().Y) / height;
     var w = brx - ulx;
     var h = bry - uly;
     return new RectangleF(new PointF(ulx - w * 0.2f, uly - h * 0.2f), new SizeF(w * 1.4f, h * 1.4f));
 }
开发者ID:virrkharia,项目名称:dynamight,代码行数:10,代码来源:StereoCalibration.cs


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