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


C# Contour.ToArray方法代码示例

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


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

示例1: getContourCurvatureIndices

        public static int[] getContourCurvatureIndices(Contour<Point> contour, Point[] curvePoints)
        {
            int[] curveIndices = new int[curvePoints.Count()];

            for (int j = 0; j < curvePoints.Count(); j++)
            {
                curveIndices[j] = Array.IndexOf(contour.ToArray(), curvePoints[j]);
                Console.WriteLine(curveIndices[j] + ":" + curvePoints[j].ToString());
            }

            return curveIndices;
        }
开发者ID:faddison,项目名称:KMouse,代码行数:12,代码来源:KCurvature.cs

示例2: GetMinAreaRect

		private MCvBox2D GetMinAreaRect(Contour<Point> contour)
		{
			Point[] points = contour.ToArray();
			PointF[] pointsF = new PointF[points.Length];

			for (int i = 0; i < points.Length; i++)
			{
				pointsF[i] = new PointF(
					points[i].X,
					points[i].Y);
			}

			return PointCollection.MinAreaRect(pointsF);
		}
开发者ID:eldb2,项目名称:robotic-tic-tac-toe-lynxmotion,代码行数:14,代码来源:BlobInfo.cs

示例3: IsRectangle

		/// <summary>
		/// Determines whether the angles are close enough to 90 degrees
		/// </summary>
		/// <param name="contour"></param>
		/// <returns></returns>
		private static bool IsRectangle(Contour<Point> contour)
		{
			Point[] pts = contour.ToArray();
			LineSegment2D[] edges = PointCollection.PolyLine(pts, true);

			for (int i = 0; i < edges.Length; i++)
			{
				LineSegment2D currentEdge = edges[i];
				LineSegment2D nextEdge = edges[(i + 1) % edges.Length];

				double angle = Math.Abs(nextEdge.GetExteriorAngleDegree(currentEdge));
				if (angle < 80 || angle > 100)
				{
					return false;
				}
			}

			return true;
		}
开发者ID:eldb2,项目名称:robotic-tic-tac-toe-lynxmotion,代码行数:24,代码来源:BoardImageModel.cs

示例4: DetermineLongestEdge

        private LineSegment2D[] DetermineLongestEdge(Contour<Point> contour)
        {
            var pts = contour.ToArray();
            var edges = PointCollection.PolyLine(pts, true);

            var longestEdge = edges[0];
            var index = 0;
            for (var i = 1; i < edges.Length; i++)
            {
                var edge = edges[i];

                // Assumption is that the longest edge defines the width of the tracked device in the blob
                if (edge.Length > longestEdge.Length)
                {
                    index = i;
                    longestEdge = edges[i];
                }
            }

            var nextEdgeToLongestEdge = edges[(index + 1) % edges.Length];

            return new[] { longestEdge, nextEdgeToLongestEdge };
        }
开发者ID:AlternateIf,项目名称:huddle-engine,代码行数:23,代码来源:GlyphDecoder.cs

示例5: isCircleByMath

        bool isCircleByMath(Contour<Point> blob)
        {
            Point[] blobPoints = blob.ToArray();
            PointF[] pointCollection = new PointF[blob.Total];
            for (int i = 0; i < blob.Total; i++)
                pointCollection[i] = new PointF((float)blobPoints[i].X, (float)blobPoints[i].Y);
            CircleF circle = PointCollection.MinEnclosingCircle(pointCollection);

            return blob.Area / circle.Area > 0.7f;
        }
开发者ID:GreenBlitz4590Programmers,项目名称:StrongHoldVision,代码行数:10,代码来源:ImageProcessor.cs

示例6: IsRightL

        bool IsRightL(Contour<Point> blob)
        {
            int blob_center = blob.BoundingRectangle.X + blob.BoundingRectangle.Width / 2;

            int left_count = 0, right_count = 0;
            Point[] points = blob.ToArray();
            foreach (Point p in points)
            {
                if (p.X < blob_center)
                    left_count++;
                else
                    right_count++;
            }

            return left_count > right_count;
        }
开发者ID:GreenBlitz4590Programmers,项目名称:StrongHoldVision,代码行数:16,代码来源:ImageProcessor.cs

