基本構造体 =============== .. highlight:: c .. index:: CvPoint .. _CvPoint: CvPoint ------- .. ctype:: CvPoint 整数型で表現される2次元座標上の点(通常は,0が原点). :: typedef struct CvPoint { int x; int y; } CvPoint; .. .. attribute:: x x 座標 .. attribute:: y y 座標 :: /* コンストラクタ */ inline CvPoint cvPoint( int x, int y ); /* CvPoint2D32f からの変換 */ inline CvPoint cvPointFrom32f( CvPoint2D32f point ); .. .. index:: CvPoint2D32f .. _CvPoint2D32f: CvPoint2D32f ------------ .. ctype:: CvPoint2D32f 浮動小数点型で表現される2次元座標上の点(通常は,0が原点). :: typedef struct CvPoint2D32f { float x; float y; } CvPoint2D32f; .. .. attribute:: x x 座標 .. attribute:: y y 座標 :: /* コンストラクタ */ inline CvPoint2D32f cvPoint2D32f( double x, double y ); /* CvPoint からの変換 */ inline CvPoint2D32f cvPointTo32f( CvPoint point ); .. .. index:: CvPoint3D32f .. _CvPoint3D32f: CvPoint3D32f ------------ .. ctype:: CvPoint3D32f 浮動小数点型で表現される3次元座標上の点(通常は,0が原点). :: typedef struct CvPoint3D32f { float x; float y; float z; } CvPoint3D32f; .. .. attribute:: x x 座標 .. attribute:: y y 座標 .. attribute:: z z 座標 :: /* コンストラクタ */ inline CvPoint3D32f cvPoint3D32f( double x, double y, double z ); .. .. index:: CvPoint2D64f .. _CvPoint2D64f: CvPoint2D64f ------------ .. ctype:: CvPoint2D64f 倍精度浮動小数点型で表現される2次元座標上の点(通常は,0が原点). :: typedef struct CvPoint2D64f { double x; double y; } CvPoint2D64f; .. .. attribute:: x x-coordinate .. attribute:: y y-coordinate :: /* コンストラクタ */ inline CvPoint2D64f cvPoint2D64f( double x, double y ); /* CvPoint からの変換 */ inline CvPoint2D64f cvPointTo64f( CvPoint point ); .. .. index:: CvPoint3D64f .. _CvPoint3D64f: CvPoint3D64f ------------ .. ctype:: CvPoint3D64f 倍精度浮動小数点型で表現される3次元座標上の点(通常は,0が原点). :: typedef struct CvPoint3D64f { double x; double y; double z; } CvPoint3D64f; .. .. attribute:: x x 座標 .. attribute:: y y 座標 .. attribute:: z z 座標 :: /* コンストラクタ */ inline CvPoint3D64f cvPoint3D64f( double x, double y, double z ); .. .. index:: CvSize .. _CvSize: CvSize ------ .. ctype:: CvSize ピクセル精度で表現された矩形のサイズ. :: typedef struct CvSize { int width; int height; } CvSize; .. .. attribute:: width 矩形の幅 .. attribute:: height 矩形の高さ :: /* コンストラクタ */ inline CvSize cvSize( int width, int height ); .. .. index:: CvSize2D32f .. _CvSize2D32f: CvSize2D32f ----------- .. ctype:: CvSize2D32f サブピクセル精度で表現された矩形のサイズ. :: typedef struct CvSize2D32f { float width; float height; } CvSize2D32f; .. .. attribute:: width 矩形の幅 .. attribute:: height 矩形の高さ :: /* コンストラクタ */ inline CvSize2D32f cvSize2D32f( double width, double height ); .. .. index:: CvRect .. _CvRect: CvRect ------ .. ctype:: CvRect 矩形のオフセット(通常,左上の角)座標,およびサイズ. :: typedef struct CvRect { int x; int y; int width; int height; } CvRect; .. .. attribute:: x 左上の x 座標 .. attribute:: y 左上の y 座標(Windowsビットマップの場合は,左下) .. attribute:: width 矩形の幅 .. attribute:: height 矩形の高さ :: /* コンストラクタ */ inline CvRect cvRect( int x, int y, int width, int height ); .. .. index:: CvScalar .. _CvScalar: CvScalar -------- .. ctype:: CvScalar double型の値を4個まで格納するコンテナ. :: typedef struct CvScalar { double val[4]; } CvScalar; .. :: /* コンストラクタ: val[0] を val0 で初期化,val[1] を val1で初期化,と続きます */ inline CvScalar cvScalar( double val0, double val1=0, double val2=0, double val3=0 ); /* コンストラクタ: val[0]...val[3] 全てを,val0123 で初期化 */ inline CvScalar cvScalarAll( double val0123 ); /* コンストラクタ: val[0] を val0 で初期化し,残りの val[1]...val[3] を 0 で初期化します */ inline CvScalar cvRealScalar( double val0 ); .. .. index:: CvTermCriteria .. _CvTermCriteria: CvTermCriteria -------------- .. ctype:: CvTermCriteria 反復アルゴリズムのための停止基準. :: #define CV_TERMCRIT_ITER 1 #define CV_TERMCRIT_NUMBER CV_TERMCRIT_ITER #define CV_TERMCRIT_EPS 2 typedef struct CvTermCriteria { int type; int max_iter; double epsilon; } CvTermCriteria; .. .. attribute:: type ``CV_TERMCRIT_ITER`` と ``CV_TERMCRIT_EPS`` の組み合わせ .. attribute:: max_iter 反復数の最大値 .. attribute:: epsilon 要求精度 :: /* コンストラクタ */ inline CvTermCriteria cvTermCriteria( int type, int max_iter, double epsilon ); /* 与えられた cvTermCriteria をチェックし, type を CV_TERMCRIT_ITER+CV_TERMCRIT_EPS に変更し, max_iter と eprilon の両方を有効にします.*/ CvTermCriteria cvCheckTermCriteria( CvTermCriteria criteria, double default_eps, int default_max_iters ); .. .. index:: CvMat .. _CvMat: CvMat ----- .. ctype:: CvMat マルチチャンネル行列. :: typedef struct CvMat { int type; int step; int* refcount; union { uchar* ptr; short* s; int* i; float* fl; double* db; } data; #ifdef __cplusplus union { int rows; int height; }; union { int cols; int width; }; #else int rows; int cols; #endif } CvMat; .. .. attribute:: type 行列の要素の型とフラグを含む,CvMat のシグネチャ(CV _ MAT _ MAGIC _ VAL) .. attribute:: step バイト単位で表される行の長さ .. attribute:: refcount 内部的に利用されるデータ参照カウンタ .. attribute:: data 実際の行列データへのポインタ .. attribute:: rows 行数 .. attribute:: cols 列数 行列は,各列ごとに保存されます.全ての列は,4バイト境界にアラインメントが調整されます. .. index:: CvMatND .. _CvMatND: CvMatND ------- .. ctype:: CvMatND 多次元,マルチチャンネルの密な配列. :: typedef struct CvMatND { int type; int dims; int* refcount; union { uchar* ptr; short* s; int* i; float* fl; double* db; } data; struct { int size; int step; } dim[CV_MAX_DIM]; } CvMatND; .. .. attribute:: type 行列要素の型とフラグを含む,CvMatND のシグネチャ(CV _ MATND _ MAGIC _ VAL) .. attribute:: dims 配列の次元数 .. attribute:: refcount 内部的に利用されるデータ参照カウンタ .. attribute:: data 実際の行列データへのポインタ .. attribute:: dim 各次元における(要素数,要素間のバイト数)の組 .. index:: CvSparseMat .. _CvSparseMat: CvSparseMat ----------- .. ctype:: CvSparseMat 多次元,マルチチャンネルの疎な配列. :: typedef struct CvSparseMat { int type; int dims; int* refcount; struct CvSet* heap; void** hashtable; int hashsize; int total; int valoffset; int idxoffset; int size[CV_MAX_DIM]; } CvSparseMat; .. .. attribute:: type 行列の要素の型とフラグを含む,CvSparseMat のシグネチャ(CV _ SPARSE _ MAT _ MAGIC _ VAL) .. attribute:: dims 次元数 .. attribute:: refcount 参照カウンタ.利用されません .. attribute:: heap ハッシュテーブルのノードの保存領域 .. attribute:: hashtable ハッシュテーブル.各エントリはノードのリストです .. attribute:: hashsize ハッシュテーブルのサイズ .. attribute:: total 疎な配列のノード総数 .. attribute:: valoffset 配列ノードの値のオフセット.バイト単位 .. attribute:: idxoffset 配列ノードのインデックスのオフセット.バイト単位 .. attribute:: size 各次元のサイズを表す配列 .. index:: IplImage .. _IplImage: IplImage -------- .. ctype:: IplImage IPL 画像ヘッダ. :: typedef struct _IplImage { int nSize; int ID; int nChannels; int alphaChannel; int depth; char colorModel[4]; char channelSeq[4]; int dataOrder; int origin; int align; int width; int height; struct _IplROI *roi; struct _IplImage *maskROI; void *imageId; struct _IplTileInfo *tileInfo; int imageSize; char *imageData; int widthStep; int BorderMode[4]; int BorderConst[4]; char *imageDataOrigin; } IplImage; .. .. attribute:: nSize ``sizeof(IplImage)`` .. attribute:: ID バージョン,常に 0 .. attribute:: nChannels チャンネル数.OpenCV のほとんどの関数が,1-4 チャンネルをサポートします .. attribute:: alphaChannel OpenCV では無視されます .. attribute:: depth ピクセル毎のビット数(ビット深度,色深度)+オプションの符号ビット( ``IPL_DEPTH_SIGN`` ).サポートされるビット深度は: .. attribute:: IPL_DEPTH_8U 8ビット符号なし整数 .. attribute:: IPL_DEPTH_8S 8ビット符号あり整数 .. attribute:: IPL_DEPTH_16U 16ビット符号なし整数 .. attribute:: IPL_DEPTH_16S 16ビット符号あり整数 .. attribute:: IPL_DEPTH_32S 32ビット符号あり整数 .. attribute:: IPL_DEPTH_32F 単精度浮動小数点数 .. attribute:: IPL_DEPTH_64F 倍精度浮動小数点数 .. attribute:: colorModel OpenCV では無視されます.OpenCVの関数 :ref:`CvtColor` は,パラメータとして変換元と変換後の色空間を利用します .. attribute:: channelSeq OpenCV では無視されます .. attribute:: dataOrder 0 = ``IPL_DATA_ORDER_PIXEL`` - インタリーブカラーチャンネル,1 - 分離カラーチャンネル. :ref:`CreateImage` が作成できるのは,インタリーブチャンネルの画像のみです.例えば,一般的なカラー画像のレイアウトは, :math:`b_{00} g_{00} r_{00} b_{10} g_{10} r_{10} ...` のようになります .. attribute:: origin 0 - 左上原点,1 - 左下原点(Windows ビットマップ形式) .. attribute:: align 画像の行のアラインメント(4 あるいは 8).OpenCV ではこれを無視して,代わりに widthStep を使用します .. attribute:: width ピクセル単位で表された画像の幅 .. attribute:: height ピクセル単位で表された画像の高さ .. attribute:: roi 注目領域(ROI).NULL でないならば,この領域が処理の対象となります .. attribute:: maskROI OpenCVでは,必ず NULL .. attribute:: imageId OpenCVでは,必ず NULL .. attribute:: imageId OpenCVでは,必ず NULL .. attribute:: imageSize バイト単位で表された画像のデータサイズ.インタリーブデータの場合,これは, :math:`\texttt{image->height} \cdot \texttt{image->widthStep}` と等しくなります .. attribute:: imageData アラインメントが調整された画像データへのポインタ .. attribute:: widthStep アラインメントが調整された画像の行のサイズ.バイト単位で表されます .. attribute:: BorderMode 画像境界モード.OpenCVでは無視されます .. attribute:: BorderConst 画像境界値.OpenCVでは無視されます .. attribute:: imageDataOrigin オリジナル画像データへのポインタ(アラインメントが調整されているとは限りません).画像を解放するために利用されます :ref:`IplImage` 構造体は元々,Intel Image Processing Library(IPL) 固有の形式として利用されていました.OpenCVでは,上述のパラメータリストにあるように, :ref:`IplImage` フォーマットの一部のみをサポートします. この制限に加えて,OpenCV と IPL とでは ROI の扱いが異なります.OpenCV ではすべての入出力画像のサイズ,またはその ROI サイズが正確に一致する必要があります.一方 IPL では,重複する領域が処理の対象となります.つまり画像のサイズ,または ROI のサイズがバラバラでも構いません. .. index:: CvArr .. _CvArr: CvArr ----- .. ctype:: CvArr 任意の配列 :: typedef void CvArr; .. メタ型 ``CvArr`` は,1種類以上の配列(例えば IplImage*,CvMat*, CvSeq*など)を引数にとる関数を記述するための仮引数としてのみ利用されます.個々の配列型は,実行時にヘッダの最初の4バイトを分析することで決定されます.