mirror of
https://github.com/opencv/opencv.git
synced 2025-06-06 00:43:52 +08:00
core: emit more clear messages in OutputArray::create()
This commit is contained in:
parent
3e3787ecb6
commit
261ad78122
@ -1247,6 +1247,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
|
||||
{
|
||||
CV_Assert( i < 0 );
|
||||
Mat& m = *(Mat*)obj;
|
||||
CV_Assert(!(m.empty() && fixedType() && fixedSize()) && "Can't reallocate empty Mat with locked layout (probably due to misused 'const' modifier)");
|
||||
if (allowTransposed && !m.empty() &&
|
||||
d == 2 && m.dims == 2 &&
|
||||
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] &&
|
||||
@ -1260,13 +1261,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
|
||||
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
|
||||
mtype = m.type();
|
||||
else
|
||||
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "");
|
||||
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "Can't reallocate Mat with locked type (probably due to misused 'const' modifier)");
|
||||
}
|
||||
if(fixedSize())
|
||||
{
|
||||
CV_CheckEQ(m.dims, d, "");
|
||||
CV_CheckEQ(m.dims, d, "Can't reallocate Mat with locked size (probably due to misused 'const' modifier)");
|
||||
for(int j = 0; j < d; ++j)
|
||||
CV_CheckEQ(m.size[j], sizes[j], "");
|
||||
CV_CheckEQ(m.size[j], sizes[j], "Can't reallocate Mat with locked size (probably due to misused 'const' modifier)");
|
||||
}
|
||||
m.create(d, sizes, mtype);
|
||||
return;
|
||||
@ -1276,6 +1277,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
|
||||
{
|
||||
CV_Assert( i < 0 );
|
||||
UMat& m = *(UMat*)obj;
|
||||
CV_Assert(!(m.empty() && fixedType() && fixedSize()) && "Can't reallocate empty UMat with locked layout (probably due to misused 'const' modifier)");
|
||||
if (allowTransposed && !m.empty() &&
|
||||
d == 2 && m.dims == 2 &&
|
||||
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] &&
|
||||
@ -1289,13 +1291,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
|
||||
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
|
||||
mtype = m.type();
|
||||
else
|
||||
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "");
|
||||
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "Can't reallocate UMat with locked type (probably due to misused 'const' modifier)");
|
||||
}
|
||||
if(fixedSize())
|
||||
{
|
||||
CV_CheckEQ(m.dims, d, "");
|
||||
CV_CheckEQ(m.dims, d, "Can't reallocate UMat with locked size (probably due to misused 'const' modifier)");
|
||||
for(int j = 0; j < d; ++j)
|
||||
CV_CheckEQ(m.size[j], sizes[j], "");
|
||||
CV_CheckEQ(m.size[j], sizes[j], "Can't reallocate UMat with locked size (probably due to misused 'const' modifier)");
|
||||
}
|
||||
m.create(d, sizes, mtype);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user