/// <summary> /// 2値画像中の輪郭を検出します. /// 入力画像は,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます. /// また,この関数は,輪郭抽出処理中に入力画像の中身を書き換えます. /// </summary> /// <param name="mode">輪郭抽出モード</param> /// <param name="method">輪郭の近似手法</param> /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param> /// <return>検出された輪郭.各輪郭は,点のベクトルとして格納されます.</return> #else /// <summary> /// Finds contours in a binary image. /// The source is an 8-bit single-channel image. Non-zero pixels are treated as 1’s. /// Zero pixels remain 0’s, so the image is treated as binary. The function modifies this image while extracting the contours. /// </summary> /// <param name="mode">Contour retrieval mode</param> /// <param name="method">Contour approximation method</param> /// <param name="offset"> Optional offset by which every contour point is shifted. /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param> /// <returns>Detected contours. Each contour is stored as a vector of points.</returns> #endif public MatOfPoint[] FindContoursAsMat(ContourRetrieval mode, ContourChain method, Point? offset = null) { return Cv2.FindContoursAsMat(this, mode, method, offset); }
/// <summary> /// 2値画像中の輪郭を検出します. /// 入力画像は,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます. /// また,この関数は,輪郭抽出処理中に入力画像の中身を書き換えます. /// </summary> /// <param name="contours">検出された輪郭.各輪郭は,点のベクトルとして格納されます.</param> /// <param name="hierarchy">画像のトポロジーに関する情報を含む出力ベクトル.これは,輪郭数と同じ数の要素を持ちます.各輪郭 contours[i] に対して, /// 要素 hierarchy[i]のメンバにはそれぞれ,同じ階層レベルに存在する前後の輪郭,最初の子輪郭,および親輪郭の /// contours インデックス(0 基準)がセットされます.また,輪郭 i において,前後,親,子の輪郭が存在しない場合, /// それに対応する hierarchy[i] の要素は,負の値になります.</param> /// <param name="mode">輪郭抽出モード</param> /// <param name="method">輪郭の近似手法</param> /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param> #else /// <summary> /// Finds contours in a binary image. /// The source is an 8-bit single-channel image. Non-zero pixels are treated as 1’s. /// Zero pixels remain 0’s, so the image is treated as binary. The function modifies this image while extracting the contours. /// </summary> /// <param name="contours">Detected contours. Each contour is stored as a vector of points.</param> /// <param name="hierarchy">Optional output vector, containing information about the image topology. /// It has as many elements as the number of contours. For each i-th contour contours[i], /// the members of the elements hierarchy[i] are set to 0-based indices in contours of the next /// and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. /// If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.</param> /// <param name="mode">Contour retrieval mode</param> /// <param name="method">Contour approximation method</param> /// <param name="offset"> Optional offset by which every contour point is shifted. /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param> #endif public void FindContours(out Mat[] contours, OutputArray hierarchy, ContourRetrieval mode, ContourChain method, Point? offset = null) { Cv2.FindContours(this, out contours, hierarchy, mode, method, offset); }
/// <summary> /// 2値画像中の輪郭を検出します. /// 入力画像は,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます. /// また,この関数は,輪郭抽出処理中に入力画像の中身を書き換えます. /// </summary> /// <param name="mode">輪郭抽出モード</param> /// <param name="method">輪郭の近似手法</param> /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param> /// <return>検出された輪郭.各輪郭は,点のベクトルとして格納されます.</return> #else /// <summary> /// Finds contours in a binary image. /// The source is an 8-bit single-channel image. Non-zero pixels are treated as 1’s. /// Zero pixels remain 0’s, so the image is treated as binary. The function modifies this image while extracting the contours. /// </summary> /// <param name="mode">Contour retrieval mode</param> /// <param name="method">Contour approximation method</param> /// <param name="offset"> Optional offset by which every contour point is shifted. /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param> /// <returns>Detected contours. Each contour is stored as a vector of points.</returns> #endif public Point[][] FindContoursAsArray(ContourRetrieval mode, ContourChain method, Point? offset = null) { return Cv2.FindContoursAsArray(this, mode, method, offset); }
/// <summary> /// 2値画像中の輪郭を検出します. /// </summary> /// <param name="image">入力画像,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます. /// また,この関数は,輪郭抽出処理中に入力画像 image の中身を書き換えます.</param> /// <param name="mode">輪郭抽出モード</param> /// <param name="method">輪郭の近似手法</param> /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param> /// <return>検出された輪郭.各輪郭は,点のベクトルとして格納されます.</return> #else /// <summary> /// Finds contours in a binary image. /// </summary> /// <param name="image">Source, an 8-bit single-channel image. Non-zero pixels are treated as 1’s. /// Zero pixels remain 0’s, so the image is treated as binary. /// The function modifies the image while extracting the contours.</param> /// <param name="mode">Contour retrieval mode</param> /// <param name="method">Contour approximation method</param> /// <param name="offset"> Optional offset by which every contour point is shifted. /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param> /// <returns>Detected contours. Each contour is stored as a vector of points.</returns> #endif public static MatOfPoint[] FindContoursAsMat(InputOutputArray image, ContourRetrieval mode, ContourChain method, Point? offset = null) { if (image == null) throw new ArgumentNullException("image"); image.ThrowIfNotReady(); CvPoint offset0 = offset.GetValueOrDefault(new Point()); IntPtr contoursPtr; NativeMethods.imgproc_findContours2_OutputArray(image.CvPtr, out contoursPtr, (int)mode, (int)method, offset0); image.Fix(); using (var contoursVec = new VectorOfMat(contoursPtr)) { return contoursVec.ToArray<MatOfPoint>(); } }
/// <summary> /// 2値画像中の輪郭を検出します. /// 入力画像は,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます. /// また,この関数は,輪郭抽出処理中に入力画像の中身を書き換えます. /// </summary> /// <param name="contours">検出された輪郭.各輪郭は,点のベクトルとして格納されます.</param> /// <param name="hierarchy">画像のトポロジーに関する情報を含む出力ベクトル.これは,輪郭数と同じ数の要素を持ちます.各輪郭 contours[i] に対して, /// 要素 hierarchy[i]のメンバにはそれぞれ,同じ階層レベルに存在する前後の輪郭,最初の子輪郭,および親輪郭の /// contours インデックス(0 基準)がセットされます.また,輪郭 i において,前後,親,子の輪郭が存在しない場合, /// それに対応する hierarchy[i] の要素は,負の値になります.</param> /// <param name="mode">輪郭抽出モード</param> /// <param name="method">輪郭の近似手法</param> /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param> #else /// <summary> /// Finds contours in a binary image. /// The source is an 8-bit single-channel image. Non-zero pixels are treated as 1’s. /// Zero pixels remain 0’s, so the image is treated as binary. The function modifies this image while extracting the contours. /// </summary> /// <param name="contours">Detected contours. Each contour is stored as a vector of points.</param> /// <param name="hierarchy">Optional output vector, containing information about the image topology. /// It has as many elements as the number of contours. For each i-th contour contours[i], /// the members of the elements hierarchy[i] are set to 0-based indices in contours of the next /// and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. /// If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.</param> /// <param name="mode">Contour retrieval mode</param> /// <param name="method">Contour approximation method</param> /// <param name="offset"> Optional offset by which every contour point is shifted. /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param> #endif public void FindContours(out Point[][] contours, out HiearchyIndex[] hierarchy, ContourRetrieval mode, ContourChain method, Point? offset = null) { Cv2.FindContours(this, out contours, out hierarchy, mode, method, offset); }
/// <summary> /// 2値画像中の輪郭を検出します. /// </summary> /// <param name="image">入力画像,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます. /// また,この関数は,輪郭抽出処理中に入力画像 image の中身を書き換えます.</param> /// <param name="contours">検出された輪郭.各輪郭は,点のベクトルとして格納されます.</param> /// <param name="hierarchy">画像のトポロジーに関する情報を含む出力ベクトル.これは,輪郭数と同じ数の要素を持ちます.各輪郭 contours[i] に対して, /// 要素 hierarchy[i]のメンバにはそれぞれ,同じ階層レベルに存在する前後の輪郭,最初の子輪郭,および親輪郭の /// contours インデックス(0 基準)がセットされます.また,輪郭 i において,前後,親,子の輪郭が存在しない場合, /// それに対応する hierarchy[i] の要素は,負の値になります.</param> /// <param name="mode">輪郭抽出モード</param> /// <param name="method">輪郭の近似手法</param> /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param> #else /// <summary> /// Finds contours in a binary image. /// </summary> /// <param name="image">Source, an 8-bit single-channel image. Non-zero pixels are treated as 1’s. /// Zero pixels remain 0’s, so the image is treated as binary. /// The function modifies the image while extracting the contours.</param> /// <param name="contours">Detected contours. Each contour is stored as a vector of points.</param> /// <param name="hierarchy">Optional output vector, containing information about the image topology. /// It has as many elements as the number of contours. For each i-th contour contours[i], /// the members of the elements hierarchy[i] are set to 0-based indices in contours of the next /// and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. /// If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.</param> /// <param name="mode">Contour retrieval mode</param> /// <param name="method">Contour approximation method</param> /// <param name="offset"> Optional offset by which every contour point is shifted. /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param> #endif public static void FindContours(InputOutputArray image, out Point[][] contours, out HierarchyIndex[] hierarchy, ContourRetrieval mode, ContourChain method, Point? offset = null) { if (image == null) throw new ArgumentNullException("image"); image.ThrowIfNotReady(); CvPoint offset0 = offset.GetValueOrDefault(new Point()); IntPtr contoursPtr, hierarchyPtr; NativeMethods.imgproc_findContours1_vector(image.CvPtr, out contoursPtr, out hierarchyPtr, (int)mode, (int)method, offset0); using (var contoursVec = new VectorOfVectorPoint(contoursPtr)) using (var hierarchyVec = new VectorOfVec4i(hierarchyPtr)) { contours = contoursVec.ToArray(); Vec4i[] hierarchyOrg = hierarchyVec.ToArray(); hierarchy = EnumerableEx.SelectToArray(hierarchyOrg, HierarchyIndex.FromVec4i); } image.Fix(); }
/// <summary> /// 2値画像中の輪郭を検出します. /// </summary> /// <param name="image">入力画像,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます. /// また,この関数は,輪郭抽出処理中に入力画像 image の中身を書き換えます.</param> /// <param name="contours">検出された輪郭.各輪郭は,点のベクトルとして格納されます.</param> /// <param name="hierarchy">画像のトポロジーに関する情報を含む出力ベクトル.これは,輪郭数と同じ数の要素を持ちます.各輪郭 contours[i] に対して, /// 要素 hierarchy[i]のメンバにはそれぞれ,同じ階層レベルに存在する前後の輪郭,最初の子輪郭,および親輪郭の /// contours インデックス(0 基準)がセットされます.また,輪郭 i において,前後,親,子の輪郭が存在しない場合, /// それに対応する hierarchy[i] の要素は,負の値になります.</param> /// <param name="mode">輪郭抽出モード</param> /// <param name="method">輪郭の近似手法</param> /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param> #else /// <summary> /// Finds contours in a binary image. /// </summary> /// <param name="image">Source, an 8-bit single-channel image. Non-zero pixels are treated as 1’s. /// Zero pixels remain 0’s, so the image is treated as binary. /// The function modifies the image while extracting the contours.</param> /// <param name="contours">Detected contours. Each contour is stored as a vector of points.</param> /// <param name="hierarchy">Optional output vector, containing information about the image topology. /// It has as many elements as the number of contours. For each i-th contour contours[i], /// the members of the elements hierarchy[i] are set to 0-based indices in contours of the next /// and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. /// If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.</param> /// <param name="mode">Contour retrieval mode</param> /// <param name="method">Contour approximation method</param> /// <param name="offset"> Optional offset by which every contour point is shifted. /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param> #endif public static void FindContours(InputOutputArray image, out Mat[] contours, OutputArray hierarchy, ContourRetrieval mode, ContourChain method, Point? offset = null) { if (image == null) throw new ArgumentNullException("image"); if (hierarchy == null) throw new ArgumentNullException("hierarchy"); image.ThrowIfNotReady(); hierarchy.ThrowIfNotReady(); CvPoint offset0 = offset.GetValueOrDefault(new Point()); IntPtr contoursPtr; NativeMethods.imgproc_findContours1_OutputArray(image.CvPtr, out contoursPtr, hierarchy.CvPtr, (int)mode, (int)method, offset0); using (var contoursVec = new VectorOfMat(contoursPtr)) { contours = contoursVec.ToArray(); } image.Fix(); hierarchy.Fix(); }
/// <summary> /// 2値画像中の輪郭を見つける /// </summary> /// <param name="image">入力画像(8ビットシングルチャンネル).値が0以外のピクセルは「1」,0のピクセルは「0」とする.</param> /// <param name="storage">抽出された輪郭を保存する領域</param> /// <param name="firstContour">出力パラメータ.一番外側の輪郭へのポインタが入っている.</param> /// <param name="headerSize">シーケンスヘッダのサイズ.method=CV_CHAIN_CODEの場合,>=sizeof(CvChain) ,それ以外の場合 >=sizeof(CvContour).</param> /// <param name="mode">抽出モード </param> /// <param name="method">近似手法</param> /// <returns>抽出した輪郭の個数</returns> #else /// <summary> /// Retrieves contours from the binary image and returns the number of retrieved contours. /// </summary> /// <param name="image">The source 8-bit single channel image. Non-zero pixels are treated as 1’s, zero pixels remain 0’s - that is image treated as binary. /// To get such a binary image from grayscale, one may use cvThreshold, cvAdaptiveThreshold or cvCanny. The function modifies the source image content. </param> /// <param name="storage">Container of the retrieved contours. </param> /// <param name="firstContour">Output parameter, will contain the pointer to the first outer contour. </param> /// <param name="headerSize">Size of the sequence header, >=sizeof(CvChain) if method=CV_CHAIN_CODE, and >=sizeof(CvContour) otherwise. </param> /// <param name="mode">Retrieval mode. </param> /// <param name="method">Approximation method. </param> /// <returns>The number of retrieved contours.</returns> #endif public static int FindContours(CvArr image, CvMemStorage storage, out CvSeq<CvPoint> firstContour, int headerSize, ContourRetrieval mode, ContourChain method) { return FindContours(image, storage, out firstContour, headerSize, mode, method, new CvPoint(0, 0)); }
/// <summary> /// 2値画像中の輪郭を見つける /// </summary> /// <param name="image">入力画像(8ビットシングルチャンネル).値が0以外のピクセルは「1」,0のピクセルは「0」とする.</param> /// <param name="storage">抽出された輪郭を保存する領域</param> /// <param name="firstContour">出力パラメータ.一番外側の輪郭へのポインタが入っている.</param> /// <param name="headerSize">シーケンスヘッダのサイズ.method=CV_CHAIN_CODEの場合,>=sizeof(CvChain) ,それ以外の場合 >=sizeof(CvContour).</param> /// <param name="mode">抽出モード </param> /// <param name="method">近似手法</param> /// <param name="offset">オフセット.全ての輪郭点はこれによってシフトされる.</param> /// <returns>抽出した輪郭の個数</returns> #else /// <summary> /// Retrieves contours from the binary image and returns the number of retrieved contours. /// </summary> /// <param name="image">The source 8-bit single channel image. Non-zero pixels are treated as 1’s, zero pixels remain 0’s - that is image treated as binary. /// To get such a binary image from grayscale, one may use cvThreshold, cvAdaptiveThreshold or cvCanny. The function modifies the source image content. </param> /// <param name="storage">Container of the retrieved contours. </param> /// <param name="firstContour">Output parameter, will contain the pointer to the first outer contour. </param> /// <param name="headerSize">Size of the sequence header, >=sizeof(CvChain) if method=CV_CHAIN_CODE, and >=sizeof(CvContour) otherwise. </param> /// <param name="mode">Retrieval mode. </param> /// <param name="method">Approximation method. </param> /// <param name="offset">Offset, by which every contour point is shifted. This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context. </param> /// <returns>The number of retrieved contours.</returns> #endif public static int FindContours(CvArr image, CvMemStorage storage, out CvSeq<CvPoint> firstContour, int headerSize, ContourRetrieval mode, ContourChain method, CvPoint offset) { if (image == null) throw new ArgumentNullException("image"); if (storage == null) throw new ArgumentNullException("storage"); IntPtr firstContourPtr = IntPtr.Zero; int result = NativeMethods.cvFindContours(image.CvPtr, storage.CvPtr, ref firstContourPtr, headerSize, mode, method, offset); if (firstContourPtr == IntPtr.Zero) firstContour = null; else if (method == ContourChain.Code) firstContour = new CvChain(firstContourPtr); else firstContour = new CvContour(firstContourPtr); return result; }
/// <summary> /// フリーマンチェーン(Freeman chain)をポリラインで近似する /// </summary> /// <param name="srcSeq">他のチェーンから参照可能なチェーンへの参照.</param> /// <param name="storage">計算結果保存用のストレージ.</param> /// <param name="method">推定手法.</param> /// <param name="parameter">メソッドパラメータ(現在は使われていない).</param> /// <param name="minimalPerimeter">minimal_perimeter以上の周囲長をもつ輪郭のみを計算する.その他のチェーンは結果の構造体から削除される.</param> /// <param name="recursive">trueの場合,src_seqからh_nextあるいはv_nextによって辿ることができる全てのチェーンを近似する.falseの場合,単一のチェーンを近似する. </param> /// <returns></returns> #else /// <summary> /// Approximates Freeman chain(s) with polygonal curve /// </summary> /// <param name="srcSeq">Freeman chain(s) </param> /// <param name="storage">Storage location for the resulting polylines. </param> /// <param name="method">Approximation method.</param> /// <param name="parameter">Method parameter (not used now). </param> /// <param name="minimalPerimeter">Approximates only those contours whose perimeters are not less than minimal_perimeter. Other chains are removed from the resulting structure. </param> /// <param name="recursive">If true, the function approximates all chains that access can be obtained to from src_seq by h_next or v_next links. If false, the single chain is approximated. </param> /// <returns></returns> #endif public static CvSeq<CvPoint> ApproxChains(CvChain srcSeq, CvMemStorage storage, ContourChain method, double parameter, int minimalPerimeter, bool recursive) { if (srcSeq == null) throw new ArgumentNullException("srcSeq"); if (storage == null) throw new ArgumentNullException("storage"); IntPtr resultPtr = NativeMethods.cvApproxChains(srcSeq.CvPtr, storage.CvPtr, method, parameter, minimalPerimeter, recursive); if (resultPtr == IntPtr.Zero) return null; CvSeq<CvPoint> result = new CvSeq<CvPoint>(resultPtr); return result; }
/// <summary> /// フリーマンチェーン(Freeman chain)をポリラインで近似する /// </summary> /// <param name="srcSeq">他のチェーンから参照可能なチェーンへの参照.</param> /// <param name="storage">計算結果保存用のストレージ.</param> /// <param name="method">推定手法.</param> /// <param name="parameter">メソッドパラメータ(現在は使われていない).</param> /// <param name="minimalPerimeter">minimal_perimeter以上の周囲長をもつ輪郭のみを計算する.その他のチェーンは結果の構造体から削除される.</param> /// <returns></returns> #else /// <summary> /// Approximates Freeman chain(s) with polygonal curve /// </summary> /// <param name="srcSeq">Freeman chain(s) </param> /// <param name="storage">Storage location for the resulting polylines. </param> /// <param name="method">Approximation method.</param> /// <param name="parameter">Method parameter (not used now). </param> /// <param name="minimalPerimeter">Approximates only those contours whose perimeters are not less than minimal_perimeter. Other chains are removed from the resulting structure. </param> /// <returns></returns> #endif public static CvSeq<CvPoint> ApproxChains(CvChain srcSeq, CvMemStorage storage, ContourChain method, double parameter, int minimalPerimeter) { return ApproxChains(srcSeq, storage, method, parameter, minimalPerimeter, false); }
/// <summary> /// フリーマンチェーン(Freeman chain)をポリラインで近似する /// </summary> /// <param name="srcSeq">他のチェーンから参照可能なチェーンへの参照.</param> /// <param name="storage">計算結果保存用のストレージ.</param> /// <param name="method">推定手法.</param> /// <returns></returns> #else /// <summary> /// Approximates Freeman chain(s) with polygonal curve /// </summary> /// <param name="srcSeq">Freeman chain(s) </param> /// <param name="storage">Storage location for the resulting polylines. </param> /// <param name="method">Approximation method.</param> /// /// <returns></returns> #endif public static CvSeq<CvPoint> ApproxChains(CvChain srcSeq, CvMemStorage storage, ContourChain method) { return ApproxChains(srcSeq, storage, method, 0, 0, false); }
/// <summary> /// フリーマンチェーン(Freeman chain)をポリラインで近似する /// </summary> /// <param name="src_seq">他のチェーンから参照可能なチェーンへの参照.</param> /// <param name="storage">計算結果保存用のストレージ.</param> /// <param name="method">推定手法.</param> /// <param name="parameter">メソッドパラメータ(現在は使われていない).</param> /// <param name="minimal_perimeter">minimal_perimeter以上の周囲長をもつ輪郭のみを計算する.その他のチェーンは結果の構造体から削除される.</param> /// <param name="recursive">trueの場合,src_seqからh_nextあるいはv_nextによって辿ることができる全てのチェーンを近似する.falseの場合,単一のチェーンを近似する. </param> /// <returns></returns> #else /// <summary> /// Approximates Freeman chain(s) with polygonal curve /// </summary> /// <param name="src_seq">Freeman chain(s) </param> /// <param name="storage">Storage location for the resulting polylines. </param> /// <param name="method">Approximation method.</param> /// <param name="parameter">Method parameter (not used now). </param> /// <param name="minimal_perimeter">Approximates only those contours whose perimeters are not less than minimal_perimeter. Other chains are removed from the resulting structure. </param> /// <param name="recursive">If true, the function approximates all chains that access can be obtained to from src_seq by h_next or v_next links. If false, the single chain is approximated. </param> /// <returns></returns> #endif public static CvSeq<CvPoint> ApproxChains(CvChain src_seq, CvMemStorage storage, ContourChain method, double parameter, int minimal_perimeter, bool recursive) { if (src_seq == null) throw new ArgumentNullException("image"); if (storage == null) throw new ArgumentNullException("storage"); IntPtr result_ptr = CvInvoke.cvApproxChains(src_seq.CvPtr, storage.CvPtr, method, parameter, minimal_perimeter, recursive); if (result_ptr == IntPtr.Zero) { return null; } else { CvSeq<CvPoint> result = new CvSeq<CvPoint>(result_ptr); return result; } }
/// <summary> /// フリーマンチェーン(Freeman chain)をポリラインで近似する /// </summary> /// <param name="srcSeq">他のチェーンから参照可能なチェーンへの参照.</param> /// <param name="storage">計算結果保存用のストレージ.</param> /// <param name="method">推定手法.</param> /// <returns></returns> #else /// <summary> /// Approximates Freeman chain(s) with polygonal curve /// </summary> /// <param name="srcSeq">Freeman chain(s) </param> /// <param name="storage">Storage location for the resulting polylines. </param> /// <param name="method">Approximation method.</param> /// /// <returns></returns> #endif public static CvSeq <CvPoint> ApproxChains(CvChain srcSeq, CvMemStorage storage, ContourChain method) { return(ApproxChains(srcSeq, storage, method, 0, 0, false)); }