Ejemplo n.º 1
0
        /// <summary>
        /// Finds convex hull of 2D point set using Sklansky's algorithm
        /// </summary>
        /// <param name="points">The points to find convex hull from</param>
        /// <param name="storage">the storage used by the resulting sequence</param>
        /// <param name="orientation">The orientation of the convex hull</param>
        /// <returns>The convex hull of the points</returns>
        public static Seq <PointF> ConvexHull(PointF[] points, MemStorage storage, CvEnum.ORIENTATION orientation)
        {
            IntPtr   seq    = Marshal.AllocHGlobal(StructSize.MCvSeq);
            IntPtr   block  = Marshal.AllocHGlobal(StructSize.MCvSeqBlock);
            GCHandle handle = GCHandle.Alloc(points, GCHandleType.Pinned);

            CvInvoke.cvMakeSeqHeaderForArray(
                CvInvoke.CV_MAKETYPE((int)CvEnum.MAT_DEPTH.CV_32F, 2),
                StructSize.MCvSeq,
                StructSize.PointF,
                handle.AddrOfPinnedObject(),
                points.Length,
                seq,
                block);

            Seq <PointF> convexHull = new Seq <PointF>(CvInvoke.cvConvexHull2(seq, storage.Ptr, orientation, 1), storage);

            handle.Free();
            Marshal.FreeHGlobal(seq);
            Marshal.FreeHGlobal(block);
            return(convexHull);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Get the convex hull of this point sequence, the resulting convex hull use the same storage as the current sequence
 /// </summary>
 /// <param name="orientation">The orientation of the convex hull</param>
 /// <returns>The result convex hull</returns>
 public Seq <T> GetConvexHull(CvEnum.ORIENTATION orientation)
 {
     return(GetConvexHull(orientation, _stor));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the convex hull of this point sequence
        /// </summary>
        /// <param name="orientation">The orientation of the convex hull</param>
        /// <param name="stor">The storage for the resulting sequence</param>
        /// <returns>The result convex hull</returns>
        public Seq <T> GetConvexHull(CvEnum.ORIENTATION orientation, MemStorage stor)
        {
            IntPtr hull = CvInvoke.cvConvexHull2(Ptr, stor, orientation, 1);

            return(new Seq <T>(hull, stor));
        }