OpenCV 5.0.0
Open Source Computer Vision
読み込み中...
検索中...
見つかりません
🤖 AIによる機械翻訳(非公式) — これは OpenCV 5.0.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。
cv::_InputArray クラス

読み取り専用の入力配列を OpenCV 関数に渡すためのプロキシクラスである。続き...

#include <opencv2/core/mat.hpp>

Collaboration diagram for cv::_InputArray:

公開型

enum  KindFlag {
  KIND_SHIFT = 16 ,
  FIXED_TYPE = 0x8000 << KIND_SHIFT ,
  FIXED_SIZE = 0x4000 << KIND_SHIFT ,
  KIND_MASK = 31 << KIND_SHIFT ,
  NONE = 0 << KIND_SHIFT ,
  MAT = 1 << KIND_SHIFT ,
  MATX = 2 << KIND_SHIFT ,
  STD_VECTOR = 3 << KIND_SHIFT ,
  STD_VECTOR_VECTOR = 4 << KIND_SHIFT ,
  STD_VECTOR_MAT = 5 << KIND_SHIFT ,
  OPENGL_BUFFER = 7 << KIND_SHIFT ,
  CUDA_HOST_MEM = 8 << KIND_SHIFT ,
  CUDA_GPU_MAT = 9 << KIND_SHIFT ,
  UMAT =10 << KIND_SHIFT ,
  STD_VECTOR_UMAT =11 << KIND_SHIFT ,
  STD_BOOL_VECTOR =12 << KIND_SHIFT ,
  STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT ,
  STD_ARRAY_MAT =15 << KIND_SHIFT ,
  CUDA_GPU_MATND =16 << KIND_SHIFT ,
  STD_VECTOR_CUDA_GPU_MAT_ND = 17 << KIND_SHIFT
}
 

公開メンバ関数

 _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< cuda::GpuMatND > &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 getGpuMatNDVector (std::vector< cuda::GpuMatND > &gpumv) 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
 
bool isVecVector () const
 
_InputArray::KindFlag kind () const
 
size_t offset (int i=-1) const
 
int rows (int i=-1) const
 
bool sameSize (const _InputArray &arr) const
 
MatShape shape (int i=-1) 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
 

静的公開メンバ関数

template<typename _Tp , std::size_t _Nm>
static _InputArray rawIn (const std::array< _Tp, _Nm > &arr)
 
template<typename _Tp >
static _InputArray rawIn (const std::vector< _Tp > &vec)
 

限定公開メンバ関数

void init (int _flags, const void *_obj)
 
void init (int _flags, const void *_obj, Size _sz)
 

限定公開変数類

int flags
 
void * obj
 
Size sz
 

詳細説明

読み取り専用の入力配列を OpenCV 関数に渡すためのプロキシクラスである。

これは次のように定義される。

typedef const _InputArray& InputArray;
This is the proxy class for passing read-only input arrays into OpenCV functions.
Definition mat.hpp:270
const _InputArray & InputArray
Definition mat.hpp:586

ここで 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を受け取る関数を見たときは、実際には MatMatxvector<T> などを渡せることを意味する(完全な一覧は上記を参照)。
  • 省略可能な入力引数: 入力配列の一部が空である可能性がある場合は、cv::noArray()(あるいは以前そうしていたであろう単純な cv::Mat())を渡す。
  • このクラスは引数を渡すためだけに設計されている。すなわち、通常はこの型のクラスメンバやローカル変数・グローバル変数を宣言すべきではない
  • 複数の型の配列を扱える独自の関数やクラスメソッドを設計したい場合は、それぞれの引数にInputArray(またはOutputArray)を使用できる。関数内では _InputArray::getMat() メソッドを使って配列の行列ヘッダを(データをコピーせずに)構築する。_InputArray::kind() を使って Matvector<> などを区別できるが、通常は必要ない。

InputArray を受け取る関数は次のように使用できる。

