## 12/10/2013

### OpenCV, What is the InputArray?

The 'InputArray' is used usually in OpenCV function parameter.
I think that is made to transfer vector< >, Matx< >, Vec< > and scalar easily.

This is the document on the opencv.org.

### InputArray and OutputArray¶

Many OpenCV functions process dense 2-dimensional or multi-dimensional numerical arrays. Usually, such functions take cpp:class:Mat as parameters, but in some cases it’s more convenient to use std::vector<> (for a point set, for example) or Matx<> (for 3x3 homography matrix and such). To avoid many duplicates in the API, special “proxy” classes have been introduced. The base “proxy” class is InputArray. It is used for passing read-only arrays on a function input. The derived from InputArray class OutputArray is used to specify an output array for a function. Normally, you should not care of those intermediate types (and you should not declare variables of those types explicitly) - it will all just work automatically. You can assume that instead of InputArray/OutputArray you can always use Mat, std::vector<>, Matx<>, Vec<> or Scalar. When a function has an optional input or output array, and you do not have or do not want one, pass cv::noArray().

So I tested the 'InputArray' by programming.
Reference this source code.

/////
using namespace std;

void main()
{

///////////////////////////////////////////
///Test #1
std::vector< cv::Mat > inImgs;

//input
cv::InputArray imgs = inImgs;

//property
printf("Total = %d, Size=(%d,%d)\n", imgs.total(), imgs.size().width, imgs.size().height );

//copy;
std::vector< cv::Mat > inFunction;
imgs.getMatVector( inFunction );

//Test inFunction
cv::imshow("a",inFunction[0]);

cv::waitKey(0);

}

/////
output