mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
fixed single-mat input/output in mixChannels() (ticket #1446)
This commit is contained in:
parent
3ae22014a0
commit
8989e0b07e
@ -508,14 +508,21 @@ void cv::mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst,
|
||||
{
|
||||
if(fromTo.empty())
|
||||
return;
|
||||
int i, nsrc = (int)src.total(), ndst = (int)dst.total();
|
||||
bool src_is_mat = src.kind() != _InputArray::STD_VECTOR_MAT &&
|
||||
src.kind() != _InputArray::STD_VECTOR_VECTOR;
|
||||
bool dst_is_mat = dst.kind() != _InputArray::STD_VECTOR_MAT &&
|
||||
dst.kind() != _InputArray::STD_VECTOR_VECTOR;
|
||||
int i;
|
||||
int nsrc = src_is_mat ? 1 : (int)src.total();
|
||||
int ndst = dst_is_mat ? 1 : (int)dst.total();
|
||||
|
||||
CV_Assert(fromTo.size()%2 == 0 && nsrc > 0 && ndst > 0);
|
||||
cv::AutoBuffer<Mat> _buf(nsrc + ndst);
|
||||
Mat* buf = _buf;
|
||||
for( i = 0; i < nsrc; i++ )
|
||||
buf[i] = src.getMat(i);
|
||||
buf[i] = src.getMat(src_is_mat ? -1 : i);
|
||||
for( i = 0; i < ndst; i++ )
|
||||
buf[nsrc + i] = dst.getMat(i);
|
||||
buf[nsrc + i] = dst.getMat(dst_is_mat ? -1 : i);
|
||||
mixChannels(&buf[0], nsrc, &buf[nsrc], ndst, &fromTo[0], fromTo.size()/2);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user