Пример #1
0
        /// <summary>
        /// find contours in the image
        /// </summary>
        /// <param name="local"> the image </param>
        /// <param name="cHAIN_APPROX_METHOD">param provided to the opencv function</param>
        /// <param name="rETR_TYPE">param provided to the opencv function</param>
        /// <param name="stor">param provided to the opencv function </param>
        /// <remarks>For more information about previous parameters and contours see opencv book chapter 8 And/Or opencv reference manual v2.1 March 18, 2010  page 343 </remarks>
        /// <returns> the founded contours </returns>

        private Contour <Point> FindContours(Image <Gray, byte> local, CHAIN_APPROX_METHOD cHAIN_APPROX_METHOD, RETR_TYPE rETR_TYPE, MemStorage stor)
        {
            using (Image <Gray, byte> imagecopy = local.Copy()) //since cvFindContours modifies the content of the source, we need to make a clone
            {
                IntPtr seq = IntPtr.Zero;
                CvInvoke.cvFindContours(
                    imagecopy.Ptr,
                    stor.Ptr,
                    ref seq,
                    StructSize.MCvContour,
                    rETR_TYPE,
                    cHAIN_APPROX_METHOD,
                    new Point(local.ROI.X, local.ROI.Y));// because of ROI, the contour is offset or shifted

                return((seq == IntPtr.Zero) ? null : new Contour <Point>(seq, stor));
            }
        }
Пример #2
0
        private Contour<Point> FindContours(Image<Gray, byte> local, CHAIN_APPROX_METHOD cHAIN_APPROX_METHOD, RETR_TYPE rETR_TYPE, MemStorage stor)
        {
            using (Image<Gray, byte> imagecopy = local.Copy()) //since cvFindContours modifies the content of the source, we need to make a clone
            {
                IntPtr seq = IntPtr.Zero;
                CvInvoke.cvFindContours(
                    imagecopy.Ptr,
                    stor.Ptr,
                    ref seq,
                    StructSize.MCvContour,
                    rETR_TYPE,
                    cHAIN_APPROX_METHOD,
                    new Point(local.ROI.X, local.ROI.Y));// because of ROI, the contour is offset or shifted 

                return (seq == IntPtr.Zero) ? null : new Contour<Point>(seq, stor);
            }
        }