std::vector<Point2f> vec;
// points or a circle
for( int i = 0; i < 30; i++ )
vec.push_back(Point2f((float)(100 + 30*cos(i*CV_PI*2/5)),
(float)(100 - 30*sin(i*CV_PI*2/5))));
cv::transform(vec, vec, cv::Matx23f(0.707, -0.707, 10, 0.707, 0.707, 20));
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:386

すなわち、点を含む STL ベクトルを作り、Matx<float, 2, 3> インスタンスとしてインラインで作成した 2x3 行列を用いて、そのベクトルにインプレースのアフィン変換を適用している。

そのような関数は次のように実装できる(簡単のため、内部のアサーション文に従って非常に特定のケースを実装している)。

void myAffineTransform(InputArray _src, OutputArray _dst, InputArray _m)
{
// get Mat headers for input arrays. This is O(1) operation,
// unless _src and/or _m are matrix expressions.
Mat src = _src.getMat(), m = _m.getMat();
CV_Assert( src.type() == CV_32FC2 && m.type() == CV_32F && m.size() == Size(3, 2) );
// [re]create the output array so that it has the proper size and type.
// In case of Mat it calls Mat::create, in case of STL vector it calls vector::resize.
_dst.create(src.size(), src.type());
Mat dst = _dst.getMat();
for( int i = 0; i < src.rows; i++ )
for( int j = 0; j < src.cols; j++ )
{
Point2f pt = src.at<Point2f>(i, j);
dst.at<Point2f>(i, j) = Point2f(m.at<float>(0, 0)*pt.x +
m.at<float>(0, 1)*pt.y +
m.at<float>(0, 2),
m.at<float>(1, 0)*pt.x +
m.at<float>(1, 1)*pt.y +
m.at<float>(1, 2));
}
}
Comma-separated Matrix Initializer.
Definition mat.hpp:964
MatSize size
Definition mat.hpp:2511
_Tp & at(int i0=0)
Returns a reference to the specified array element.
int cols
Definition mat.hpp:2488
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
Definition mat.hpp:2488
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:338
Mat getMat(int idx=-1) const
This type is very similar to InputArray except that it is used for input/output and output function p...
Definition mat.hpp:410
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:108
#define CV_32F
Definition interface.h:59
#define CV_Assert(expr)
Checks a condition at runtime and throws exception if it fails.
Definition exception.hpp:198

もう1つの関連する型として InputArrayOfArrays があり、現在は InputArray のシノニムとして定義されている。

InputArray InputArrayOfArrays
Definition mat.hpp:587

これは、ベクトルのベクトル、または行列のベクトルのいずれかである関数引数を表す。Python/Java などのラッパーを正しく生成するには、別のシノニムが必要である。関数実装レベルでの使い方は似ているが、外側のベクトルの idx 番目の要素のヘッダを取得するには _InputArray::getMat(idx) を使用し、外側のベクトルの要素(ベクトル/行列)の数を求めるには _InputArray::size().area() を使用する。

一般に、型のサポートは cv::Mat 型に限られる。それ以外の型は禁止されている。しかし、場合によっては、cv::KeyPointcv::DMatch の配列のように、一般的でない独自の Mat 型の受け渡しをサポートする必要がある。このデータは画像データとして解釈されたり、通常の cv::Mat のように何らかの処理をされたりすることを意図していない。そのような独自の型を渡すには rawIn() / rawOut() / rawInOut() ラッパーを使用する。独自の型はMat互換の CV_8UC<N> 値(N = sizeof(T)、N <= CV_CN_MAX)としてラップされる。

samples/cpp/pca.cpp、および samples/peopledetect.cpp

列挙型メンバ詳解

◆ KindFlag

列挙値
KIND_SHIFT 
FIXED_TYPE 
FIXED_SIZE 
KIND_MASK 
NONE 
MAT 
MATX 
STD_VECTOR 
STD_VECTOR_VECTOR 
STD_VECTOR_MAT 
OPENGL_BUFFER 
CUDA_HOST_MEM 
CUDA_GPU_MAT 
UMAT 
STD_VECTOR_UMAT 
STD_BOOL_VECTOR 
STD_VECTOR_CUDA_GPU_MAT 
STD_ARRAY_MAT 
CUDA_GPU_MATND 
STD_VECTOR_CUDA_GPU_MAT_ND 

