From: Vadim Pisarevsky Date: Sat, 3 Dec 2011 20:19:33 +0000 (+0000) Subject: fixed single-mat input/output in mixChannels() (ticket #1446) X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~5769 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8989e0b07eda75d550e81af2fa2e14e8b456f4fd;p=platform%2Fupstream%2Fopencv.git fixed single-mat input/output in mixChannels() (ticket #1446) --- diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index c0a7c49..2fb5f27 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -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 _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); }