Changeset 32142

Show
Ignore:
Timestamp:
04/08/09 23:37:03 (4 years ago)
Author:
schima
Message:

CvChainPtReader?

Location:
lang/cpluspluscli/OpenCvSharp2/trunk
Files:
3 added
16 modified

Legend:

Unmodified
Added
Removed
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.Extern/OpenCvSharp.Extern.vcproj

    r32110 r32142  
    554554                                </File> 
    555555                                <File 
     556                                        RelativePath=".\WCvChainPtReader.cpp" 
     557                                        > 
     558                                </File> 
     559                                <File 
    556560                                        RelativePath=".\WCvConnectedComp.cpp" 
    557561                                        > 
     
    700704                                </File> 
    701705                                <File 
     706                                        RelativePath=".\WCvChainPtReader.h" 
     707                                        > 
     708                                </File> 
     709                                <File 
    702710                                        RelativePath=".\WCvConnectedComp.h" 
    703711                                        > 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.Test/Program.cs

    r32022 r32142  
    6767            //new Test.Contour(); 
    6868            // CvContourScanner Sample 
    69             //new Test.ContourScanner(); 
     69            new Test.ContourScanner(); 
    7070            // System.Drawing.Bitmapへの変換 
    7171            //new Test.ConvertToBitmap(); 
     
    133133            //new Test.Resize(); 
    134134            // CvSeqのテスト 
    135             new Test.SeqTest(); 
     135            //new Test.SeqTest(); 
    136136            // 輪郭検出 
    137137            //new Test.Snake(); 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.Test/Samples/ContourScanner.cs

    r32042 r32142  
    2727                { 
    2828                    // find contours by CvContourScanner 
    29                     CvContourScanner scanner = Cv.StartFindContours(canny, storage, CvContour<CvPoint>.SizeOf, ContourRetrieval.Tree, ContourChain.ApproxSimple); 
    30                     //CvContourScanner scanner = new CvContourScanner(canny, storage, CvContour<CvPoint>.SizeOf, ContourRetrieval.Tree, ContourChain.ApproxSimple); 
     29 
     30                    // native style 
     31                    /* 
     32                    CvContourScanner scanner = Cv.StartFindContours(canny, storage, CvContour.SizeOf, ContourRetrieval.Tree, ContourChain.ApproxSimple); 
    3133                    while (true) 
    3234                    { 
     
    3537                            break; 
    3638                        else 
    37                             result.DrawContours(c, CvColor.Red, CvColor.Green, 0, 3, LineType.AntiAlias); 
     39                            Cv.DrawContours(result, c, CvColor.Red, CvColor.Green, 0, 3, LineType.AntiAlias); 
    3840                    } 
    3941                    Cv.EndFindContours(scanner); 
    40                     //scanner.Dispose(); 
     42                    //*/ 
     43 
     44                    // wrapper style 
     45                    using (CvContourScanner scanner = new CvContourScanner(canny, storage, CvContour.SizeOf, ContourRetrieval.Tree, ContourChain.ApproxSimple)) 
     46                    { 
     47                        foreach (CvSeq<CvPoint> c in scanner) 
     48                        { 
     49                            result.DrawContours(c, CvColor.Red, CvColor.Green, 0, 3, LineType.AntiAlias); 
     50                        } 
     51                    }                     
    4152                } 
    4253 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.Test/Samples/FindContours.cs

    r31604 r32142  
    5353                CvMemStorage storage = new CvMemStorage(); 
    5454                // native style 
    55                 Cv.FindContours(img, storage, out contours, CvContour<CvPoint>.SizeOf, ContourRetrieval.Tree, ContourChain.ApproxSimple); 
    56                 contours = Cv.ApproxPoly(contours, CvContour<CvPoint>.SizeOf, storage, ApproxPolyMethod.DP, 3, true); 
     55                Cv.FindContours(img, storage, out contours, CvContour.SizeOf, ContourRetrieval.Tree, ContourChain.ApproxSimple); 
     56                contours = Cv.ApproxPoly(contours, CvContour.SizeOf, storage, ApproxPolyMethod.DP, 3, true); 
    5757                 
    5858                // wrapper style 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.Test/Samples/Squares.cs

    r31777 r32142  
    122122                    // find contours and store them all as a list 
    123123                    CvSeq<CvPoint> contours; 
    124                     Cv.FindContours(gray, storage, out contours, CvContour<CvPoint>.SizeOf, ContourRetrieval.List, ContourChain.ApproxSimple, new CvPoint(0, 0)); 
     124                    Cv.FindContours(gray, storage, out contours, CvContour.SizeOf, ContourRetrieval.List, ContourChain.ApproxSimple, new CvPoint(0, 0)); 
    125125 
    126126                    // test each contour 
     
    129129                        // approximate contour with accuracy proportional 
    130130                        // to the contour perimeter 
    131                         CvSeq<CvPoint> result = Cv.ApproxPoly(contours, CvContour<CvPoint>.SizeOf, storage, ApproxPolyMethod.DP, contours.ContourPerimeter() * 0.02, false); 
     131                        CvSeq<CvPoint> result = Cv.ApproxPoly(contours, CvContour.SizeOf, storage, ApproxPolyMethod.DP, contours.ContourPerimeter() * 0.02, false); 
    132132                        // square contours should have 4 vertices after approximation 
    133133                        // relatively large area (to filter out noisy contours) 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.Test/Samples/TreeNodeIterator.cs

    r31759 r32142  
    2525                Cv.Threshold(src_img_gray, tmp_img, 120, 255, ThresholdType.Binary); 
    2626                CvSeq<CvPoint> contours; 
    27                 Cv.FindContours(tmp_img, storage, out contours, CvContour<CvPoint>.SizeOf, ContourRetrieval.Tree, ContourChain.ApproxSimple); 
     27                Cv.FindContours(tmp_img, storage, out contours, CvContour.SizeOf, ContourRetrieval.Tree, ContourChain.ApproxSimple); 
    2828                /* 輪郭シーケンスから座標を取得 */ 
    2929                using (CvFileStorage fs = new CvFileStorage("contours.yaml", null, FileStorageMode.Write)) 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Class/CvContourScanner.cs

    r31945 r32142  
    1616    /// </summary> 
    1717#endif 
    18     public class CvContourScanner : DisposableObject, ICvPtrHolder 
     18    public class CvContourScanner : DisposableObject, ICvPtrHolder, IEnumerable<CvSeq<CvPoint>> 
    1919    { 
    2020        /// <summary> 
     
    4747#endif 
    4848        public CvContourScanner(CvArr image, CvMemStorage storage) 
    49             : this(image, storage, CvContour<CvPoint>.SizeOf, ContourRetrieval.List, ContourChain.ApproxSimple, new CvPoint(0, 0)) 
     49            : this(image, storage, CvContour.SizeOf, ContourRetrieval.List, ContourChain.ApproxSimple, new CvPoint(0, 0)) 
    5050        { 
    5151        } 
     
    163163        public static CvContourScanner StartFindContours(CvArr image, CvMemStorage storage) 
    164164        { 
    165             return new CvContourScanner(image, storage, CvContour<CvPoint>.SizeOf, ContourRetrieval.List, ContourChain.ApproxSimple, new CvPoint(0, 0)); 
     165            return new CvContourScanner(image, storage, CvContour.SizeOf, ContourRetrieval.List, ContourChain.ApproxSimple, new CvPoint(0, 0)); 
    166166        } 
    167167#if LANG_JP 
     
    291291        } 
    292292        #endregion 
     293 
     294        #region IEnumerable<CvSeq<CvPoint>> 
     295        /// <summary> 
     296        ///  
     297        /// </summary> 
     298        /// <returns></returns> 
     299        public IEnumerator<CvSeq<CvPoint>> GetEnumerator() 
     300        { 
     301            while (true) 
     302            { 
     303                CvSeq<CvPoint> c = Cv.FindNextContour(this); 
     304                if (c == null) 
     305                    break; 
     306                else 
     307                    yield return c; 
     308            } 
     309            Cv.EndFindContours(this); 
     310        } 
     311        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 
     312        { 
     313            return GetEnumerator(); 
     314        } 
     315        #endregion 
    293316    } 
    294317} 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Core/CvDll.cs

    r32138 r32142  
    227227        public static extern void cvPyrUp(IntPtr src, IntPtr dst, CvFilter filter); 
    228228        [DllImport(DLL_CV)] 
     229        public static extern CvPoint cvReadChainPoint(IntPtr reader); 
     230        [DllImport(DLL_CV)] 
    229231        public static extern void cvReleaseHaarClassifierCascade(ref IntPtr cascade); 
    230232        [DllImport(DLL_CV)] 
     
    274276        [DllImport(DLL_CV)] 
    275277        public static extern IntPtr cvStartFindContours(IntPtr image, IntPtr storage, int header_size, [MarshalAs(UnmanagedType.U4)] ContourRetrieval mode, [MarshalAs(UnmanagedType.U4)] ContourChain method, CvPoint offset); 
     278        [DllImport(DLL_CV)] 
     279        public static extern void cvStartReadChainPoints(IntPtr chain, IntPtr reader); 
    276280        [DllImport(DLL_CV)] 
    277281        public static extern Subdiv2DPointLocation cvSubdiv2DLocate(IntPtr subdiv, CvPoint2D32f pt, out CvSubdiv2DEdge edge, ref IntPtr vertex); 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Core/Cv_A-C.cs

    r32138 r32142  
    462462        /// <returns></returns> 
    463463#endif 
    464         public static CvSeq<CvPoint> ApproxChains(this CvChain<CvPoint> src_seq, CvMemStorage storage) 
     464        public static CvSeq<CvPoint> ApproxChains(this CvChain src_seq, CvMemStorage storage) 
    465465        { 
    466466            return ApproxChains(src_seq, storage, ContourChain.ApproxSimple, 0, 0, false); 
     
    483483        /// /// <returns></returns> 
    484484#endif 
    485         public static CvSeq<CvPoint> ApproxChains(this CvChain<CvPoint> src_seq, CvMemStorage storage, ContourChain method) 
     485        public static CvSeq<CvPoint> ApproxChains(this CvChain src_seq, CvMemStorage storage, ContourChain method) 
    486486        { 
    487487            return ApproxChains(src_seq, storage, method, 0, 0, false); 
     
    506506        /// <returns></returns> 
    507507#endif 
    508         public static CvSeq<CvPoint> ApproxChains(this CvChain<CvPoint> src_seq, CvMemStorage storage, ContourChain method, double parameter) 
     508        public static CvSeq<CvPoint> ApproxChains(this CvChain src_seq, CvMemStorage storage, ContourChain method, double parameter) 
    509509        { 
    510510            return ApproxChains(src_seq, storage, method, parameter, 0, false); 
     
    518518        /// <param name="method">推定手法.</param> 
    519519        /// <param name="parameter">メソッドパラメータ(現在は使われていない).</param> 
    520         /// <param name="minimal_perimeter"></param> 
     520        /// <param name="minimal_perimeter">minimal_perimeter以上の周囲長をもつ輪郭のみを計算する.その他のチェーンは結果の構造体から削除される.</param> 
    521521        /// <returns></returns> 
    522522#else 
     
    531531        /// <returns></returns> 
    532532#endif 
    533         public static CvSeq<CvPoint> ApproxChains(this CvChain<CvPoint> src_seq, CvMemStorage storage, ContourChain method, double parameter, int minimal_perimeter) 
     533        public static CvSeq<CvPoint> ApproxChains(this CvChain src_seq, CvMemStorage storage, ContourChain method, double parameter, int minimal_perimeter) 
    534534        { 
    535535            return ApproxChains(src_seq, storage, method, parameter, minimal_perimeter, false); 
     
    543543        /// <param name="method">推定手法.</param> 
    544544        /// <param name="parameter">メソッドパラメータ(現在は使われていない).</param> 
    545         /// <param name="minimal_perimeter"></param> 
    546         /// <param name="recursive"></param> 
     545        /// <param name="minimal_perimeter">minimal_perimeter以上の周囲長をもつ輪郭のみを計算する.その他のチェーンは結果の構造体から削除される.</param> 
     546        /// <param name="recursive">trueの場合,src_seqからh_nextあるいはv_nextによって辿ることができる全てのチェーンを近似する.falseの場合,単一のチェーンを近似する. </param> 
    547547        /// <returns></returns> 
    548548#else 
     
    558558        /// <returns></returns> 
    559559#endif 
    560         public static CvSeq<CvPoint> ApproxChains(this CvChain<CvPoint> src_seq, CvMemStorage storage, ContourChain method, double parameter, int minimal_perimeter, bool recursive) 
     560        public static CvSeq<CvPoint> ApproxChains(this CvChain src_seq, CvMemStorage storage, ContourChain method, double parameter, int minimal_perimeter, bool recursive) 
    561561        { 
    562562            if (src_seq == null) 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Core/Cv_D-G.cs

    r32022 r32142  
    919919        public static int FindContours(this CvArr image, CvMemStorage storage, out CvSeq<CvPoint> first_contour) 
    920920        { 
    921             return FindContours(image, storage, out first_contour, CvContour<CvPoint>.SizeOf, ContourRetrieval.List, ContourChain.ApproxSimple, new CvPoint(0, 0)); 
     921            return FindContours(image, storage, out first_contour, CvContour.SizeOf, ContourRetrieval.List, ContourChain.ApproxSimple, new CvPoint(0, 0)); 
    922922        } 
    923923#if LANG_JP 
     
    10411041            else if (method == ContourChain.Code) 
    10421042            { 
    1043                 first_contour = new CvChain<CvPoint>(first_contour_ptr); 
     1043                first_contour = new CvChain(first_contour_ptr); 
    10441044            } 
    10451045            else 
    10461046            { 
    1047                 first_contour = new CvContour<CvPoint>(first_contour_ptr); 
     1047                first_contour = new CvContour(first_contour_ptr); 
    10481048            } 
    10491049            return result; 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Core/Cv_R-Z.cs

    r32111 r32142  
    158158        } 
    159159        #endregion 
     160        #region ReadChainPoint 
     161#if LANG_JP 
     162        /// <summary> 
     163        /// チェーン上の次の点を得る 
     164        /// </summary> 
     165        /// <param name="reader">チェーンリーダの状態</param> 
     166        /// <returns>現在のチェーン上の点</returns> 
     167#else 
     168        /// <summary> 
     169        /// Gets next chain point 
     170        /// </summary> 
     171        /// <param name="reader">Chain reader state.</param> 
     172        /// <returns>Current chain point.</returns> 
     173#endif 
     174        public static CvPoint ReadChainPoint(this CvChainPtReader reader) 
     175        { 
     176            if (reader == null) 
     177            { 
     178                throw new ArgumentNullException("reader"); 
     179            } 
     180            return CvDll.cvReadChainPoint(reader.CvPtr); 
     181        } 
     182        #endregion 
    160183        #region RandInt 
    161184        /// <summary> 
     
    26282651        public static CvContourScanner StartFindContours(this CvArr image, CvMemStorage storage) 
    26292652        { 
    2630             return StartFindContours(image, storage, CvContour<CvPoint>.SizeOf, ContourRetrieval.List, ContourChain.ApproxSimple, new CvPoint()); 
     2653            return StartFindContours(image, storage, CvContour.SizeOf, ContourRetrieval.List, ContourChain.ApproxSimple, new CvPoint()); 
    26312654        } 
    26322655#if LANG_JP 
     
    27522775        } 
    27532776        #endregion 
     2777        #region StartReadChainPoints 
     2778#if LANG_JP 
     2779        /// <summary> 
     2780        /// チェーンリーダを初期化する 
     2781        /// </summary> 
     2782        /// <param name="chain">チェーンへのポインタ</param> 
     2783        /// <param name="reader">チェーンリーダの状態</param> 
     2784#else 
     2785        /// <summary> 
     2786        ///  
     2787        /// </summary> 
     2788        /// <param name="chain">Pointer to chain.</param> 
     2789        /// <param name="reader">Chain reader state.</param> 
     2790#endif 
     2791        public static void StartReadChainPoints(CvChain chain, CvChainPtReader reader) 
     2792        { 
     2793            if (reader == null) 
     2794                throw new ArgumentNullException("reader"); 
     2795            if (chain == null) 
     2796                throw new ArgumentNullException("chain"); 
     2797            CvDll.cvStartReadChainPoints(chain.CvPtr, reader.CvPtr); 
     2798        } 
     2799        #endregion 
    27542800        #region StartReadSeq 
    27552801        /// <summary> 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/CvArr/CvChain.cs

    r31460 r32142  
    99    /// 輪郭データ 
    1010    /// </summary> 
    11     public class CvChain<T> : CvSeq<T> where T : struct 
     11    public class CvChain : CvSeq<CvPoint>  
    1212    { 
    1313        /// <summary> 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/CvArr/CvContour.cs

    r31460 r32142  
    99    /// 輪郭データ 
    1010    /// </summary> 
    11     public class CvContour<T> : CvSeq<T> where T : struct 
     11    public class CvContour : CvSeq<CvPoint> 
    1212    { 
    1313        /// <summary> 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/DisposableObject.cs

    r31582 r32142  
    104104        protected IntPtr AllocMemory(int size) 
    105105        { 
     106            if (AllocatedMemory != IntPtr.Zero) 
     107            { 
     108                Marshal.FreeHGlobal(AllocatedMemory); 
     109            } 
    106110            AllocatedMemory = Marshal.AllocHGlobal(size); 
    107111            NotifyMemoryPressure(size); 
  • lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/OpenCvSharp.csproj

    r32022 r32142  
    159159  <ItemGroup> 
    160160    <Compile Include="Class\CvBox2D.cs" /> 
     161    <Compile Include="Class\CvChainPtReader.cs" /> 
    161162    <Compile Include="Class\CvHuMoments.cs" /> 
    162163    <Compile Include="Class\CvMoments.cs" /> 
  • lang/cpluspluscli/OpenCvSharp2/trunk/wrapped functions.csv

    r32098 r32142  
    362362Read;X 
    363363ReadByName;X 
    364 ReadChainPoint; 
     364ReadChainPoint;X 
    365365ReadInt; 
    366366ReadIntByName;X 
     
    470470StartFindContours;X 
    471471StartNextStream;X 
    472 StartReadChainPoints; 
     472StartReadChainPoints;X 
    473473StartReadRawData; 
    474474StartReadSeq;X