Changeset 32863 for lang/cpluspluscli

Show
Ignore:
Timestamp:
04/27/09 22:51:04 (4 years ago)
Author:
schima
Message:

bugfix : CvContourScanner?

Location:
lang/cpluspluscli/OpenCvSharp2/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.Test/Program.cs

    r32859 r32863  
    7070            //new Test.Contour();                     // 輪郭領域の面積と輪郭の長さ 
    7171 
    72             //new Test.ContourScanner();              // CvContourScanner Sample 
     72            new Test.ContourScanner();              // CvContourScanner Sample 
    7373 
    7474            //new Test.ConvertToBitmap();             // System.Drawing.Bitmapへの変換 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Src/Class/CvContourScanner.cs

    r32859 r32863  
    2323    public class CvContourScanner : DisposableCvObject, IEnumerable<CvSeq<CvPoint>> 
    2424    { 
     25        #region Fields 
     26        private CvArr _image; 
     27        private CvMemStorage _storage; 
     28        private int _header_size; 
     29        private ContourRetrieval _mode; 
     30        private ContourChain _method; 
     31        private CvPoint _offset; 
     32        #endregion 
     33 
     34 
    2535        #region Constructors 
    26         /// <summary> 
    27         /// Initialize from pointer 
    28         /// </summary> 
    29         /// <param name="ptr"></param> 
    30         public CvContourScanner(IntPtr ptr) 
    31         { 
    32             this._ptr = ptr; 
    33         } 
    34  
    3536#if LANG_JP 
    3637        /// <summary> 
     
    142143            if (storage == null) 
    143144                throw new ArgumentNullException("storage"); 
     145            Initialize(image, storage, header_size, mode, method, offset); 
     146        } 
     147 
     148        /// <summary> 
     149        /// Initializes contour scanning process 
     150        /// </summary> 
     151        /// <param name="image">The source 8-bit single channel binary image. </param> 
     152        /// <param name="storage">Container of the retrieved contours.</param> 
     153        /// <param name="header_size">Size of the sequence header, >=sizeof(CvChain) if method=CV_CHAIN_CODE, and >=sizeof(CvContour) otherwise. </param> 
     154        /// <param name="mode">Retrieval mode; see cvFindContours. </param> 
     155        /// <param name="method">Approximation method. It has the same meaning as in cvFindContours, but CV_LINK_RUNS can not be used here. </param> 
     156        /// <param name="offset">ROI offset; see cvFindContours. </param> 
     157        /// <returns>CvContourScanner</returns> 
     158        private void Initialize(CvArr image, CvMemStorage storage, int header_size, ContourRetrieval mode, ContourChain method, CvPoint offset) 
     159        { 
     160            this._image = image; 
     161            this._storage = storage; 
     162            this._header_size = header_size; 
     163            this._mode = mode; 
     164            this._method = method; 
     165            this._offset = offset; 
     166            if (this._ptr != IntPtr.Zero) 
     167            { 
     168                CvDll.cvEndFindContours(ref this._ptr); 
     169            } 
    144170            this._ptr = CvDll.cvStartFindContours(image.CvPtr, storage.CvPtr, header_size, mode, method, offset); 
     171        } 
     172        /// <summary> 
     173        /// Initializes contour scanning process 
     174        /// </summary> 
     175        private void Initialize() 
     176        { 
     177            Initialize(_image, _storage, _header_size, _mode, _method, _offset); 
    145178        } 
    146179 
     
    264297 
    265298        /// <summary> 
    266         /// = cvEndFindContours 
     299        /// cvEndFindContours 
    267300        /// </summary> 
    268301        public override void Dispose() 
     
    278311        #region IEnumerable<CvSeq<CvPoint>> 
    279312        /// <summary> 
    280         ///  
    281         /// </summary> 
    282         /// <returns></returns> 
     313        /// Returns an enumerator that iterates through the collection. 
     314        /// </summary> 
     315        /// <returns> A System.Collections.Generic.IEnumerator&lt;T&gt; that can be used to iterate through the collection.</returns> 
    283316        public IEnumerator<CvSeq<CvPoint>> GetEnumerator() 
    284317        { 
     318            Initialize(); 
    285319            while (true) 
    286320            { 
     
    293327            Cv.EndFindContours(this); 
    294328        } 
     329        /// <summary> 
     330        ///  
     331        /// </summary> 
     332        /// <returns></returns> 
    295333        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 
    296334        { 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Src/Core/Cv_R-Z.cs

    r32848 r32863  
    43024302                throw new ArgumentNullException("storage"); 
    43034303 
    4304             IntPtr result = CvDll.cvStartFindContours(image.CvPtr, storage.CvPtr, header_size, mode, method, offset); 
    4305  
    4306             if (result == IntPtr.Zero) 
    4307                 return null; 
    4308             else 
    4309                 return new CvContourScanner(result); 
     4304            return new CvContourScanner(image, storage, header_size, mode, method, offset); 
    43104305        } 
    43114306        #endregion 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Src/DisposableCvObject.cs

    r32859 r32863  
    3434#endif 
    3535        protected DisposableCvObject() 
    36             : base() 
     36            : this(true) 
    3737        { 
    3838        } 
     
    4949#endif 
    5050        protected DisposableCvObject(IntPtr ptr) 
    51             : base() 
     51            : this(ptr, true) 
    5252        { 
    53             this._ptr = ptr; 
    5453        } 
    5554#if LANG_JP 
     
    6766            : base(isEnabledDispose) 
    6867        { 
     68            this._ptr = IntPtr.Zero; 
    6969        } 
    7070#if LANG_JP