diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index 25ab93dfa..37741c399 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -289,10 +289,12 @@ static bool ocl_split( InputArray _m, OutputArrayOfArrays _mv ) return false; Size size = _m.size(); - std::vector & dst = *(std::vector *)_mv.getObj(); - dst.resize(cn); + _mv.create(cn, 1, depth); for (int i = 0; i < cn; ++i) - dst[i].create(size, depth); + _mv.create(size, depth, i); + + std::vector dst; + _mv.getUMatVector(dst); int argidx = k.set(0, ocl::KernelArg::ReadOnly(_m.getUMat())); for (int i = 0; i < cn; ++i) @@ -317,10 +319,19 @@ void cv::split(InputArray _m, OutputArrayOfArrays _mv) _mv.release(); return; } + CV_Assert( !_mv.fixedType() || _mv.empty() || _mv.type() == m.depth() ); - _mv.create(m.channels(), 1, m.depth()); - Mat* dst = &_mv.getMatRef(0); - split(m, dst); + + Size size = m.size(); + int depth = m.depth(), cn = m.channels(); + _mv.create(cn, 1, depth); + for (int i = 0; i < cn; ++i) + _mv.create(size, depth, i); + + std::vector dst; + _mv.getMatVector(dst); + + split(m, &dst[0]); } void cv::merge(const Mat* mv, size_t n, OutputArray _dst) @@ -404,7 +415,8 @@ namespace cv { static bool ocl_merge( InputArrayOfArrays _mv, OutputArray _dst ) { - const std::vector & src = *(const std::vector *)(_mv.getObj()); + std::vector src; + _mv.getUMatVector(src); CV_Assert(!src.empty()); int type = src[0].type(), depth = CV_MAT_DEPTH(type); @@ -651,8 +663,9 @@ static void getUMatIndex(const std::vector & um, int cn, int & idx, int & static bool ocl_mixChannels(InputArrayOfArrays _src, InputOutputArrayOfArrays _dst, const int* fromTo, size_t npairs) { - const std::vector & src = *(const std::vector *)_src.getObj(); - std::vector & dst = *(std::vector *)_dst.getObj(); + std::vector src, dst; + _src.getUMatVector(src); + _dst.getUMatVector(dst); size_t nsrc = src.size(), ndst = dst.size(); CV_Assert(nsrc > 0 && ndst > 0); @@ -718,7 +731,7 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst, if (npairs == 0 || fromTo == NULL) return; - CV_OCL_RUN(src.isUMatVector() && dst.isUMatVector(), + CV_OCL_RUN(dst.isUMatVector(), ocl_mixChannels(src, dst, fromTo, npairs)) bool src_is_mat = src.kind() != _InputArray::STD_VECTOR_MAT && @@ -747,7 +760,7 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst, if (fromTo.empty()) return; - CV_OCL_RUN(src.isUMatVector() && dst.isUMatVector(), + CV_OCL_RUN(dst.isUMatVector(), ocl_mixChannels(src, dst, &fromTo[0], fromTo.size()>>1)) bool src_is_mat = src.kind() != _InputArray::STD_VECTOR_MAT && diff --git a/modules/core/test/ocl/test_channels.cpp b/modules/core/test/ocl/test_channels.cpp index 09d709e91..f0dc10250 100644 --- a/modules/core/test/ocl/test_channels.cpp +++ b/modules/core/test/ocl/test_channels.cpp @@ -197,7 +197,7 @@ PARAM_TEST_CASE(Split, MatType, Channels, bool) } }; -OCL_TEST_P(Split, DISABLED_Accuracy) +OCL_TEST_P(Split, Accuracy) { for (int j = 0; j < test_loop_times; j++) {