構築子と解体子の詳解

◆ _InputArray() [1/25]

cv::_InputArray::_InputArray ( )

◆ _InputArray() [2/25]

cv::_InputArray::_InputArray ( int _flags,
void * _obj )

◆ _InputArray() [3/25]

cv::_InputArray::_InputArray ( const Mat & m)

◆ _InputArray() [4/25]

cv::_InputArray::_InputArray ( const MatExpr & expr)

◆ _InputArray() [5/25]

cv::_InputArray::_InputArray ( const std::vector< Mat > & vec)

◆ _InputArray() [6/25]

template<typename _Tp >
cv::_InputArray::_InputArray ( const Mat_< _Tp > & m)

◆ _InputArray() [7/25]

template<typename _Tp >
cv::_InputArray::_InputArray ( const std::vector< _Tp > & vec)

◆ _InputArray() [8/25]

cv::_InputArray::_InputArray ( const std::vector< bool > & vec)

◆ _InputArray() [9/25]

template<typename _Tp >
cv::_InputArray::_InputArray ( const std::vector< std::vector< _Tp > > & vec)

◆ _InputArray() [10/25]

cv::_InputArray::_InputArray ( const std::vector< std::vector< bool > > & )
delete

◆ _InputArray() [11/25]

template<typename _Tp >
cv::_InputArray::_InputArray ( const std::vector< Mat_< _Tp > > & vec)

◆ _InputArray() [12/25]

template<typename _Tp >
cv::_InputArray::_InputArray ( const _Tp * vec,
int n )

◆ _InputArray() [13/25]

template<typename _Tp , int m, int n>
cv::_InputArray::_InputArray ( const Matx< _Tp, m, n > & matx)

◆ _InputArray() [14/25]

cv::_InputArray::_InputArray ( const double & val)

◆ _InputArray() [15/25]

cv::_InputArray::_InputArray ( const cuda::GpuMat & d_mat)

◆ _InputArray() [16/25]

cv::_InputArray::_InputArray ( const std::vector< cuda::GpuMat > & d_mat_array)

◆ _InputArray() [17/25]

cv::_InputArray::_InputArray ( const cuda::GpuMatND & d_mat)

◆ _InputArray() [18/25]

cv::_InputArray::_InputArray ( const std::vector< cuda::GpuMatND > & d_mat_array)

◆ _InputArray() [19/25]

cv::_InputArray::_InputArray ( const ogl::Buffer & buf)

◆ _InputArray() [20/25]

cv::_InputArray::_InputArray ( const cuda::HostMem & cuda_mem)

◆ _InputArray() [21/25]

template<typename _Tp >
cv::_InputArray::_InputArray ( const cudev::GpuMat_< _Tp > & m)

◆ _InputArray() [22/25]

cv::_InputArray::_InputArray ( const UMat & um)

◆ _InputArray() [23/25]

cv::_InputArray::_InputArray ( const std::vector< UMat > & umv)

◆ _InputArray() [24/25]

template<typename _Tp , std::size_t _Nm>
cv::_InputArray::_InputArray ( const std::array< _Tp, _Nm > & arr)

◆ _InputArray() [25/25]

template<std::size_t _Nm>
cv::_InputArray::_InputArray ( const std::array< Mat, _Nm > & arr)

◆ ~_InputArray()

cv::_InputArray::~_InputArray ( )

メンバ関数詳解

◆ channels()

int cv::_InputArray::channels ( int i = -1) const

◆ cols()

int cv::_InputArray::cols ( int i = -1) const

◆ copyTo() [1/2]

void cv::_InputArray::copyTo ( const _OutputArray & arr) const

◆ copyTo() [2/2]

void cv::_InputArray::copyTo ( const _OutputArray & arr,
const _InputArray & mask ) const

◆ depth()

int cv::_InputArray::depth ( int i = -1) const

◆ dims()

int cv::_InputArray::dims ( int i = -1) const

◆ empty() [1/2]

