|
|
|
@ -160,22 +160,49 @@ static inline MatShape shape(int a0, int a1=-1, int a2=-1, int a3=-1) |
|
|
|
|
|
|
|
|
|
static inline int total(const MatShape& shape, int start = -1, int end = -1) |
|
|
|
|
{ |
|
|
|
|
if (start == -1) start = 0; |
|
|
|
|
if (end == -1) end = (int)shape.size(); |
|
|
|
|
|
|
|
|
|
if (shape.empty()) |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
int dims = (int)shape.size(); |
|
|
|
|
|
|
|
|
|
if (start == -1) start = 0; |
|
|
|
|
if (end == -1) end = dims; |
|
|
|
|
|
|
|
|
|
CV_CheckLE(0, start, ""); |
|
|
|
|
CV_CheckLE(start, end, ""); |
|
|
|
|
CV_CheckLE(end, dims, ""); |
|
|
|
|
|
|
|
|
|
int elems = 1; |
|
|
|
|
CV_Assert(start <= (int)shape.size() && end <= (int)shape.size() && |
|
|
|
|
start <= end); |
|
|
|
|
for(int i = start; i < end; i++) |
|
|
|
|
for (int i = start; i < end; i++) |
|
|
|
|
{ |
|
|
|
|
elems *= shape[i]; |
|
|
|
|
} |
|
|
|
|
return elems; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: rename to countDimsElements()
|
|
|
|
|
static inline int total(const Mat& mat, int start = -1, int end = -1) |
|
|
|
|
{ |
|
|
|
|
if (mat.empty()) |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
int dims = mat.dims; |
|
|
|
|
|
|
|
|
|
if (start == -1) start = 0; |
|
|
|
|
if (end == -1) end = dims; |
|
|
|
|
|
|
|
|
|
CV_CheckLE(0, start, ""); |
|
|
|
|
CV_CheckLE(start, end, ""); |
|
|
|
|
CV_CheckLE(end, dims, ""); |
|
|
|
|
|
|
|
|
|
int elems = 1; |
|
|
|
|
for (int i = start; i < end; i++) |
|
|
|
|
{ |
|
|
|
|
elems *= mat.size[i]; |
|
|
|
|
} |
|
|
|
|
return elems; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static inline MatShape concat(const MatShape& a, const MatShape& b) |
|
|
|
|
{ |
|
|
|
|
MatShape c = a; |
|
|
|
|