Changeset 32533
- Timestamp:
- 04/17/09 18:15:09 (4 years ago)
- Location:
- lang/cpluspluscli/OpenCvSharp2/trunk
- Files:
-
- 1 added
- 12 modified
-
OpenCvSharp.Extern/CvInline.h (modified) (9 diffs)
-
OpenCvSharp.Extern/WCvLineIterator.h (modified) (1 diff)
-
OpenCvSharp.MachineLearning/CvStatModel/CvKNearest.cs (modified) (12 diffs)
-
OpenCvSharp.Test/OpenCvSharp.Test.csproj (modified) (1 diff)
-
OpenCvSharp.Test/Program.cs (modified) (2 diffs)
-
OpenCvSharp.Test/Samples/LineIterator.cs (added)
-
OpenCvSharp/Src/Class/CvLineIterator.cs (modified) (6 diffs)
-
OpenCvSharp/Src/Core/CvDll.cs (modified) (1 diff)
-
OpenCvSharp/Src/Core/Cv_A-C.cs (modified) (1 diff)
-
OpenCvSharp/Src/Core/Cv_D-G.cs (modified) (1 diff)
-
OpenCvSharp/Src/Core/Cv_H-Q.cs (modified) (14 diffs)
-
OpenCvSharp/Src/Core/Cv_Macro.cs (modified) (1 diff)
-
OpenCvSharp/Src/Struct/CvScalar.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.Extern/CvInline.h
r32526 r32533 18 18 public: 19 19 // macro 20 static bool CV_IS_SET_ELEM_( IntPtr ptr ) { 20 static bool CV_IS_SET_ELEM_( IntPtr ptr ) 21 { 21 22 return CV_IS_SET_ELEM( ptr.ToPointer() ); 22 23 } 23 24 24 25 //Graph 25 static IntPtr cvGetGraphVtx_( IntPtr graph, int idx ){ 26 static IntPtr cvGetGraphVtx_( IntPtr graph, int idx ) 27 { 26 28 return IntPtr(cvGetGraphVtx((CvGraph*)graph.ToPointer(), idx)); 27 29 } 28 static int cvGraphVtxIdx_( IntPtr graph, IntPtr vtx ){ 30 static int cvGraphVtxIdx_( IntPtr graph, IntPtr vtx ) 31 { 29 32 return cvGraphVtxIdx((CvGraph*)graph.ToPointer(), (CvGraphVtx*)vtx.ToPointer()); 30 33 } 31 static int cvGraphEdgeIdx_( IntPtr graph, IntPtr edge ){ 34 static int cvGraphEdgeIdx_( IntPtr graph, IntPtr edge ) 35 { 32 36 return cvGraphEdgeIdx((CvGraph*)graph.ToPointer(), (CvGraphEdge*)edge.ToPointer()); 33 37 } 34 static int CV_IS_GRAPH_VERTEX_VISITED_( IntPtr vtx ){ 38 static int CV_IS_GRAPH_VERTEX_VISITED_( IntPtr vtx ) 39 { 35 40 return CV_IS_GRAPH_VERTEX_VISITED((CvGraphVtx*)vtx.ToPointer()); 36 41 } 37 static int CV_IS_GRAPH_EDGE_VISITED_( IntPtr edge ){ 42 static int CV_IS_GRAPH_EDGE_VISITED_( IntPtr edge ) 43 { 38 44 return CV_IS_GRAPH_EDGE_VISITED((CvGraphEdge*)edge.ToPointer()); 39 45 } … … 41 47 /* 42 48 [Obsolete] 43 static void CV_NEXT_SEQ_ELEM_( int elem_size, IntPtr reader ) { 49 static void CV_NEXT_SEQ_ELEM_( int elem_size, IntPtr reader ) 50 { 44 51 CvSeqReader sr = *((CvSeqReader*)reader.ToPointer()); 45 52 CV_NEXT_SEQ_ELEM(elem_size, sr); 46 53 } 47 54 [Obsolete] 48 static void CV_PREV_SEQ_ELEM_( int elem_size, IntPtr reader ) { 55 static void CV_PREV_SEQ_ELEM_( int elem_size, IntPtr reader ) 56 { 49 57 CvSeqReader sr = *((CvSeqReader*)reader.ToPointer()); 50 58 CV_PREV_SEQ_ELEM(elem_size, sr); 51 59 } 52 60 //*/ 53 static bool CV_ARE_TYPES_EQ_CvMat(IntPtr mat1, IntPtr mat2){ 61 static bool CV_ARE_TYPES_EQ_CvMat(IntPtr mat1, IntPtr mat2) 62 { 54 63 CvMat* _mat1 = (CvMat*)mat1.ToPointer(); 55 64 CvMat* _mat2 = (CvMat*)mat2.ToPointer(); … … 62 71 } 63 72 // cvInc/DecData 64 static void cvDecRefData( IntPtr arr ){ 73 static void cvDecRefData( IntPtr arr ) 74 { 65 75 ::cvDecRefData(arr.ToPointer()); 66 76 } 67 static int cvIncRefData( IntPtr arr ){ 77 static int cvIncRefData( IntPtr arr ) 78 { 68 79 return ::cvIncRefData(arr.ToPointer()); 69 80 } 70 81 // CvReadInt/Real/String 71 static int cvReadInt( IntPtr node ) { 82 static int cvReadInt( IntPtr node ) 83 { 72 84 CvFileNode* _node = (CvFileNode*)node.ToPointer(); 73 85 return ::cvReadInt(_node); 74 86 } 75 static int cvReadInt( IntPtr node, int default_value ) { 87 static int cvReadInt( IntPtr node, int default_value ) 88 { 76 89 CvFileNode* _node = (CvFileNode*)node.ToPointer(); 77 90 return ::cvReadInt(_node, default_value); … … 81 94 return ::cvReadReal(_node); 82 95 } 83 static double cvReadReal( IntPtr node, double default_value ) { 96 static double cvReadReal( IntPtr node, double default_value ) 97 { 84 98 CvFileNode* _node = (CvFileNode*)node.ToPointer(); 85 99 return ::cvReadReal(_node, default_value); … … 93 107 return marshal_as<String^>(result); 94 108 } 95 static String^ cvReadString( IntPtr node, String^ default_value ) { 109 static String^ cvReadString( IntPtr node, String^ default_value ) 110 { 96 111 CvFileNode* _node = (CvFileNode*)node.ToPointer(); 97 112 marshal_context context; … … 169 184 } 170 185 // cvmGet/Set 171 static double cvmGet( IntPtr mat, int row, int col ){ 186 static double cvmGet( IntPtr mat, int row, int col ) 187 { 172 188 CvMat* matPtr = (CvMat*)mat.ToPointer(); 173 189 return ::cvmGet(matPtr, row, col); 174 190 } 175 static void cvmSet( IntPtr mat, int row, int col, double value ){ 191 static void cvmSet( IntPtr mat, int row, int col, double value ) 192 { 176 193 CvMat* matPtr = (CvMat*)mat.ToPointer(); 177 194 ::cvmSet(matPtr, row, col, value); … … 197 214 }*/ 198 215 // 算術演算 199 static int cvRound( double value ) { 216 static int cvRound( double value ) 217 { 200 218 return ::cvRound(value); 201 219 } 202 static int cvFloor( double value ){ 220 static int cvFloor( double value ) 221 { 203 222 return ::cvFloor(value); 204 223 } 205 static int cvCeil( double value ){ 224 static int cvCeil( double value ) 225 { 206 226 return ::cvCeil(value); 207 227 } 208 static int cvIsNaN( double value ){ 228 static int cvIsNaN( double value ) 229 { 209 230 return ::cvIsNaN(value); 210 231 } 211 static int cvIsInf( double value ){ 232 static int cvIsInf( double value ) 233 { 212 234 return ::cvIsInf(value); 213 235 } 214 236 // cvGetHistValue_*D 215 static IntPtr cvGetHistValue_1D_( IntPtr hist, int idx0 ){ 237 static IntPtr cvGetHistValue_1D_( IntPtr hist, int idx0 ) 238 { 216 239 CvHistogram* _hist = (CvHistogram*)hist.ToPointer(); 217 240 float* result = cvGetHistValue_1D(_hist, idx0); 218 241 return IntPtr(result); 219 242 } 220 static IntPtr cvGetHistValue_2D_( IntPtr hist, int idx0, int idx1 ) { 243 static IntPtr cvGetHistValue_2D_( IntPtr hist, int idx0, int idx1 ) 244 { 221 245 CvHistogram* _hist = (CvHistogram*)hist.ToPointer(); 222 246 float* result = cvGetHistValue_2D(_hist, idx0, idx1); 223 247 return IntPtr(result); 224 248 } 225 static IntPtr cvGetHistValue_3D_( IntPtr hist, int idx0, int idx1, int idx2 ) { 249 static IntPtr cvGetHistValue_3D_( IntPtr hist, int idx0, int idx1, int idx2 ) 250 { 226 251 CvHistogram* _hist = (CvHistogram*)hist.ToPointer(); 227 252 float* result = cvGetHistValue_3D(_hist, idx0, idx1, idx2); 228 253 return IntPtr(result); 229 254 } 230 static IntPtr cvGetHistValue_nD_( IntPtr hist, array<int>^ idx ) { 255 static IntPtr cvGetHistValue_nD_( IntPtr hist, array<int>^ idx ) 256 { 231 257 CvHistogram* _hist = (CvHistogram*)hist.ToPointer(); 232 258 pin_ptr<int> idx_ptr = &idx[0]; … … 240 266 } 241 267 // cvQueryHistValue_*D 242 static double cvQueryHistValue_1D_( IntPtr hist, int idx0 ) { 268 static double cvQueryHistValue_1D_( IntPtr hist, int idx0 ) 269 { 243 270 CvHistogram* _hist = (CvHistogram*)hist.ToPointer(); 244 271 return cvQueryHistValue_1D(_hist, idx0); 245 272 } 246 static double cvQueryHistValue_2D_( IntPtr hist, int idx0, int idx1 ) { 273 static double cvQueryHistValue_2D_( IntPtr hist, int idx0, int idx1 ) 274 { 247 275 CvHistogram* _hist = (CvHistogram*)hist.ToPointer(); 248 276 return cvQueryHistValue_2D(_hist, idx0, idx1); 249 277 } 250 static double cvQueryHistValue_3D_( IntPtr hist, int idx0, int idx1, int idx2 ) { 278 static double cvQueryHistValue_3D_( IntPtr hist, int idx0, int idx1, int idx2 ) 279 { 251 280 CvHistogram* _hist = (CvHistogram*)hist.ToPointer(); 252 281 return cvQueryHistValue_3D(_hist, idx0, idx1, idx2); 253 282 } 254 static double cvQueryHistValue_nD_( IntPtr hist, ... array<int>^ idx ) { 283 static double cvQueryHistValue_nD_( IntPtr hist, ... array<int>^ idx ) 284 { 255 285 CvHistogram* _hist = (CvHistogram*)hist.ToPointer(); 256 286 pin_ptr<int> idx_ptr = &idx[0]; … … 259 289 260 290 // cvSeq 261 static IntPtr cvCloneSeq( IntPtr seq, IntPtr storage ){ 291 static IntPtr cvCloneSeq( IntPtr seq, IntPtr storage ) 292 { 262 293 return IntPtr(::cvCloneSeq((CvSeq*)seq.ToPointer(), (CvMemStorage*)storage.ToPointer())); 263 294 } 264 295 // Subdiv2D 265 static CvSubdiv2DEdge cvSubdiv2DNextEdge( CvSubdiv2DEdge edge ) { 296 static CvSubdiv2DEdge cvSubdiv2DNextEdge( CvSubdiv2DEdge edge ) 297 { 266 298 return ::cvSubdiv2DNextEdge(edge); 267 299 } 268 static CvSubdiv2DEdge cvSubdiv2DRotateEdge( CvSubdiv2DEdge edge, int rotate ) { 300 static CvSubdiv2DEdge cvSubdiv2DRotateEdge( CvSubdiv2DEdge edge, int rotate ) 301 { 269 302 return ::cvSubdiv2DRotateEdge(edge, rotate); 270 303 } 271 static CvSubdiv2DEdge cvSubdiv2DSymEdge( CvSubdiv2DEdge edge ) { 304 static CvSubdiv2DEdge cvSubdiv2DSymEdge( CvSubdiv2DEdge edge ) 305 { 272 306 return ::cvSubdiv2DSymEdge(edge); 273 307 } 274 static CvSubdiv2DEdge cvSubdiv2DGetEdge( CvSubdiv2DEdge edge, int type ) { 308 static CvSubdiv2DEdge cvSubdiv2DGetEdge( CvSubdiv2DEdge edge, int type ) 309 { 275 310 return ::cvSubdiv2DGetEdge(edge, (CvNextEdgeType)type); 276 311 } 277 static IntPtr cvSubdiv2DEdgeOrg( CvSubdiv2DEdge edge ) { 312 static IntPtr cvSubdiv2DEdgeOrg( CvSubdiv2DEdge edge ) 313 { 278 314 return IntPtr(::cvSubdiv2DEdgeOrg(edge)); 279 315 } 280 static IntPtr cvSubdiv2DEdgeDst( CvSubdiv2DEdge edge ) { 316 static IntPtr cvSubdiv2DEdgeDst( CvSubdiv2DEdge edge ) 317 { 281 318 return IntPtr(::cvSubdiv2DEdgeDst(edge)); 282 319 } -
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.Extern/WCvLineIterator.h
r32527 r32533 34 34 { 35 35 this->_ptr = static_cast<CvLineIterator*>(ptr.ToPointer()); 36 this->Ptr = IntPtr(ptr);36 this->Ptr = ptr; 37 37 } 38 38 39 property IntPtr ptr{ 39 property IntPtr ptr 40 { 40 41 IntPtr get(){ return IntPtr(_ptr->ptr); } 42 void set(IntPtr value){ _ptr->ptr = static_cast<uchar*>(value.ToPointer()); } 43 } 44 property int err 45 { 46 int get(){ return _ptr->err; } 47 void set(int value){ _ptr->err = value; } 48 } 49 property int plus_delta 50 { 51 int get(){ return _ptr->plus_delta; } 52 void set(int value){ _ptr->plus_delta = value; } 53 } 54 property int minus_delta 55 { 56 int get(){ return _ptr->minus_delta; } 57 void set(int value){ _ptr->minus_delta = value; } 58 } 59 property int plus_step 60 { 61 int get(){ return _ptr->plus_step; } 62 void set(int value){ _ptr->plus_step = value; } 63 } 64 property int minus_step 65 { 66 int get(){ return _ptr->minus_step; } 67 void set(int value){ _ptr->minus_step = value; } 41 68 } 42 69 -
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.MachineLearning/CvStatModel/CvKNearest.cs
r32359 r32533 7 7 { 8 8 #if LANG_JP 9 /// <summary>10 ///11 /// </summary>9 /// <summary> 10 /// 11 /// </summary> 12 12 #else 13 13 /// <summary> 14 14 /// K nearest neighbors classifier 15 15 /// </summary> 16 17 #endif 18 public class CvKNearest : CvStatModel16 17 #endif 18 public class CvKNearest : CvStatModel 19 19 { 20 20 #if LANG_JP … … 26 26 /// Access to c++ pointer 27 27 /// </summary> 28 29 28 #endif 30 29 private readonly Extern.WCvKNearest _data; 31 #if LANG_JP30 #if LANG_JP 32 31 /// <summary> 33 32 /// データポインタ 34 33 /// </summary> 35 34 #else 36 /// <summary> 37 /// Pointer 38 /// </summary> 39 35 /// <summary> 36 /// Pointer 37 /// </summary> 40 38 #endif 41 39 private readonly IntPtr _ptr; … … 48 46 /// </summary> 49 47 #else 50 /// <summary> 51 /// sizeof(CvKNearest) 52 /// </summary> 53 54 #endif 48 /// <summary> 49 /// sizeof(CvKNearest) 50 /// </summary> 51 #endif 55 52 public const int SizeOf = Extern.WCvKNearest.SizeOf; 56 53 57 54 #endregion 58 55 59 56 60 57 #region Init and Disposal 61 58 #if LANG_JP … … 64 61 /// </summary> 65 62 #else 66 /// <summary> 67 /// Constructor 68 /// </summary> 69 70 #endif 63 /// <summary> 64 /// Constructor 65 /// </summary> 66 #endif 71 67 public CvKNearest() 72 68 { … … 77 73 #if LANG_JP 78 74 /// <summary> 79 /// コンストラクタ80 /// </summary>81 /// <param name="train_data"></param>82 /// <param name="responses"></param>83 /// <param name="sample_idx"></param>75 /// コンストラクタ 76 /// </summary> 77 /// <param name="train_data"></param> 78 /// <param name="responses"></param> 79 /// <param name="sample_idx"></param> 84 80 /// <param name="is_regression"></param> 85 81 /// <param name="max_k"></param> … … 99 95 /// WCvKNearest(IntPtr _train_data, IntPtr _responses, IntPtr _sample_idx,bool is_regression, int max_k) 100 96 /// </remarks> 101 #endif 102 103 public CvKNearest(CvMat train_data, CvMat responses, CvMat sample_idx,bool is_regression, int max_k) 97 #endif 98 public CvKNearest(CvMat train_data, CvMat responses, CvMat sample_idx, bool is_regression, int max_k) 104 99 { 105 100 if (train_data == null) … … 110 105 IntPtr responses_ptr = (responses == null) ? IntPtr.Zero : responses.CvPtr; 111 106 IntPtr sample_idx_ptr = (sample_idx == null) ? IntPtr.Zero : sample_idx.CvPtr; 112 this._data = new Extern.WCvKNearest(train_data_ptr, responses_ptr, sample_idx_ptr, is_regression,max_k);107 this._data = new Extern.WCvKNearest(train_data_ptr, responses_ptr, sample_idx_ptr, is_regression, max_k); 113 108 this._ptr = _data.Ptr; 114 109 base.NotifyMemoryPressure(SizeOf); … … 124 119 /// </summary> 125 120 /// <param name="ptr">CvKNearest*</param> 126 #endif 121 #endif 127 122 public CvKNearest(IntPtr ptr) 128 123 { … … 180 175 /// <returns></returns> 181 176 #endif 182 public bool Train(CvMat train_data, CvMat responses, CvMat sample_idx, bool is_regression,int max_k, bool update_base)177 public bool Train(CvMat train_data, CvMat responses, CvMat sample_idx, bool is_regression, int max_k, bool update_base) 183 178 { 184 179 if (train_data == null) … … 188 183 IntPtr sample_idx_ptr = (sample_idx == null) ? IntPtr.Zero : sample_idx.CvPtr; 189 184 190 return _data.train(train_data.CvPtr, responses.CvPtr, sample_idx_ptr, is_regression, max_k, update_base);185 return _data.train(train_data.CvPtr, responses.CvPtr, sample_idx_ptr, is_regression, max_k, update_base); 191 186 192 187 } … … 215 210 #endif 216 211 public float FindNearest(CvMat samples, int k, CvMat results, float[][] neighbors, CvMat neighbor_responses, CvMat dist) 217 218 212 { 219 213 if (samples == null) … … 225 219 if (neighbors == null) 226 220 { 227 neighborsPtr_ptr = new IntPtr[1] {IntPtr.Zero};221 neighborsPtr_ptr = new IntPtr[1] { IntPtr.Zero }; 228 222 return _data.find_nearest(samples.CvPtr, k, results_ptr, neighborsPtr_ptr, neighbor_responses_ptr, dist_ptr); 229 223 } -
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.Test/OpenCvSharp.Test.csproj
r32525 r32533 178 178 <Compile Include="Samples\Kalman.cs" /> 179 179 <Compile Include="Samples\KMeans.cs" /> 180 <Compile Include="Samples\LineIterator.cs" /> 180 181 <Compile Include="Samples\LogPolar.cs" /> 181 182 <Compile Include="Samples\MatTest.cs" /> -
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp.Test/Program.cs
r32432 r32533 77 77 //new Test.ConvertToWriteableBitmap(); 78 78 // Building convex hull for a sequence or array of points 79 new Test.ConvexHull();79 //new Test.ConvexHull(); 80 80 // 境界線の作成 81 81 //new Test.CopyMakeBorder(); … … 110 110 // カルマンフィルタ 111 111 //new Test.Kalman(); 112 // CvLineIterator sample 113 new Test.LineIterator(); 112 114 // Log-polar 変換 113 115 //new Test.LogPolar(); -
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Src/Class/CvLineIterator.cs
r32511 r32533 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using System.Runtime.InteropServices; 4 5 using System.Text; 5 6 6 7 namespace KwsmLab.OpenCvSharp 7 8 { 8 #if LANG_JP9 #if LANG_JP 9 10 /// <summary> 10 11 /// … … 15 16 /// </summary> 16 17 #endif 17 public class CvLineIterator : DisposableObject, ICvPtrHolder18 public class CvLineIterator : DisposableObject, ICvPtrHolder, IEnumerable<byte[]> 18 19 { 19 20 /// <summary> … … 25 26 /// </summary> 26 27 private IntPtr _ptr; 27 private BitDepth depth; 28 29 private int _count; 30 private CvArr _image; 31 private CvPoint _pt1; 32 private CvPoint _pt2; 33 private PixelConnectivity _connectivity; 34 private bool _left_to_right; 35 28 36 29 37 #region Constructors 30 /// <summary> 31 /// Initialize from pointer 32 /// </summary> 33 /// <param name="ptr"></param> 34 public CvLineIterator(IntPtr ptr) 35 { 36 if (ptr == IntPtr.Zero) 38 #if LANG_JP 39 /// <summary> 40 /// 構造体の分のメモリを割り当てて初期化 41 /// </summary> 42 #else 43 /// <summary> 44 /// Constructor 45 /// </summary> 46 #endif 47 public CvLineIterator() 48 { 49 this._ptr = base.AllocMemory(SizeOf); 50 this._data = new Extern.WCvLineIterator(this._ptr); 51 this._count = -1; 52 } 53 54 #if LANG_JP 55 /// <summary> 56 /// ラインイテレータを初期化する 57 /// </summary> 58 /// <param name="image">対象画像</param> 59 /// <param name="pt1">線分の一つ目の端点</param> 60 /// <param name="pt2">線分のニつ目の端点</param> 61 /// <returns></returns> 62 #else 63 /// <summary> 64 /// Initializes line iterator 65 /// </summary> 66 /// <param name="image">Image to sample the line from. </param> 67 /// <param name="pt1">First ending point of the line segment. </param> 68 /// <param name="pt2">Second ending point of the line segment. </param> 69 /// <returns>The function cvInitLineIterator initializes the line iterator and returns the number of pixels between two end points. Both points must be inside the image. After the iterator has been initialized, all the points on the raster line that connects the two ending points may be retrieved by successive calls of NextLinePoint point. The points on the line are calculated one by one using 4-connected or 8-connected Bresenham algorithm.</returns> 70 #endif 71 public CvLineIterator(CvArr image, CvPoint pt1, CvPoint pt2) 72 : this(image, pt1, pt2, PixelConnectivity.Connectivity_8, false) 73 { 74 } 75 #if LANG_JP 76 /// <summary> 77 /// ラインイテレータを初期化する 78 /// </summary> 79 /// <param name="image">対象画像</param> 80 /// <param name="pt1">線分の一つ目の端点</param> 81 /// <param name="pt2">線分のニつ目の端点</param> 82 /// <param name="connectivity">走査した線分の接続性.4または8</param> 83 /// <returns></returns> 84 #else 85 /// <summary> 86 /// Initializes line iterator 87 /// </summary> 88 /// <param name="image">Image to sample the line from. </param> 89 /// <param name="pt1">First ending point of the line segment. </param> 90 /// <param name="pt2">Second ending point of the line segment. </param> 91 /// <param name="connectivity">The scanned line connectivity, 4 or 8. </param> 92 /// <returns>The function cvInitLineIterator initializes the line iterator and returns the number of pixels between two end points. Both points must be inside the image. After the iterator has been initialized, all the points on the raster line that connects the two ending points may be retrieved by successive calls of NextLinePoint point. The points on the line are calculated one by one using 4-connected or 8-connected Bresenham algorithm.</returns> 93 #endif 94 public CvLineIterator(CvArr image, CvPoint pt1, CvPoint pt2, PixelConnectivity connectivity) 95 : this(image, pt1, pt2, connectivity, false) 96 { 97 } 98 #if LANG_JP 99 /// <summary> 100 /// ラインイテレータを初期化する 101 /// </summary> 102 /// <param name="image">対象画像</param> 103 /// <param name="pt1">線分の一つ目の端点</param> 104 /// <param name="pt2">線分のニつ目の端点</param> 105 /// <param name="connectivity">走査した線分の接続性.4または8</param> 106 /// <param name="left_to_right">pt1とpt2とは無関係に線分をいつも左から右に走査する(true)か, pt1からpt2への決まった方向で走査するか(false)を指定するフラグ. </param> 107 /// <returns></returns> 108 #else 109 /// <summary> 110 /// Initializes line iterator 111 /// </summary> 112 /// <param name="image">Image to sample the line from. </param> 113 /// <param name="pt1">First ending point of the line segment. </param> 114 /// <param name="pt2">Second ending point of the line segment. </param> 115 /// <param name="connectivity">The scanned line connectivity, 4 or 8. </param> 116 /// <param name="left_to_right">The flag, indicating whether the line should be always scanned from the left-most point to the right-most out of pt1 and pt2 (left_to_right=true), or it is scanned in the specified order, from pt1 to pt2 (left_to_right=false). </param> 117 /// <returns>The function cvInitLineIterator initializes the line iterator and returns the number of pixels between two end points. Both points must be inside the image. After the iterator has been initialized, all the points on the raster line that connects the two ending points may be retrieved by successive calls of NextLinePoint point. The points on the line are calculated one by one using 4-connected or 8-connected Bresenham algorithm.</returns> 118 #endif 119 public CvLineIterator(CvArr image, CvPoint pt1, CvPoint pt2, PixelConnectivity connectivity, bool left_to_right) 120 : this() 121 { 122 if (image == null) 37 123 { 38 throw new ArgumentNullException(" ptr");124 throw new ArgumentNullException("image"); 39 125 } 40 this._ptr = ptr; 41 this._data = new Extern.WCvLineIterator(ptr); 42 } 43 44 #if LANG_JP 45 /// <summary> 46 /// 126 Initialize(image, pt1, pt2, connectivity, left_to_right); 127 } 128 129 /// <summary> 130 /// Initializes line iterator 131 /// </summary> 132 /// <param name="image">Image to sample the line from. </param> 133 /// <param name="pt1">First ending point of the line segment. </param> 134 /// <param name="pt2">Second ending point of the line segment. </param> 135 /// <param name="connectivity">The scanned line connectivity, 4 or 8. </param> 136 /// <param name="left_to_right">The flag, indicating whether the line should be always scanned from the left-most point to the right-most out of pt1 and pt2 (left_to_right=true), or it is scanned in the specified order, from pt1 to pt2 (left_to_right=false). </param> 137 /// <returns>The function cvInitLineIterator initializes the line iterator and returns the number of pixels between two end points. Both points must be inside the image. After the iterator has been initialized, all the points on the raster line that connects the two ending points may be retrieved by successive calls of NextLinePoint point. The points on the line are calculated one by one using 4-connected or 8-connected Bresenham algorithm.</returns> 138 private void Initialize(CvArr image, CvPoint pt1, CvPoint pt2, PixelConnectivity connectivity, bool left_to_right) 139 { 140 this._image = image; 141 this._pt1 = pt1; 142 this._pt2 = pt2; 143 this._connectivity = connectivity; 144 this._left_to_right = left_to_right; 145 this._count = CvDll.cvInitLineIterator(image.CvPtr, pt1, pt2, this.CvPtr, connectivity, left_to_right); 146 } 147 /// <summary> 148 /// Initializes line iterator 149 /// </summary> 150 private void Initialize() 151 { 152 Initialize(_image, _pt1, _pt2, _connectivity, _left_to_right); 153 } 154 155 #if LANG_JP 156 /// <summary> 157 /// リソースの解放 47 158 /// </summary> 48 159 #else … … 60 171 #if LANG_JP 61 172 /// <summary> 62 /// データポインタ (CvLineIterator*)を取得する173 /// データポインタ (CvLineIterator*) 63 174 /// </summary> 64 175 #else … … 82 193 #else 83 194 /// <summary> 84 /// Depth of the image 85 /// </summary> 86 #endif 87 public BitDepth Depth 88 { 89 get { return depth; } 90 set { depth = value; } 91 } 92 93 #if LANG_JP 94 /// <summary> 95 /// 96 /// </summary> 97 #else 98 /// <summary> 99 /// Depth of the image 100 /// </summary> 101 #endif 102 public IntPtr CurrentPointPtr 195 /// 196 /// </summary> 197 #endif 198 public int Count 199 { 200 get { return _count; } 201 private set { _count = value; } 202 } 203 #if LANG_JP 204 /// <summary> 205 /// 206 /// </summary> 207 #else 208 /// <summary> 209 /// 210 /// </summary> 211 #endif 212 public IntPtr Ptr 103 213 { 104 214 get { return _data.ptr; } 105 } 106 107 #if LANG_JP 108 /// <summary> 109 /// 110 /// </summary> 111 #else 112 /// <summary> 113 /// Depth of the image 215 set { _data.ptr = value; } 216 } 217 #if LANG_JP 218 /// <summary> 219 /// 220 /// </summary> 221 #else 222 /// <summary> 223 /// 224 /// </summary> 225 #endif 226 public int Err 227 { 228 get { return _data.err; } 229 set { _data.err = value; } 230 } 231 #if LANG_JP 232 /// <summary> 233 /// 234 /// </summary> 235 #else 236 /// <summary> 237 /// 238 /// </summary> 239 #endif 240 public int PlusDelta 241 { 242 get { return _data.plus_delta; } 243 set { _data.plus_delta = value; } 244 } 245 #if LANG_JP 246 /// <summary> 247 /// 248 /// </summary> 249 #else 250 /// <summary> 251 /// 252 /// </summary> 253 #endif 254 public int MinusDelta 255 { 256 get { return _data.minus_delta; } 257 set { _data.minus_delta = value; } 258 } 259 #if LANG_JP 260 /// <summary> 261 /// 262 /// </summary> 263 #else 264 /// <summary> 265 /// 266 /// </summary> 267 #endif 268 public int PlusStep 269 { 270 get { return _data.plus_step; } 271 set { _data.plus_step = value; } 272 } 273 #if LANG_JP 274 /// <summary> 275 /// 276 /// </summary> 277 #else 278 /// <summary> 279 /// 280 /// </summary> 281 #endif 282 public int MinusStep 283 { 284 get { return _data.minus_step; } 285 set { _data.minus_step = value; } 286 } 287 288 #if LANG_JP 289 /// <summary> 290 /// CV_NEXT_LINE_POINT 291 /// </summary> 292 #else 293 /// <summary> 294 /// CV_NEXT_LINE_POINT 114 295 /// </summary> 115 296 #endif … … 117 298 { 118 299 _data.NextLinePoint(); 300 } 301 #endregion 302 303 #region IEnumerable<T> Members 304 /// <summary> 305 /// 306 /// </summary> 307 /// <returns></returns> 308 public IEnumerator<byte[]> GetEnumerator() 309 { 310 if (_image == null) 311 { 312 throw new NotSupportedException("Not initialized iterator"); 313 } 314 315 Initialize(); 316 int ch = _image.ElemChannels; 317 318 for (int i = 0; i < _count; i++) 319 { 320 byte[] result = new byte[ch]; 321 IntPtr ptr = _data.ptr; 322 for (int j = 0; j < ch; j++) 323 { 324 result[j] = Marshal.ReadByte(ptr, j); 325 } 326 yield return result; 327 _data.NextLinePoint(); 328 } 329 } 330 /// <summary> 331 /// 332 /// </summary> 333 /// <returns></returns> 334 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 335 { 336 return GetEnumerator(); 119 337 } 120 338 #endregion -
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Src/Core/CvDll.cs
r32525 r32533 561 561 public static extern IntPtr cvInitImageHeader(IntPtr image, CvSize size, BitDepth depth, int channels, int origin, int align); 562 562 [DllImport(DLL_CXCORE)] 563 public static extern int cvInitLineIterator(IntPtr image, CvPoint pt1, CvPoint pt2, IntPtr line_iterator, [MarshalAs(UnmanagedType.I4)] PixelConnectivity connectivity, intleft_to_right);563 public static extern int cvInitLineIterator(IntPtr image, CvPoint pt1, CvPoint pt2, IntPtr line_iterator, [MarshalAs(UnmanagedType.I4)] PixelConnectivity connectivity, [MarshalAs(UnmanagedType.Bool)] bool left_to_right); 564 564 [DllImport(DLL_CXCORE)] 565 565 public static extern IntPtr cvInitMatHeader(IntPtr mat, int rows, int cols, MatrixType type, IntPtr data, int step); -
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Src/Core/Cv_A-C.cs
r32517 r32533 2518 2518 #if LANG_JP 2519 2519 /// <summary> 2520 /// 2521 /// </summary> 2522 /// <param name="img_size"> </param>2523 /// <param name="pt1"> </param>2524 /// <param name="pt2"> </param>2520 /// 線分を画像領域で切り取る 2521 /// </summary> 2522 /// <param name="img_size">画像の大きさ</param> 2523 /// <param name="pt1">線分の1番目の端点.この値はこの関数によって変更される.</param> 2524 /// <param name="pt2">線分の2番目の端点.この値はこの関数によって変更される.</param> 2525 2525 /// <returns></returns> 2526 2526 #else -
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Src/Core/Cv_D-G.cs
r32527 r32533 593 593 /// <returns>The function cvEllipse2Poly computes vertices of the polyline that approximates the specified elliptic arc. It is used by cvEllipse. It returns the numbers of output points.</returns> 594 594 #endif 595 public static int Ellipse2Poly(CvPoint center, CvSize axes, int angle, int arc_start,int arc_end,out CvPoint[] pts, int delta)595 public static int Ellipse2Poly(CvPoint center, CvSize axes, int angle, int arc_start, int arc_end, out CvPoint[] pts, int delta) 596 596 { 597 597 int nb_pts = (int)Math.Ceiling(((arc_end - arc_start) / (float)delta) + 1); -
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Src/Core/Cv_H-Q.cs
r32526 r32533 651 651 #region InitLineIterator 652 652 #if LANG_JP 653 /// <summary>654 /// 655 /// </summary> 656 /// <param name="image"> </param>657 /// <param name="pt1"> </param>658 /// <param name="pt2"> </param>659 /// <param name="line_iterator"> </param>653 /// <summary> 654 /// ラインイテレータを初期化する 655 /// </summary> 656 /// <param name="image">対象画像</param> 657 /// <param name="pt1">線分の一つ目の端点</param> 658 /// <param name="pt2">線分のニつ目の端点</param> 659 /// <param name="line_iterator">ラインイテレータ状態構造体へのポインタ</param> 660 660 /// <returns></returns> 661 661 #else … … 674 674 } 675 675 #if LANG_JP 676 /// <summary>677 /// 678 /// </summary> 679 /// <param name="image"> </param>680 /// <param name="pt1"> </param>681 /// <param name="pt2"> </param>682 /// <param name="line_iterator"> </param>683 /// <param name="connectivity"> </param>676 /// <summary> 677 /// ラインイテレータを初期化する 678 /// </summary> 679 /// <param name="image">対象画像</param> 680 /// <param name="pt1">線分の一つ目の端点</param> 681 /// <param name="pt2">線分のニつ目の端点</param> 682 /// <param name="line_iterator">ラインイテレータ状態構造体へのポインタ</param> 683 /// <param name="connectivity">走査した線分の接続性.4または8</param> 684 684 /// <returns></returns> 685 685 #else … … 699 699 } 700 700 #if LANG_JP 701 /// <summary>702 /// 703 /// </summary> 704 /// <param name="image"> </param>705 /// <param name="pt1"> </param>706 /// <param name="pt2"> </param>707 /// <param name="line_iterator"> </param>708 /// <param name="connectivity"> </param>709 /// <param name="left_to_right"> </param>701 /// <summary> 702 /// ラインイテレータを初期化する 703 /// </summary> 704 /// <param name="image">対象画像</param> 705 /// <param name="pt1">線分の一つ目の端点</param> 706 /// <param name="pt2">線分のニつ目の端点</param> 707 /// <param name="line_iterator">ラインイテレータ状態構造体へのポインタ</param> 708 /// <param name="connectivity">走査した線分の接続性.4または8</param> 709 /// <param name="left_to_right">pt1とpt2とは無関係に線分をいつも左から右に走査する(true)か, pt1からpt2への決まった方向で走査するか(false)を指定するフラグ. </param> 710 710 /// <returns></returns> 711 711 #else … … 721 721 /// <returns>The function cvInitLineIterator initializes the line iterator and returns the number of pixels between two end points. Both points must be inside the image. After the iterator has been initialized, all the points on the raster line that connects the two ending points may be retrieved by successive calls of NextLinePoint point. The points on the line are calculated one by one using 4-connected or 8-connected Bresenham algorithm.</returns> 722 722 #endif 723 public static int InitLineIterator( CvArr image, CvPoint pt1, CvPoint pt2,out CvLineIterator line_iterator, PixelConnectivity connectivity, bool left_to_right)723 public static int InitLineIterator(CvArr image, CvPoint pt1, CvPoint pt2, out CvLineIterator line_iterator, PixelConnectivity connectivity, bool left_to_right) 724 724 { 725 725 if (image == null) 726 726 throw new ArgumentNullException("image"); 727 IntPtr line_iterator_ptr = new IntPtr(); 728 int pixels = CvDll.cvInitLineIterator(image.CvPtr, pt1, pt2, line_iterator_ptr, connectivity, System.Convert.ToInt32(left_to_right)); 729 line_iterator = new CvLineIterator(line_iterator_ptr); 730 return pixels; 727 line_iterator = new CvLineIterator(image, pt1, pt2, connectivity, left_to_right); 728 return line_iterator.Count; 731 729 } 732 730 #endregion … … 1150 1148 #region InvSqrt 1151 1149 #if LANG_JP 1152 /// <summary>1150 /// <summary> 1153 1151 /// 引数の平方根の逆数を計算する. 1154 1152 /// これは,通常,1./sqrt(value)を計算するよりも高速である. … … 1212 1210 throw new ArgumentNullException("vtx"); 1213 1211 } 1214 return CvInline.CV_IS_GRAPH_VERTEX_VISITED_( vtx.CvPtr);1212 return CvInline.CV_IS_GRAPH_VERTEX_VISITED_(vtx.CvPtr); 1215 1213 } 1216 1214 #endregion … … 1239 1237 #region KalmanCorrect 1240 1238 #if LANG_JP 1241 /// <summary>1239 /// <summary> 1242 1240 /// モデル状態を修正する. 修正された状態を kalman->state_post に保存し,これを出力として返す.cvKalmanCorrectのエイリアス. 1243 1241 /// </summary> … … 1261 1259 IntPtr result = CvDll.cvKalmanPredict(kalman.CvPtr, measurement.CvPtr); 1262 1260 return new CvMat(result, false); 1263 } 1264 #if LANG_JP 1265 /// <summary>1261 } 1262 #if LANG_JP 1263 /// <summary> 1266 1264 /// モデル状態を修正する. 修正された状態を kalman->state_post に保存し,これを出力として返す.cvKalmanCorrectのエイリアス. 1267 1265 /// </summary> … … 1284 1282 #region KalmanPredict 1285 1283 #if LANG_JP 1286 /// <summary>1284 /// <summary> 1287 1285 /// 次のモデル状態を推定する. cvKalmanPredictのエイリアス. 1288 1286 /// </summary> … … 1301 1299 } 1302 1300 #if LANG_JP 1303 /// <summary>1301 /// <summary> 1304 1302 /// 次のモデル状態を推定する. cvKalmanPredictのエイリアス. 1305 1303 /// </summary> … … 1324 1322 } 1325 1323 #if LANG_JP 1326 /// <summary>1324 /// <summary> 1327 1325 /// 次のモデル状態を推定する. cvKalmanPredictのエイリアス. 1328 1326 /// </summary> … … 1339 1337 { 1340 1338 return KalmanPredict(kalman); 1341 } 1342 #if LANG_JP 1343 /// <summary>1339 } 1340 #if LANG_JP 1341 /// <summary> 1344 1342 /// 次のモデル状態を推定する. cvKalmanPredictのエイリアス. 1345 1343 /// </summary> … … 2150 2148 #region MeanShift 2151 2149 #if LANG_JP 2152 /// <summary>2150 /// <summary> 2153 2151 /// 2154 2152 /// </summary> 2155 /// <param name="prob_image"></param>2153 /// <param name="prob_image"></param> 2156 2154 /// <param name="window"></param> 2157 2155 /// <param name="criteria"></param> … … 3173 3171 block = new CvSeqBlock(); 3174 3172 IntPtr result = CvDll.cvPointSeqFromMat(seq_kind, mat.CvPtr, contour_header.CvPtr, block.CvPtr); 3175 if (result == IntPtr.Zero)3173 if (result == IntPtr.Zero) 3176 3174 return null; 3177 3175 else -
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Src/Core/Cv_Macro.cs
r32510 r32533 238 238 } 239 239 #endregion 240 #region NEXT_LINE_POINT 241 /// <summary> 242 /// 243 /// </summary> 244 /// <param name="line_iterator"></param> 245 public static void NEXT_LINE_POINT(CvLineIterator line_iterator) 246 { 247 int _line_iterator_mask = line_iterator.Err < 0 ? -1 : 0; 248 line_iterator.Err += line_iterator.MinusDelta + (line_iterator.PlusDelta & _line_iterator_mask); 249 line_iterator.Ptr = new IntPtr(line_iterator.Ptr.ToInt64() + line_iterator.MinusStep + (line_iterator.PlusStep & _line_iterator_mask)); 250 } 251 #endregion 240 252 #region NEXT_SEQ_ELEM 241 253 /// <summary> -
lang/cpluspluscli/OpenCvSharp2/trunk/OpenCvSharp/Src/Struct/CvScalar.cs
r32510 r32533 299 299 /// </summary> 300 300 /// <returns>文字列形式</returns> 301 public override string ToString()301 public override string ToString() 302 302 { 303 303 return string.Format("CvScalar ({0}, {1}, {2}, {3})", Val0, Val1, Val2, Val3);
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)