static inline std::ostream& operator << (std::ostream& out, const MatSize& msize)
{
- int i, dims = msize.p[-1];
+ int i, dims = msize.dims();
for( i = 0; i < dims; i++ )
{
- out << msize.p[i];
+ out << msize[i];
if( i < dims-1 )
out << " x ";
}
struct CV_EXPORTS MatSize
{
explicit MatSize(int* _p);
+ int dims() const;
Size operator()() const;
const int& operator[](int i) const;
int& operator[](int i);
- operator const int*() const;
+ operator const int*() const; // TODO OpenCV 4.0: drop this
bool operator == (const MatSize& sz) const;
bool operator != (const MatSize& sz) const;
: p(_p) {}
inline
+int MatSize::dims() const
+{
+ return (p - 1)[0];
+}
+
+inline
Size MatSize::operator()() const
{
- CV_DbgAssert(p[-1] <= 2);
+ CV_DbgAssert(dims() <= 2);
return Size(p[1], p[0]);
}
inline
const int& MatSize::operator[](int i) const
{
+ CV_DbgAssert(i < dims());
+#ifdef __OPENCV_BUILD
+ CV_DbgAssert(i >= 0);
+#endif
return p[i];
}
inline
int& MatSize::operator[](int i)
{
+ CV_DbgAssert(i < dims());
+#ifdef __OPENCV_BUILD
+ CV_DbgAssert(i >= 0);
+#endif
return p[i];
}
inline
bool MatSize::operator == (const MatSize& sz) const
{
- int d = p[-1];
- int dsz = sz.p[-1];
+ int d = dims();
+ int dsz = sz.dims();
if( d != dsz )
return false;
if( d == 2 )
static inline MatShape shape(const MatSize& sz)
{
- return shape(sz.p, sz[-1]);
+ return shape(sz.p, sz.dims());
}
static inline MatShape shape(const UMat& mat)
for (int i = 0; i < outputs.size(); ++i)
{
- CV_Assert(sliceRanges[i].size() <= inpShape[-1]);
+ CV_Assert(sliceRanges[i].size() <= inpShape.dims());
// Clamp.
for (int j = 0; j < sliceRanges[i].size(); ++j)
{
sliceRanges[i][j] = clamp(sliceRanges[i][j], inpShape[j]);
}
// Fill the rest of ranges.
- for (int j = sliceRanges[i].size(); j < inpShape[-1]; ++j)
+ for (int j = sliceRanges[i].size(); j < inpShape.dims(); ++j)
{
sliceRanges[i].push_back(Range::all());
}
// Third party copyrights are property of their respective owners.
#include "precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
#include "op_halide.hpp"
#ifdef HAVE_HALIDE
static MatShape getBufferShape(const MatSize& size)
{
- return getBufferShape(MatShape(size.p, size.p + size[-1]));
+ return getBufferShape(shape(size));
}
Halide::Buffer<float> wrapToHalideBuffer(const Mat& mat)
void getCanonicalSize(const MatSize& size, int* w, int* h, int* c, int* n)
{
- getCanonicalSize(MatShape(size.p, size.p + size[-1]), w, h, c, n);
+ getCanonicalSize(shape(size), w, h, c, n);
}
void getCanonicalSize(const MatShape& shape, int* width, int* height,