This is the proxy class for passing read-only input arrays into OpenCV functions.
More...
|
| _InputArray () |
|
template<typename _Tp > |
| _InputArray (const _Tp *vec, int n) |
|
| _InputArray (const cuda::GpuMat &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 |
|
int | getFlags () const |
|
cuda::GpuMat | getGpuMat () 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 | 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 |
|
This is the proxy class for passing read-only input arrays into OpenCV functions.
It is defined as:
const _InputArray & InputArray
Definition: mat.hpp:441
where _InputArray is a class that can be constructed from Mat
, Mat_<T>
, Matx<T, m, n>
, std::vector<T>
, std::vector<std::vector<T> >
, std::vector<Mat>
, std::vector<Mat_<T> >
, UMat
, std::vector<UMat>
or double
. It can also be constructed from a matrix expression.
Since this is mostly implementation-level class, and its interface may change in future versions, we do not describe it in details. There are a few key things, though, that should be kept in mind:
- When you see in the reference manual or in OpenCV source code a function that takes InputArray, it means that you can actually pass
Mat
, Matx
, vector<T>
etc. (see above the complete list).
- Optional input arguments: If some of the input arrays may be empty, pass cv::noArray() (or simply cv::Mat() as you probably did before).
- The class is designed solely for passing parameters. That is, normally you should not declare class members, local and global variables of this type.
- If you want to design your own function or a class method that can operate of arrays of multiple types, you can use InputArray (or OutputArray) for the respective parameters. Inside a function you should use _InputArray::getMat() method to construct a matrix header for the array (without copying data). _InputArray::kind() can be used to distinguish Mat from
vector<>
etc., but normally it is not needed.
Here is how you can use a function that takes 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.
#define CV_PI
Definition: cvdef.h:366
Quat< T > cos(const Quat< T > &q)
Quat< T > sin(const Quat< T > &q)
That is, we form an STL vector containing points, and apply in-place affine transformation to the vector using the 2x3 matrix created inline as Matx<float, 2, 3>
instance.
Here is how such a function can be implemented (for simplicity, we implement a very specific case of it, according to the assertion statement inside) :
{
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:811
MatSize size
Definition: mat.hpp:2159
_Tp & at(int i0=0)
Returns a reference to the specified array element.
int cols
Definition: mat.hpp:2137
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
Definition: mat.hpp:2137
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:295
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:342
There is another related type, InputArrayOfArrays, which is currently defined as a synonym for InputArray:
InputArray InputArrayOfArrays
Definition: mat.hpp:442
It denotes function arguments that are either vectors of vectors or vectors of matrices. A separate synonym is needed to generate Python/Java etc. wrappers properly. At the function implementation level their use is similar, but _InputArray::getMat(idx) should be used to get header for the idx-th component of the outer vector and _InputArray::size().area() should be used to find the number of components (vectors/matrices) of the outer vector.
In general, type support is limited to cv::Mat types. Other types are forbidden. But in some cases we need to support passing of custom non-general Mat types, like arrays of cv::KeyPoint, cv::DMatch, etc. This data is not intended to be interpreted as an image data, or processed somehow like regular cv::Mat. To pass such custom type use rawIn() / rawOut() / rawInOut() wrappers. Custom type is wrapped as Mat-compatible CV_8UC<N>
values (N = sizeof(T), N <= CV_CN_MAX).
- Examples
- samples/cpp/pca.cpp, and samples/cpp/peopledetect.cpp.