cv::gpu::convertTo function fails on continuous matrices (Bug #1567)


Added by navywoe - about 13 years ago. Updated almost 13 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:Vladislav Vinogradov % Done:

0%

Category:gpu (cuda)
Target version:2.4.0
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

The gpu convertTo function does not work if the matrix has been created with the createContinuous function. On cuda 1.0 the function silently returns incorrect result, in cuda 2.0 it returns an error message stating unknown cause. I have attached a sample code and a sample input so the error would be reproducible.

After further investigating the error it turns out that there are two implementations of convertTo: transformSmart and transformSimple. Both functions are implemented in
modules/gpu/src/opencv2/gpu/device/detail/transform_detail.hpp
If I manually select transformSimple with the following patch, the above example works:
Index: modules/gpu/src/opencv2/gpu/device/transform.hpp ===================================================================
--- modules/gpu/src/opencv2/gpu/device/transform.hpp (revision 7197)
+++ modules/gpu/src/opencv2/gpu/device/transform.hpp (working copy)
@ -53,7 +53,8 @
static inline void transform(DevMem2D_<T> src, DevMem2D_<D> dst, UnOp op, Mask mask, cudaStream_t stream) {
typedef TransformFunctorTraits]]<UnOp> ft;
- transform_detail::TransformDispatcher<VecTraits<T>::cn 1 && VecTraits&lt;D&gt;::cn 1 && ft::smart_shift != 1>::call(src, dst, op, mask, stream);
+ transform_detail::TransformDispatcher<false// VecTraits<T>::cn 1 && VecTraits&lt;D&gt;::cn 1 && ft::smart_shift != 1
+ >::call(src, dst, op, mask, stream);
}

template &lt;typename T1, typename T2, typename D, typename BinOp, typename Mask&gt;

thank You for Your consideration.


opencv_ticket_1567.tar.bz2 - this little example produces wrong results. (3.9 MB) navywoe -, 2012-01-26 10:07 am


Associated revisions

Revision 3ec2f7f5
Added by Vladislav Vinogradov about 13 years ago

fixed gpu::device::transform with non-aligned sources (Ticket #1567)

Revision 685eceb6
Added by Roman Donchenko over 11 years ago

Merge pull request #1567 from ilya-lavrenov:warn_fix

History

Updated by Anatoly Baksheev about 13 years ago

Thanks for the report. We will investigate this. But most likely this won't be fixed.

Just optimized version of transform assumes that all rows are aligned. Unaligned reading causes undefined behavior. All GpuMat allocations return 'right' memory, createContinuous can violate the requirement.

Maybe we will add define/CMake flag that disables the acceleration or leave "as is".

Vlad, let's discuss this in Monday.

  • Status deleted (Open)

Updated by Vladislav Vinogradov about 13 years ago

I fixed this problem in transform (call transformSimple for non aligned memory).
But some other gpu functions (remap, resize, warpAffine, warpPerspective and some other) still won't work with non aligned memory, because these functions use texture memory, which require aligned memory.

Updated by Alexander Shishkov about 13 years ago

  • Description changed from The gpu convertTo function does not work if the matrix has been created with ... to The gpu convertTo function does not work if the matrix has been created with ... More

Updated by Vladislav Vinogradov about 13 years ago

  • Status set to Done

Updated by Andrey Kamaev almost 13 years ago

  • Target version set to 2.4.0

Also available in: Atom PDF