示例7: IsUnion

        //----------------------------------------------------------------------------------------------------------------------
        //int orientation(PointF p, PointF q, PointF r)
        //{
        //    int val = (q.Y - p.y) * (r.x - q.x) -
        //              (q.x - p.x) * (r.y - q.y);
        //    if (val == 0) return 0;  // colinear
        //    return (val > 0) ? 1 : 2; // clock or counterclock wise
        //}
        //------------------------------------------------------------------------------------------------------------------------
        //public static PointF FindLineUnion(PointF s1, PointF s2, PointF s3)
        //{
        //    //int n = len3;
        //    PointF denom = new PointF();
        //     denom.X = s1.X - s2.X ;
        //     denom.Y = s1.Y - s2.Y;
        //    int count = 0, i = 0;
        //    do
        //    {
        //      //  int next = (i + 1) % n;
        //       PointF resual= orientation(s1, s2,s3);
        //    } while (i != 0);
        //    return denom;
        //}
        bool IsUnion(Contour<Point> c1, Contour<Point> c2)
        {
            if (c1.Area > c2.Area)
                {
                    Point[] pts1 = c1.ToArray();
                    Point[] pts2 = c2.ToArray();
                    Point s1 = pts2[0];
                    if (IsInPolygon(pts1, s1))
                    {
                        return true;
                    }
                }
                else
                {
                    Point[] pts1 = c1.ToArray();
                    Point[] pts2 = c2.ToArray();
                    Point s1 = pts1[0];
               // Console.WriteLine("mint"+s1);
                    if (IsInPolygon(pts2, s1))
                    {
                        return true;
                    }
                }

            //    for (int i = 0; i <= len1 - 1; i++)
            //{
            //    Point s1 = pts3[i];
            //    // Point s2 = pts3[i + 1];

            //    for (int j = 0; j < len2 - 1; j++)
            //    {
            //        Point s3 = pts4[0];
            //        //if (IsInPolygon(pts3, s3))
            //        //{
            //        //    return true;
            //        //}
            //    }
            //}
            return false;
        }
开发者ID:supatsorn,项目名称:Project_,代码行数:63,代码来源:Program.cs

示例8: FindContourIntersec

        bool FindContourIntersec(Contour<Point> c1, Contour<Point> c2)
        {
            Point[] pts1 = c1.ToArray();
            Point[] pts2 = c2.ToArray();
            int len1 = pts1.Length;
            int len2 = pts2.Length;
            for (int i = 0; i <= len1 - 1; i++)
            {
                Point s1;
                Point e1;
                if (i == len1 - 1)
                {
                    s1 = pts1[len1 - 1];
                    e1 = pts1[0];
                }
                else
                {
                    s1 = pts1[i];
                    e1 = pts1[i + 1];
                }
                for (int j = 0; j < len2 - 1; j++)
                {
                    Point s2 = pts2[j];
                    Point e2 = pts2[j + 1];
                    PointF result = FindLineIntersection(s1, e1, s2, e2);

                    if (!result.IsEmpty)
                    {
                        //  Console.WriteLine("point" + result);
                        return true;
                    }
                }
                {
                    Point s2 = pts2[len2 - 1];
                    Point e2 = pts2[0];
                    PointF result = FindLineIntersection(s1, e1, s2, e2);

                    if (!result.IsEmpty)
                    {
                        return true;
                    }
                }

            }
            return false;
        }
开发者ID:supatsorn,项目名称:Project_,代码行数:46,代码来源:Program.cs

