_dst.create(src.size(), src.type());
GpuMat dst = getOutputMat(_dst, src.size(), src.type(), stream);
+ if (src.data == dst.data && ((src.cols & 1) == 1 || (src.rows & 1) == 1))
+ CV_Error(Error::BadROISize, "In-place version of flip only accepts even width/height");
- if (src.refcount != dst.refcount)
+ if (src.data != dst.data)
funcs[src.depth()][src.channels() - 1](src, dst, flipCode, StreamAccessor::getStream(stream));
else // in-place
ifuncs[src.depth()][src.channels() - 1](src, flipCode, StreamAccessor::getStream(stream));
CUDA_TEST_P(Flip, AccuracyInplace)
{
+ size.width = (size.width >> 1) << 1; // in-place version only accepts even number
+ size.height = (size.height >> 1) << 1; // in-place version only accepts even number
cv::Mat src = randomMat(size, type);
cv::cuda::GpuMat srcDst = loadMat(src, useRoi);