|
| | _InputArray () |
| |
| template<typename _Tp > |
| | _InputArray (const _Tp *vec, int n) |
| |
| | _InputArray (const cuda::GpuMat &d_mat) |
| |
| | _InputArray (const cuda::GpuMatND &d_mat) |
| |
| | _InputArray (const cuda::HostMem &cuda_mem) |
| |
| template<typename _Tp > |
| | _InputArray (const cudev::GpuMat_< _Tp > &m) |
| |
| | _InputArray (const double &val) |
| |
| | _InputArray (const Mat &m) |
| |
| template<typename _Tp > |
| | _InputArray (const Mat_< _Tp > &m) |
| |
| | _InputArray (const MatExpr &expr) |
| |
| template<typename _Tp , int m, int n> |
| | _InputArray (const Matx< _Tp, m, n > &matx) |
| |
| | _InputArray (const ogl::Buffer &buf) |
| |
| template<typename _Tp , std::size_t _Nm> |
| | _InputArray (const std::array< _Tp, _Nm > &arr) |
| |
| template<std::size_t _Nm> |
| | _InputArray (const std::array< Mat, _Nm > &arr) |
| |
| template<typename _Tp > |
| | _InputArray (const std::vector< _Tp > &vec) |
| |
| | _InputArray (const std::vector< bool > &vec) |
| |
| | _InputArray (const std::vector< cuda::GpuMat > &d_mat_array) |
| |
| | _InputArray (const std::vector< Mat > &vec) |
| |
| template<typename _Tp > |
| | _InputArray (const std::vector< Mat_< _Tp > > &vec) |
| |
| template<typename _Tp > |
| | _InputArray (const std::vector< std::vector< _Tp > > &vec) |
| |
| | _InputArray (const std::vector< std::vector< bool > > &)=delete |
| |
| | _InputArray (const std::vector< UMat > &umv) |
| |
| | _InputArray (const UMat &um) |
| |
| | _InputArray (int _flags, void *_obj) |
| |
| | ~_InputArray () |
| |
| int | channels (int i=-1) const |
| |
| int | cols (int i=-1) const |
| |
| void | copyTo (const _OutputArray &arr) const |
| |
| void | copyTo (const _OutputArray &arr, const _InputArray &mask) const |
| |
| int | depth (int i=-1) const |
| |
| int | dims (int i=-1) const |
| |
| bool | empty () const |
| |
| bool | empty (int i) const |
| |
| int | getFlags () const |
| |
| cuda::GpuMat | getGpuMat () const |
| |
| cuda::GpuMatND | getGpuMatND () const |
| |
| void | getGpuMatVector (std::vector< cuda::GpuMat > &gpumv) const |
| |
| Mat | getMat (int idx=-1) const |
| |
| Mat | getMat_ (int idx=-1) const |
| |
| void | getMatVector (std::vector< Mat > &mv) const |
| |
| void * | getObj () const |
| |
| ogl::Buffer | getOGlBuffer () const |
| |
| Size | getSz () const |
| |
| UMat | getUMat (int idx=-1) const |
| |
| void | getUMatVector (std::vector< UMat > &umv) const |
| |
| bool | isContinuous (int i=-1) const |
| |
| bool | isGpuMat () const |
| |
| bool | isGpuMatND () const |
| |
| bool | isGpuMatVector () const |
| |
| bool | isMat () const |
| |
| bool | isMatVector () const |
| |
| bool | isMatx () const |
| |
| bool | isSubmatrix (int i=-1) const |
| |
| bool | isUMat () const |
| |
| bool | isUMatVector () const |
| |
| bool | isVector () const |
| |
| _InputArray::KindFlag | kind () const |
| |
| size_t | offset (int i=-1) const |
| |
| int | rows (int i=-1) const |
| |
| bool | sameSize (const _InputArray &arr) const |
| |
| Size | size (int i=-1) const |
| |
| int | sizend (int *sz, int i=-1) const |
| |
| size_t | step (int i=-1) const |
| |
| size_t | total (int i=-1) const |
| |
| int | type (int i=-1) const |
| |
読み取り専用の入力配列を OpenCV 関数に渡すためのプロキシクラスである。
これは次のように定義される。
const _InputArray & InputArray
Definition mat.hpp:454
ここで cv::_InputArray は、cv::Mat, cv::Mat_<T>, cv::Matx<T, m, n>, std::vector<T>, std::vector<std::vector<T>>, std::vector<Mat>, std::vector<Mat_<T>>, cv::UMat, std::vector<UMat> あるいは double から構築できるクラスである。行列式 (matrix expression) からも構築できる。
これは主に実装レベルのクラスであり、そのインターフェースは将来のバージョンで変更される可能性があるため、詳細には説明しない。ただし、心に留めておくべき重要な点がいくつかある。
- リファレンスマニュアルや OpenCV のソースコードで InputArray を受け取る関数を見たとき、それは実際に
Mat, Matx, vector<T> などを渡せることを意味する(上記の完全な一覧を参照)。
- 省略可能な入力引数: 入力配列の一部が空であってよい場合は、cv::noArray()(あるいは、おそらく以前そうしていたように単に cv::Mat())を渡す。
- このクラスは引数を渡すためだけに設計されている。すなわち、通常はこの型のクラスメンバやローカル変数・グローバル変数を宣言すべきではない。
- 複数の型の配列を扱える独自の関数やクラスメソッドを設計したい場合は、該当する引数に InputArray(または OutputArray)を使用できる。関数の内部では、_InputArray::getMat() メソッドを使って(データをコピーせずに)配列の行列ヘッダを構築する。_InputArray::kind() を使えば Mat と
vector<> などを区別できるが、通常は必要ない。
InputArray を受け取る関数は次のように使用できる。
std::vector<Point2f> vec;
for( int i = 0; i < 30; i++ )
void transform(InputArray src, OutputArray dst, InputArray m)
Performs the matrix transformation of every array element.
Quat< T > cos(const Quat< T > &q)
Quat< T > sin(const Quat< T > &q)
#define CV_PI
Definition cvdef.h:382
すなわち、点を含む STL ベクトルを作り、Matx<float, 2, 3> インスタンスとしてインラインで作成した 2x3 行列を用いて、そのベクトルにインプレースのアフィン変換を適用している。
そのような関数は次のように実装できる(簡単のため、内部のアサーション文に従って非常に特定のケースを実装している)。
{
for(
int i = 0; i < src.
rows; i++ )
for(
int j = 0; j < src.
cols; j++ )
{
m.at<float>(0, 2),
m.at<float>(1, 2));
}
}
n-dimensional dense array class
Definition mat.hpp:840
MatSize size
Definition mat.hpp:2226
_Tp & at(int i0=0)
Returns a reference to the specified array element.
int cols
Definition mat.hpp:2204
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
Definition mat.hpp:2204
int type() const
Returns the type of a matrix element.
_Tp y
y coordinate of the point
Definition types.hpp:202
_Tp x
x coordinate of the point
Definition types.hpp:201
Template class for specifying the size of an image or rectangle.
Definition types.hpp:335
This type is very similar to InputArray except that it is used for input/output and output function p...
Definition mat.hpp:302
void create(Size sz, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast< _OutputArray::DepthMask >(0)) const
Point_< float > Point2f
Definition types.hpp:207
#define CV_32FC2
Definition interface.h:119
#define CV_32F
Definition interface.h:78
#define CV_Assert(expr)
Checks a condition at runtime and throws exception if it fails.
Definition base.hpp:423
もう1つの関連する型として InputArrayOfArrays があり、現在は InputArray のシノニムとして定義されている。
InputArray InputArrayOfArrays
Definition mat.hpp:455
これは、ベクトルのベクトル、または行列のベクトルのいずれかである関数引数を表す。Python/Java などのラッパーを正しく生成するには、別のシノニムが必要である。関数実装レベルでの使い方は似ているが、外側のベクトルの idx 番目の要素のヘッダを取得するには _InputArray::getMat(idx) を使用し、外側のベクトルの要素(ベクトル/行列)の数を求めるには _InputArray::size().area() を使用する。
一般に、型のサポートは cv::Mat 型に限定される。それ以外の型は禁止される。しかし場合によっては、cv::KeyPoint や cv::DMatch などの配列のように、汎用でないカスタムな Mat 型の受け渡しをサポートする必要がある。このデータは画像データとして解釈されることや、通常の cv::Mat のように何らかの処理がなされることを意図していない。そのようなカスタム型を渡すには、rawIn() / rawOut() / rawInOut() ラッパーを使用する。カスタム型は Mat 互換の CV_8UC<N> 値としてラップされる (N = sizeof(T)、N <= CV_CN_MAX)。
- 例
- samples/cpp/pca.cpp、および samples/cpp/peopledetect.cpp。