mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 13:47:32 +08:00
added STD_VECTOR_UMAT support to _OutputArray::create
This commit is contained in:
parent
06acf7090c
commit
fa5492343a
@ -2318,6 +2318,65 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
|
||||
return;
|
||||
}
|
||||
|
||||
if( k == STD_VECTOR_UMAT )
|
||||
{
|
||||
std::vector<UMat>& v = *(std::vector<UMat>*)obj;
|
||||
|
||||
if( i < 0 )
|
||||
{
|
||||
CV_Assert( d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) );
|
||||
size_t len = sizes[0]*sizes[1] > 0 ? sizes[0] + sizes[1] - 1 : 0, len0 = v.size();
|
||||
|
||||
CV_Assert(!fixedSize() || len == len0);
|
||||
v.resize(len);
|
||||
if( fixedType() )
|
||||
{
|
||||
int _type = CV_MAT_TYPE(flags);
|
||||
for( size_t j = len0; j < len; j++ )
|
||||
{
|
||||
if( v[j].type() == _type )
|
||||
continue;
|
||||
CV_Assert( v[j].empty() );
|
||||
v[j].flags = (v[j].flags & ~CV_MAT_TYPE_MASK) | _type;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CV_Assert( i < (int)v.size() );
|
||||
UMat& m = v[i];
|
||||
|
||||
if( allowTransposed )
|
||||
{
|
||||
if( !m.isContinuous() )
|
||||
{
|
||||
CV_Assert(!fixedType() && !fixedSize());
|
||||
m.release();
|
||||
}
|
||||
|
||||
if( d == 2 && m.dims == 2 && m.u &&
|
||||
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] )
|
||||
return;
|
||||
}
|
||||
|
||||
if(fixedType())
|
||||
{
|
||||
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
|
||||
mtype = m.type();
|
||||
else
|
||||
CV_Assert(!fixedType() || (CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0));
|
||||
}
|
||||
if(fixedSize())
|
||||
{
|
||||
CV_Assert(m.dims == d);
|
||||
for(int j = 0; j < d; ++j)
|
||||
CV_Assert(m.size[j] == sizes[j]);
|
||||
}
|
||||
|
||||
m.create(d, sizes, mtype);
|
||||
return;
|
||||
}
|
||||
|
||||
CV_Error(Error::StsNotImplemented, "Unknown/unsupported array type");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user