diff --git a/samples/cpp/tutorial_code/gpu/gpu-thrust-interop/Thrust_interop.hpp b/samples/cpp/tutorial_code/gpu/gpu-thrust-interop/Thrust_interop.hpp index 4f44d51ce..7e880b88e 100644 --- a/samples/cpp/tutorial_code/gpu/gpu-thrust-interop/Thrust_interop.hpp +++ b/samples/cpp/tutorial_code/gpu/gpu-thrust-interop/Thrust_interop.hpp @@ -42,7 +42,10 @@ template thrust::permutation_iterator, thrust::transform_iterator, thrust::counting_iterator>> GpuMatBeginItr(cv::cuda::GpuMat mat, int channel = 0) { if (channel == -1) + { mat = mat.reshape(1); + channel = 0; + } CV_Assert(mat.depth() == cv::DataType::depth); CV_Assert(channel < mat.channels()); return thrust::make_permutation_iterator(thrust::device_pointer_cast(mat.ptr(0) + channel), @@ -59,7 +62,10 @@ template thrust::permutation_iterator, thrust::transform_iterator, thrust::counting_iterator>> GpuMatEndItr(cv::cuda::GpuMat mat, int channel = 0) { if (channel == -1) + { mat = mat.reshape(1); + channel = 0; + } CV_Assert(mat.depth() == cv::DataType::depth); CV_Assert(channel < mat.channels()); return thrust::make_permutation_iterator(thrust::device_pointer_cast(mat.ptr(0) + channel),