示例9: DetectFingers

        public void DetectFingers(Image<Gray, Byte> image)
        {
            /*
            Point3D ptHandProjective = this.depth.ConvertRealWorldToProjective(ptHand);
            Size offset = new Size((int)ptHandProjective.X, (int)ptHandProjective.Y);
            //get the hand
            Image<Gray, Byte> image = detector.DetectHand(this.depth, ptHand);
            */

            //image = image.PyrDown().PyrUp();
            //image._SmoothGaussian(5);
            //image._ThresholdBinary(new Gray(149), new Gray(255));

            Graphics g = Graphics.FromImage(this.bitmap);

            MemStorage storage1 = new MemStorage();

            Contour<Point> contours = new Contour<Point>(storage1);

            // Find the biggest contour
            for (Contour<Point> tempContours = image.FindContours(); tempContours != null; tempContours = tempContours.HNext)
            {
                if (tempContours.Area > contours.Area)
                    contours = tempContours;
            }

            //Console.WriteLine(contours.Area);
            if (contours.Area != 0)
            {
                List<KeyValuePair<Point, bool>> significantPts = new List<KeyValuePair<Point, bool>>();
                Rectangle contourRectangle = contours.BoundingRectangle;
                g.DrawRectangle(new Pen(Brushes.Green), contourRectangle);

                //Seq<Point> contoursHull = contours.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);

                // Convert the set of contour points to a polygon for graphical representation

                Seq<Point> poly = contours.ApproxPoly(20);
                Point[] polygon = poly.ToArray();

                PointF[] contourF = Array.ConvertAll(contours.ToArray(), new Converter<Point, PointF>(PointToPointF));
                //CircleF palmCircle = PointCollection.MinEnclosingCircle(contourF);
                //CircleF palmCircle = PointCollection.EllipseLeastSquareFitting(contourF);
                //MCvBox2D box = PointCollection.MinAreaRect(contourF);
                //g.DrawRectangle(new Pen(Brushes.Aquamarine),(Rectangle) box.MinAreaRect());
                //drawCircle(g, new Pen(Brushes.Green), PointFToPoint(palmCircle.Center), (int) Math.Round(palmCircle.Radius));

                // Get the convex hull based on the contour polygon
                Seq<Point> convexHull = poly.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);

                /*
                 * Handle opening and closing of the fist each frame.
                 * Fisting gesture controls the left mouse button.
                 * Based on the ratio of area between the convex and the hull.
                 * (See calculation above) Threshold currently set to 0.8
                 *
                 * NEED TO HAND COORDINATES
                 */
                double hullArea = convexHull.Area;
                double contourArea = contours.Area;
                double currentHullRatio = contourArea / hullArea;

                // newest ratio is in front of array
                hullRatios[2] = hullRatios[1];
                hullRatios[1] = hullRatios[0];
                hullRatios[0] = currentHullRatio;

                this.fixedHullRatio = hullRatios[2];

                if (smoothHullRatios && this.frame > 3)
                {
                    this.hullRatios = smoothHullRatioArray(this.hullRatios);
                }

                bool fistClosed = true;
                stopTracking = true;

                if (shouldHandClose())
                {
                    stopTracking = true;
                    fistClosed = false;
                }
                if (shouldControlMouse)
                {
                    //clickMouse(fistClosed);
                }

                // Get the convexity defects from the contour
                stopwatch.Restart();
                Seq<Emgu.CV.Structure.MCvConvexityDefect> contourDefects = contours.GetConvexityDefacts(storage1, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
                stopwatch.Stop();
                //Console.WriteLine(Math.Round(1000.0 * (double)stopwatch.ElapsedTicks / Stopwatch.Frequency, 4) + ", GetConvexityDefacts()");

                // Draw the polygon that was converted from the contour
                /*
                for (int i = 0; i < polygon.Length; i++)
                {
                    if (i == polygon.Length - 1)
                        g.DrawLine((new Pen(Brushes.Blue))), polygon[i], polygon[0]);
                    else
//.........这里部分代码省略.........
开发者ID:faddison,项目名称:KMouse,代码行数:101,代码来源:MainWindow.cs

示例10: Draw

 //public void Draw(Image<Bgr, byte> img, Seq<Point> points, bool fill = false)
 //{
 //    if (fill)
 //    {
 //        //img.FillConvexPoly(contoures.ToArray(), new Bgr(Color.Black));
 //        img.Draw(points.ApproxPoly(20), new Bgr(Color.Black), -1);
 //        //img.Draw(contoures.ApproxPoly(50), new Bgr(Color.Green), -1);
 //        img.Draw(points.ApproxPoly(20), new Bgr(Color.Red), 2);
 //    }
 //    else
 //    {
 //        img.DrawPolyline(points.ToArray(), true, new Bgr(Color.Red), 2);
 //    }
 //}
 public void Draw(Image<Bgr, byte> img, Contour<Point> contoures, bool fill = false)
 {
     if (fill)
     {
         //img.FillConvexPoly(contoures.ApproxPoly(5).ToArray(), new Bgr(Color.Black));
         img.Draw(contoures, new Bgr(Color.Black), -1);
         //img.Draw(contoures.ApproxPoly(50), new Bgr(Color.Green), -1);
     }
     else
     {
         img.DrawPolyline(contoures.ToArray(), true, new Bgr(Color.Red), 2);
     }
 }
开发者ID:HumanRemote,项目名称:HumanRemote,代码行数:27,代码来源:BackgroundSubtractProcessor.cs


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