提交 8989e0b0 编写于 作者: V Vadim Pisarevsky

fixed single-mat input/output in mixChannels() (ticket #1446)

上级 3ae22014
...@@ -508,14 +508,21 @@ void cv::mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst, ...@@ -508,14 +508,21 @@ void cv::mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst,
{ {
if(fromTo.empty()) if(fromTo.empty())
return; 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_Assert(fromTo.size()%2 == 0 && nsrc > 0 && ndst > 0);
cv::AutoBuffer<Mat> _buf(nsrc + ndst); cv::AutoBuffer<Mat> _buf(nsrc + ndst);
Mat* buf = _buf; Mat* buf = _buf;
for( i = 0; i < nsrc; i++ ) 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++ ) 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); mixChannels(&buf[0], nsrc, &buf[nsrc], ndst, &fromTo[0], fromTo.size()/2);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册