Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
prepares OpenCV for the arrival of _ArrayOps
This commit refactors the `init` functions into constructors, so that
the incoming `_ArrayOps` member properly initialised. We add a pointer
to an `_ArrayOps` object, but don't do anything with it just yet.
  • Loading branch information
cjdb committed Dec 16, 2024
commit b7fca6d0589ed82c4c1188abc41a866f34cfbc90
46 changes: 34 additions & 12 deletions modules/core/include/opencv2/core/mat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ CV_EXPORTS bool operator != (const MatShape& shape1, const MatShape& shape2);

CV__DEBUG_NS_BEGIN

struct CV_EXPORTS _ArrayOpsBase;
class CV_EXPORTS _OutputArray;

//////////////////////// Input/Output Array Arguments /////////////////////////////////
Expand Down Expand Up @@ -289,8 +290,8 @@ class CV_EXPORTS _InputArray
STD_ARRAY_MAT =15 << KIND_SHIFT
};

_InputArray();
_InputArray(int _flags, void* _obj);
_InputArray() = default;
template<class T> _InputArray(int flags, T* obj);
_InputArray(const Mat& m);
_InputArray(const MatExpr& expr);
_InputArray(const std::vector<Mat>& vec);
Expand Down Expand Up @@ -359,15 +360,18 @@ class CV_EXPORTS _InputArray
bool isVector() const;
bool isGpuMat() const;
bool isGpuMatVector() const;
~_InputArray();

protected:
int flags;
void* obj;
int flags = static_cast<int>(NONE);
void* obj = nullptr;
Size sz;
const _ArrayOpsBase* ops = nullptr;

template<class T>
_InputArray(int flags, T* obj, Size sz);

void init(int _flags, const void* _obj);
void init(int _flags, const void* _obj, Size _sz);
template<class T>
_InputArray(int flags, const T* obj, Size sz);
};
CV_ENUM_FLAGS(_InputArray::KindFlag)
__CV_ENUM_FLAGS_BITWISE_AND(_InputArray::KindFlag, int, _InputArray::KindFlag)
Expand Down Expand Up @@ -421,8 +425,13 @@ class CV_EXPORTS _OutputArray : public _InputArray
DEPTH_MASK_FLT = DEPTH_MASK_32F + DEPTH_MASK_64F
};

_OutputArray();
_OutputArray(int _flags, void* _obj);
_OutputArray() = default;

template<class T>
_OutputArray(int _flags, T* _obj)
: _InputArray(_flags, _obj)
{}

_OutputArray(Mat& m);
_OutputArray(std::vector<Mat>& vec);
_OutputArray(cuda::GpuMat& d_mat);
Expand Down Expand Up @@ -503,14 +512,23 @@ class CV_EXPORTS _OutputArray : public _InputArray

void move(UMat& u) const;
void move(Mat& m) const;
protected:
template<class T> _OutputArray(int _flags, T* _obj, Size _sz)
: _InputArray(_flags, _obj, _sz)
{}
};


class CV_EXPORTS _InputOutputArray : public _OutputArray
{
public:
_InputOutputArray();
_InputOutputArray(int _flags, void* _obj);
_InputOutputArray() = default;

template<class T>
_InputOutputArray(int _flags, T* _obj)
: _OutputArray(_flags, _obj)
{}

_InputOutputArray(Mat& m);
_InputOutputArray(std::vector<Mat>& vec);
_InputOutputArray(cuda::GpuMat& d_mat);
Expand Down Expand Up @@ -550,7 +568,11 @@ class CV_EXPORTS _InputOutputArray : public _OutputArray

template<typename _Tp> static _InputOutputArray rawInOut(std::vector<_Tp>& vec);
template<typename _Tp, std::size_t _Nm> _InputOutputArray rawInOut(std::array<_Tp, _Nm>& arr);

private:
template<class T>
_InputOutputArray(int _flags, T* _obj, Size _sz)
: _OutputArray(_flags, _obj, _sz)
{}
};

/** Helper to wrap custom types. @see InputArray */
Expand Down
Loading