bool cv::_InputArray::empty ( ) const

◆ empty() [2/2]

bool cv::_InputArray::empty ( int i) const

◆ getFlags()

int cv::_InputArray::getFlags ( ) const

◆ getGpuMat()

cuda::GpuMat cv::_InputArray::getGpuMat ( ) const

◆ getGpuMatND()

cuda::GpuMatND cv::_InputArray::getGpuMatND ( ) const

◆ getGpuMatNDVector()

void cv::_InputArray::getGpuMatNDVector ( std::vector< cuda::GpuMatND > & gpumv) const

◆ getGpuMatVector()

void cv::_InputArray::getGpuMatVector ( std::vector< cuda::GpuMat > & gpumv) const

◆ getMat()

Mat cv::_InputArray::getMat ( int idx = -1) const

◆ getMat_()

Mat cv::_InputArray::getMat_ ( int idx = -1) const

◆ getMatVector()

void cv::_InputArray::getMatVector ( std::vector< Mat > & mv) const

◆ getObj()

void * cv::_InputArray::getObj ( ) const

◆ getOGlBuffer()

ogl::Buffer cv::_InputArray::getOGlBuffer ( ) const

◆ getSz()

Size cv::_InputArray::getSz ( ) const

◆ getUMat()

UMat cv::_InputArray::getUMat ( int idx = -1) const

◆ getUMatVector()

void cv::_InputArray::getUMatVector ( std::vector< UMat > & umv) const

◆ init() [1/2]

void cv::_InputArray::init ( int _flags,
const void * _obj )
protected

◆ init() [2/2]

void cv::_InputArray::init ( int _flags,
const void * _obj,
Size _sz )
protected

◆ isContinuous()

bool cv::_InputArray::isContinuous ( int i = -1) const

◆ isGpuMat()

bool cv::_InputArray::isGpuMat ( ) const

◆ isGpuMatND()

bool cv::_InputArray::isGpuMatND ( ) const

◆ isGpuMatVector()

bool cv::_InputArray::isGpuMatVector ( ) const

◆ isMat()

bool cv::_InputArray::isMat ( ) const

◆ isMatVector()

bool cv::_InputArray::isMatVector ( ) const

◆ isMatx()

bool cv::_InputArray::isMatx ( ) const

◆ isSubmatrix()

bool cv::_InputArray::isSubmatrix ( int i = -1) const

◆ isUMat()

bool cv::_InputArray::isUMat ( ) const

◆ isUMatVector()

bool cv::_InputArray::isUMatVector ( ) const

◆ isVector()

bool cv::_InputArray::isVector ( ) const

◆ isVecVector()

bool cv::_InputArray::isVecVector ( ) const

◆ kind()

_InputArray::KindFlag cv::_InputArray::kind ( ) const

◆ offset()

size_t cv::_InputArray::offset ( int i = -1) const

◆ rawIn() [1/2]

template<typename _Tp , std::size_t _Nm>
static _InputArray cv::_InputArray::rawIn ( const std::array< _Tp, _Nm > & arr)
static

◆ rawIn() [2/2]

template<typename _Tp >
static _InputArray cv::_InputArray::rawIn ( const std::vector< _Tp > & vec)
static

◆ rows()

int cv::_InputArray::rows ( int i = -1) const

◆ sameSize()

bool cv::_InputArray::sameSize ( const _InputArray & arr) const

◆ shape()

MatShape cv::_InputArray::shape ( int i = -1) const

◆ size()

Size cv::_InputArray::size ( int i = -1) const

◆ sizend()

int cv::_InputArray::sizend ( int * sz,
int i = -1 ) const

◆ step()

size_t cv::_InputArray::step ( int i = -1) const

◆ total()

size_t cv::_InputArray::total ( int i = -1) const

◆ type()

int cv::_InputArray::type ( int i = -1) const

メンバ変数詳解

◆ flags

int cv::_InputArray::flags
protected

◆ obj

void* cv::_InputArray::obj
protected

◆ sz

Size cv::_InputArray::sz
protected

このクラス詳解は次のファイルから抽出されました: