InputArray和OutputArray
源码路径:~/opencv-2.4.9/modules/core/include/opencv2/core/core.hpp
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> >
or std::vector<Mat>
. It can also be constructed from a matrix expression.
1 typedef const _InputArray& InputArray; 2 typedef InputArray InputArrayOfArrays; 3 typedef const _OutputArray& OutputArray; 4 typedef OutputArray OutputArrayOfArrays; 5 typedef OutputArray InputOutputArray; 6 typedef OutputArray InputOutputArrayOfArrays;
1 /*! 2 Proxy datatype for passing Mat's and vector<>'s as input parameters 3 */ 4 class CV_EXPORTS _InputArray 5 { 6 public: 7 enum { 8 KIND_SHIFT = 16, 9 FIXED_TYPE = 0x8000 << KIND_SHIFT, 10 FIXED_SIZE = 0x4000 << KIND_SHIFT, 11 KIND_MASK = ~(FIXED_TYPE|FIXED_SIZE) - (1 << KIND_SHIFT) + 1, 12 13 NONE = 0 << KIND_SHIFT, 14 MAT = 1 << KIND_SHIFT, 15 MATX = 2 << KIND_SHIFT, 16 STD_VECTOR = 3 << KIND_SHIFT, 17 STD_VECTOR_VECTOR = 4 << KIND_SHIFT, 18 STD_VECTOR_MAT = 5 << KIND_SHIFT, 19 EXPR = 6 << KIND_SHIFT, 20 OPENGL_BUFFER = 7 << KIND_SHIFT, 21 OPENGL_TEXTURE = 8 << KIND_SHIFT, 22 GPU_MAT = 9 << KIND_SHIFT, 23 OCL_MAT =10 << KIND_SHIFT 24 }; 25 _InputArray(); 26 27 _InputArray(const Mat& m); 28 _InputArray(const MatExpr& expr); 29 template<typename _Tp> _InputArray(const _Tp* vec, int n); 30 template<typename _Tp> _InputArray(const vector<_Tp>& vec); 31 template<typename _Tp> _InputArray(const vector<vector<_Tp> >& vec); 32 _InputArray(const vector<Mat>& vec); 33 template<typename _Tp> _InputArray(const vector<Mat_<_Tp> >& vec); 34 template<typename _Tp> _InputArray(const Mat_<_Tp>& m); 35 template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx); 36 _InputArray(const Scalar& s); 37 _InputArray(const double& val); 38 // < Deprecated 39 _InputArray(const GlBuffer& buf); 40 _InputArray(const GlTexture& tex); 41 // > 42 _InputArray(const gpu::GpuMat& d_mat); 43 _InputArray(const ogl::Buffer& buf); 44 _InputArray(const ogl::Texture2D& tex); 45 46 virtual Mat getMat(int i=-1) const; 47 virtual void getMatVector(vector<Mat>& mv) const; 48 // < Deprecated 49 virtual GlBuffer getGlBuffer() const; 50 virtual GlTexture getGlTexture() const; 51 // > 52 virtual gpu::GpuMat getGpuMat() const; 53 /*virtual*/ ogl::Buffer getOGlBuffer() const; 54 /*virtual*/ ogl::Texture2D getOGlTexture2D() const; 55 56 virtual int kind() const; 57 virtual Size size(int i=-1) const; 58 virtual size_t total(int i=-1) const; 59 virtual int type(int i=-1) const; 60 virtual int depth(int i=-1) const; 61 virtual int channels(int i=-1) const; 62 virtual bool empty() const; 63 64 #ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY 65 virtual ~_InputArray(); 66 #endif 67 68 int flags; 69 void* obj; 70 Size sz; 71 };
1 /*! 2 Proxy datatype for passing Mat's and vector<>'s as input parameters 3 */ 4 class CV_EXPORTS _OutputArray : public _InputArray 5 { 6 public: 7 _OutputArray(); 8 9 _OutputArray(Mat& m); 10 template<typename _Tp> _OutputArray(vector<_Tp>& vec); 11 template<typename _Tp> _OutputArray(vector<vector<_Tp> >& vec); 12 _OutputArray(vector<Mat>& vec); 13 template<typename _Tp> _OutputArray(vector<Mat_<_Tp> >& vec); 14 template<typename _Tp> _OutputArray(Mat_<_Tp>& m); 15 template<typename _Tp, int m, int n> _OutputArray(Matx<_Tp, m, n>& matx); 16 template<typename _Tp> _OutputArray(_Tp* vec, int n); 17 _OutputArray(gpu::GpuMat& d_mat); 18 _OutputArray(ogl::Buffer& buf); 19 _OutputArray(ogl::Texture2D& tex); 20 21 _OutputArray(const Mat& m); 22 template<typename _Tp> _OutputArray(const vector<_Tp>& vec); 23 template<typename _Tp> _OutputArray(const vector<vector<_Tp> >& vec); 24 _OutputArray(const vector<Mat>& vec); 25 template<typename _Tp> _OutputArray(const vector<Mat_<_Tp> >& vec); 26 template<typename _Tp> _OutputArray(const Mat_<_Tp>& m); 27 template<typename _Tp, int m, int n> _OutputArray(const Matx<_Tp, m, n>& matx); 28 template<typename _Tp> _OutputArray(const _Tp* vec, int n); 29 _OutputArray(const gpu::GpuMat& d_mat); 30 _OutputArray(const ogl::Buffer& buf); 31 _OutputArray(const ogl::Texture2D& tex); 32 33 virtual bool fixedSize() const; 34 virtual bool fixedType() const; 35 virtual bool needed() const; 36 virtual Mat& getMatRef(int i=-1) const; 37 /*virtual*/ gpu::GpuMat& getGpuMatRef() const; 38 /*virtual*/ ogl::Buffer& getOGlBufferRef() const; 39 /*virtual*/ ogl::Texture2D& getOGlTexture2DRef() const; 40 virtual void create(Size sz, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const; 41 virtual void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const; 42 virtual void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const; 43 virtual void release() const; 44 virtual void clear() const; 45 46 #ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY 47 virtual ~_OutputArray(); 48 #endif 49 };