mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
core: fix condition in OutputArray::create(allowTransposed=True)
This commit is contained in:
parent
e36a3acbc0
commit
7366eebebb
@ -1287,16 +1287,11 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
|
|||||||
{
|
{
|
||||||
CV_Assert( i < 0 );
|
CV_Assert( i < 0 );
|
||||||
Mat& m = *(Mat*)obj;
|
Mat& m = *(Mat*)obj;
|
||||||
if( allowTransposed )
|
if (allowTransposed && !m.empty() &&
|
||||||
|
d == 2 && m.dims == 2 &&
|
||||||
|
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] &&
|
||||||
|
m.isContinuous())
|
||||||
{
|
{
|
||||||
if( !m.isContinuous() )
|
|
||||||
{
|
|
||||||
CV_Assert(!fixedType() && !fixedSize());
|
|
||||||
m.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( d == 2 && m.dims == 2 && m.data &&
|
|
||||||
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] )
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1305,13 +1300,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 )
|
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
|
||||||
mtype = m.type();
|
mtype = m.type();
|
||||||
else
|
else
|
||||||
CV_Assert(CV_MAT_TYPE(mtype) == m.type());
|
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "");
|
||||||
}
|
}
|
||||||
if(fixedSize())
|
if(fixedSize())
|
||||||
{
|
{
|
||||||
CV_Assert(m.dims == d);
|
CV_CheckEQ(m.dims, d, "");
|
||||||
for(int j = 0; j < d; ++j)
|
for(int j = 0; j < d; ++j)
|
||||||
CV_Assert(m.size[j] == sizes[j]);
|
CV_CheckEQ(m.size[j], sizes[j], "");
|
||||||
}
|
}
|
||||||
m.create(d, sizes, mtype);
|
m.create(d, sizes, mtype);
|
||||||
return;
|
return;
|
||||||
@ -1321,16 +1316,11 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
|
|||||||
{
|
{
|
||||||
CV_Assert( i < 0 );
|
CV_Assert( i < 0 );
|
||||||
UMat& m = *(UMat*)obj;
|
UMat& m = *(UMat*)obj;
|
||||||
if( allowTransposed )
|
if (allowTransposed && !m.empty() &&
|
||||||
|
d == 2 && m.dims == 2 &&
|
||||||
|
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] &&
|
||||||
|
m.isContinuous())
|
||||||
{
|
{
|
||||||
if( !m.isContinuous() )
|
|
||||||
{
|
|
||||||
CV_Assert(!fixedType() && !fixedSize());
|
|
||||||
m.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( d == 2 && m.dims == 2 && !m.empty() &&
|
|
||||||
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] )
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1339,13 +1329,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 )
|
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
|
||||||
mtype = m.type();
|
mtype = m.type();
|
||||||
else
|
else
|
||||||
CV_Assert(CV_MAT_TYPE(mtype) == m.type());
|
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "");
|
||||||
}
|
}
|
||||||
if(fixedSize())
|
if(fixedSize())
|
||||||
{
|
{
|
||||||
CV_Assert(m.dims == d);
|
CV_CheckEQ(m.dims, d, "");
|
||||||
for(int j = 0; j < d; ++j)
|
for(int j = 0; j < d; ++j)
|
||||||
CV_Assert(m.size[j] == sizes[j]);
|
CV_CheckEQ(m.size[j], sizes[j], "");
|
||||||
}
|
}
|
||||||
m.create(d, sizes, mtype);
|
m.create(d, sizes, mtype);
|
||||||
return;
|
return;
|
||||||
|
@ -177,6 +177,13 @@ TEST(Core_OutputArray, FixedType)
|
|||||||
EXPECT_EQ(2, num_defaultResult);
|
EXPECT_EQ(2, num_defaultResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Core_OutputArrayCreate, _13772)
|
||||||
|
{
|
||||||
|
cv::Mat1d mat;
|
||||||
|
cv::OutputArray o(mat);
|
||||||
|
ASSERT_NO_THROW(o.create(3, 5, CV_64F, -1, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST(Core_String, find_last_of__with__empty_string)
|
TEST(Core_String, find_last_of__with__empty_string)
|
||||||
|
Loading…
Reference in New Issue
Block a user