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

add API to reinterpret Mat type

This commit is contained in:
gaohaoyuan
2024-07-11 17:55:08 +08:00
committed by gaohaoyuan
parent 1ca526dcdb
commit 603344fa54
4 changed files with 62 additions and 0 deletions
+10
View File
@@ -1261,6 +1261,16 @@ Mat Mat::reshape(int _cn, const std::vector<int>& _newshape) const
return reshape(_cn, (int)_newshape.size(), &_newshape[0]);
}
Mat Mat::reinterpret(int type) const
{
type = CV_MAT_TYPE(type);
CV_Assert(CV_ELEM_SIZE(this->type()) == CV_ELEM_SIZE(type));
Mat m = *this;
m.flags = (m.flags & ~CV_MAT_TYPE_MASK) | type;
m.updateContinuityFlag();
return m;
}
Mat Mat::diag(const Mat& d)
{
CV_Assert( d.cols == 1 || d.rows == 1 );
+6
View File
@@ -1656,6 +1656,12 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
CV_Error(Error::StsNotImplemented, "Unknown/unsupported array type");
}
Mat _OutputArray::reinterpret(int mtype) const
{
mtype = CV_MAT_TYPE(mtype);
return getMat().reinterpret(mtype);
}
void _OutputArray::createSameSize(const _InputArray& arr, int mtype) const
{
int arrsz[CV_MAX_DIM], d = arr.sizend(arrsz);