fixed failure in Tonemap test
authorVadim Pisarevsky <vadim.pisarevsky@gmail.com>
Wed, 20 Nov 2013 00:20:24 +0000 (19:20 -0500)
committerVadim Pisarevsky <vadim.pisarevsky@gmail.com>
Wed, 20 Nov 2013 00:20:24 +0000 (19:20 -0500)
modules/core/src/arithm.cpp
modules/core/src/ocl.cpp
modules/core/src/precomp.hpp
modules/core/src/umatrix.cpp
modules/imgproc/src/color.cpp
modules/imgproc/src/imgwarp.cpp
modules/imgproc/src/precomp.hpp

index a21a1cc..a2b8a9e 100644 (file)
@@ -47,6 +47,7 @@
 // */
 
 #include "precomp.hpp"
+#include "opencl_kernels.hpp"
 
 namespace cv
 {
index 3592760..b2181df 100644 (file)
@@ -3038,7 +3038,7 @@ const char* typeToStr(int t)
         "?", "?", "?", "?"
     };
     int cn = CV_MAT_CN(t);
-    return cn >= 4 ? "?" : tab[CV_MAT_DEPTH(t)*4 + cn-1];
+    return cn > 4 ? "?" : tab[CV_MAT_DEPTH(t)*4 + cn-1];
 }
 
 const char* memopTypeToStr(int t)
@@ -3055,7 +3055,7 @@ const char* memopTypeToStr(int t)
         "?", "?", "?", "?"
     };
     int cn = CV_MAT_CN(t);
-    return cn >= 4 ? "?" : tab[CV_MAT_DEPTH(t)*4 + cn-1];
+    return cn > 4 ? "?" : tab[CV_MAT_DEPTH(t)*4 + cn-1];
 }
 
 const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf)
index faffb9a..7465685 100644 (file)
@@ -67,8 +67,6 @@
 #define GET_OPTIMIZED(func) (func)
 #endif
 
-#include "opencl_kernels.hpp"
-
 namespace cv
 {
 
index 9a5772f..2b659fb 100644 (file)
@@ -41,6 +41,7 @@
 //M*/
 
 #include "precomp.hpp"
+#include "opencl_kernels.hpp"
 
 ///////////////////////////////// UMat implementation ///////////////////////////////
 
index f3a9b52..0d0cf82 100644 (file)
@@ -90,6 +90,7 @@
 \**********************************************************************************/
 
 #include "precomp.hpp"
+#include "opencl_kernels.hpp"
 #include <limits>
 
 #define  CV_DESCALE(x,n)     (((x) + (1 << ((n)-1))) >> (n))
index 161b333..ab134fd 100644 (file)
@@ -47,6 +47,7 @@
 // */
 
 #include "precomp.hpp"
+#include "opencl_kernels.hpp"
 #include <iostream>
 #include <vector>
 
@@ -1901,7 +1902,7 @@ private:
 };
 #endif
 
-static bool ocl_resize( InputArray _src, OutputArray _dst,
+static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize,
                         double fx, double fy, int interpolation)
 {
     int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
@@ -1909,7 +1910,9 @@ static bool ocl_resize( InputArray _src, OutputArray _dst,
            (interpolation == INTER_NEAREST ||
            (interpolation == INTER_LINEAR && (depth == CV_8U || depth == CV_32F)))) )
         return false;
-    UMat src = _src.getUMat(), dst = _dst.getUMat();
+    UMat src = _src.getUMat();
+    _dst.create(dsize, type);
+    UMat dst = _dst.getUMat();
     ocl::Kernel k;
 
     if (interpolation == INTER_LINEAR)
@@ -2051,25 +2054,26 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
     Size ssize = _src.size();
 
     CV_Assert( ssize.area() > 0 );
-    CV_Assert( dsize.area() || (inv_scale_x > 0 && inv_scale_y > 0) );
-    if( !dsize.area() )
+    CV_Assert( dsize.area() > 0 || (inv_scale_x > 0 && inv_scale_y > 0) );
+    if( dsize.area() == 0 )
     {
         dsize = Size(saturate_cast<int>(ssize.width*inv_scale_x),
                      saturate_cast<int>(ssize.height*inv_scale_y));
-        CV_Assert( dsize.area() );
+        CV_Assert( dsize.area() > 0 );
     }
     else
     {
         inv_scale_x = (double)dsize.width/ssize.width;
         inv_scale_y = (double)dsize.height/ssize.height;
     }
-    _dst.create(dsize, _src.type());
 
     if( ocl::useOpenCL() && _dst.kind() == _InputArray::UMAT &&
-        ocl_resize(_src, _dst, inv_scale_x, inv_scale_y, interpolation) )
+        ocl_resize(_src, _dst, dsize, inv_scale_x, inv_scale_y, interpolation) )
         return;
 
-    Mat src = _src.getMat(), dst = _dst.getMat();
+    Mat src = _src.getMat();
+    _dst.create(dsize, src.type());
+    Mat dst = _dst.getMat();
 
 #ifdef HAVE_TEGRA_OPTIMIZATION
     if (tegra::resize(src, dst, (float)inv_scale_x, (float)inv_scale_y, interpolation))
index b806eda..9fa2441 100644 (file)
@@ -49,7 +49,6 @@
 #include "opencv2/imgproc/imgproc_c.h"
 #include "opencv2/core/private.hpp"
 #include "opencv2/core/ocl.hpp"
-#include "opencl_kernels.hpp"
 
 #include <math.h>
 #include <assert.h>