Updated by Alexander Shishkov about 13 years ago

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> [[DevMem]]2D_<D> dst, UnOp [[UnOp]] op, Mask mask, cudaStream_t stream)
{
typedef TransformFunctorTraits]]<UnOp> [[TransformFunctorTraits]]<UnOp> ft;
- transform_detail::TransformDispatcher<VecTraits<T>::cn == 1 && VecTraits<D>::cn [[VecTraits]]<D>::cn == 1 && ft::smart_shift != 1>::call(src, dst, op, mask, stream);
+ transform_detail::TransformDispatcher<false// VecTraits<T>::cn [[VecTraits]]<T>::cn == 1 && VecTraits<D>::cn [[VecTraits]]<D>::cn == 1 && ft::smart_shift != 1
+ >::call(src, dst, op, mask, stream);
}

template <typename T1, typename T2, typename D, typename BinOp, [[BinOp]], typename Mask>

thank You for Your consideration.

Back