1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 07:13:02 +04:00

Added new overloaded functions for Mat and UMat that accepts std::vector<int> instead of int * for the sizes on a N-dimensional array.

This allows for an N-dimensional array to be setup in one line instead of two when using C++11 initializer lists. cv::Mat(3, {zDim, yDim, xDim}, ...) can be used instead of having to create an int pointer to hold the size array.
This commit is contained in:
Addison Elliott
2016-12-14 12:56:43 -06:00
parent 37cbcf024c
commit fa6692afcf
4 changed files with 77 additions and 0 deletions
+16
View File
@@ -439,6 +439,11 @@ void Mat::create(int d, const int* _sizes, int _type)
finalizeHdr(*this);
}
void Mat::create(const std::vector<int>& _sizes, int _type)
{
create((int)_sizes.size(), _sizes.data(), _type);
}
void Mat::copySize(const Mat& m)
{
setSize(*this, m.dims, 0, 0);
@@ -541,6 +546,17 @@ Mat::Mat(int _dims, const int* _sizes, int _type, void* _data, const size_t* _st
}
Mat::Mat(const std::vector<int>& _sizes, int _type, void* _data, const size_t* _steps)
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
datalimit(0), allocator(0), u(0), size(&rows)
{
flags |= CV_MAT_TYPE(_type);
datastart = data = (uchar*)_data;
setSize(*this, (int)_sizes.size(), _sizes.data(), _steps, true);
finalizeHdr(*this);
}
Mat::Mat(const Mat& m, const Range* ranges)
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
datalimit(0), allocator(0), u(0), size(&rows)