Commit 0d09352f authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

fixed gpu::cvtColor

parent ada3e6e6
This diff is collapsed.
......@@ -44,11 +44,11 @@
#define __OPENCV_GPU_LIMITS_GPU_HPP__
namespace cv { namespace gpu { namespace device
{
{
template<class T> struct numeric_limits_gpu
{
{
typedef T type;
__device__ __forceinline__ static type min() { return type(); };
__device__ __forceinline__ static type min() { return type(); };
__device__ __forceinline__ static type max() { return type(); };
__device__ __forceinline__ static type epsilon() { return type(); }
__device__ __forceinline__ static type round_error() { return type(); }
......@@ -60,9 +60,9 @@ namespace cv { namespace gpu { namespace device
};
template<> struct numeric_limits_gpu<bool>
{
{
typedef bool type;
__device__ __forceinline__ static type min() { return false; };
__device__ __forceinline__ static type min() { return false; };
__device__ __forceinline__ static type max() { return true; };
__device__ __forceinline__ static type epsilon();
__device__ __forceinline__ static type round_error();
......@@ -74,9 +74,9 @@ namespace cv { namespace gpu { namespace device
};
template<> struct numeric_limits_gpu<char>
{
{
typedef char type;
__device__ __forceinline__ static type min() { return CHAR_MIN; };
__device__ __forceinline__ static type min() { return CHAR_MIN; };
__device__ __forceinline__ static type max() { return CHAR_MAX; };
__device__ __forceinline__ static type epsilon();
__device__ __forceinline__ static type round_error();
......@@ -88,9 +88,9 @@ namespace cv { namespace gpu { namespace device
};
template<> struct numeric_limits_gpu<unsigned char>
{
{
typedef unsigned char type;
__device__ __forceinline__ static type min() { return 0; };
__device__ __forceinline__ static type min() { return 0; };
__device__ __forceinline__ static type max() { return UCHAR_MAX; };
__device__ __forceinline__ static type epsilon();
__device__ __forceinline__ static type round_error();
......@@ -102,9 +102,9 @@ namespace cv { namespace gpu { namespace device
};
template<> struct numeric_limits_gpu<short>
{
{
typedef short type;
__device__ __forceinline__ static type min() { return SHRT_MIN; };
__device__ __forceinline__ static type min() { return SHRT_MIN; };
__device__ __forceinline__ static type max() { return SHRT_MAX; };
__device__ __forceinline__ static type epsilon();
__device__ __forceinline__ static type round_error();
......@@ -116,9 +116,9 @@ namespace cv { namespace gpu { namespace device
};
template<> struct numeric_limits_gpu<unsigned short>
{
{
typedef unsigned short type;
__device__ __forceinline__ static type min() { return 0; };
__device__ __forceinline__ static type min() { return 0; };
__device__ __forceinline__ static type max() { return USHRT_MAX; };
__device__ __forceinline__ static type epsilon();
__device__ __forceinline__ static type round_error();
......@@ -130,9 +130,9 @@ namespace cv { namespace gpu { namespace device
};
template<> struct numeric_limits_gpu<int>
{
{
typedef int type;
__device__ __forceinline__ static type min() { return INT_MIN; };
__device__ __forceinline__ static type min() { return INT_MIN; };
__device__ __forceinline__ static type max() { return INT_MAX; };
__device__ __forceinline__ static type epsilon();
__device__ __forceinline__ static type round_error();
......@@ -145,9 +145,9 @@ namespace cv { namespace gpu { namespace device
template<> struct numeric_limits_gpu<unsigned int>
{
{
typedef unsigned int type;
__device__ __forceinline__ static type min() { return 0; };
__device__ __forceinline__ static type min() { return 0; };
__device__ __forceinline__ static type max() { return UINT_MAX; };
__device__ __forceinline__ static type epsilon();
__device__ __forceinline__ static type round_error();
......@@ -159,9 +159,9 @@ namespace cv { namespace gpu { namespace device
};
template<> struct numeric_limits_gpu<long>
{
{
typedef long type;
__device__ __forceinline__ static type min() { return LONG_MIN; };
__device__ __forceinline__ static type min() { return LONG_MIN; };
__device__ __forceinline__ static type max() { return LONG_MAX; };
__device__ __forceinline__ static type epsilon();
__device__ __forceinline__ static type round_error();
......@@ -173,9 +173,9 @@ namespace cv { namespace gpu { namespace device
};
template<> struct numeric_limits_gpu<unsigned long>
{
{
typedef unsigned long type;
__device__ __forceinline__ static type min() { return 0; };
__device__ __forceinline__ static type min() { return 0; };
__device__ __forceinline__ static type max() { return ULONG_MAX; };
__device__ __forceinline__ static type epsilon();
__device__ __forceinline__ static type round_error();
......@@ -185,11 +185,11 @@ namespace cv { namespace gpu { namespace device
__device__ __forceinline__ static type signaling_NaN();
static const bool is_signed = false;
};
template<> struct numeric_limits_gpu<float>
{
{
typedef float type;
__device__ __forceinline__ static type min() { return 1.175494351e-38f/*FLT_MIN*/; };
__device__ __forceinline__ static type min() { return 1.175494351e-38f/*FLT_MIN*/; };
__device__ __forceinline__ static type max() { return 3.402823466e+38f/*FLT_MAX*/; };
__device__ __forceinline__ static type epsilon() { return 1.192092896e-07f/*FLT_EPSILON*/; };
__device__ __forceinline__ static type round_error();
......@@ -201,9 +201,9 @@ namespace cv { namespace gpu { namespace device
};
template<> struct numeric_limits_gpu<double>
{
{
typedef double type;
__device__ __forceinline__ static type min() { return 2.2250738585072014e-308/*DBL_MIN*/; };
__device__ __forceinline__ static type min() { return 2.2250738585072014e-308/*DBL_MIN*/; };
__device__ __forceinline__ static type max() { return 1.7976931348623158e+308/*DBL_MAX*/; };
__device__ __forceinline__ static type epsilon();
__device__ __forceinline__ static type round_error();
......@@ -212,7 +212,7 @@ namespace cv { namespace gpu { namespace device
__device__ __forceinline__ static type quiet_NaN();
__device__ __forceinline__ static type signaling_NaN();
static const bool is_signed = true;
};
};
}}}
#endif // __OPENCV_GPU_LIMITS_GPU_HPP__
......@@ -461,17 +461,17 @@ protected:
int CV_GpuCvtColorTest::CheckNorm(const Mat& m1, const Mat& m2)
{
double ret = norm(m1, m2, NORM_INF);
float max_err = 1e-2f;
if (ret <= 3)
{
return cvtest::TS::OK;
}
else
{
ts->printf(cvtest::TS::LOG, "\nNorm: %f\n", ret);
return cvtest::TS::FAIL_GENERIC;
}
Mat diff;
cv::matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);
float err = abs(diff.at<float>(0, 0) - 1.f);
if (err > max_err)
return cvtest::TS::FAIL_INVALID_OUTPUT;
return cvtest::TS::OK;
}
void CV_GpuCvtColorTest::run( int )
......@@ -596,7 +596,7 @@ void CV_GpuHistogramsTest::run( int )
////////////////////////////////////////////////////////////////////////
// Corner Harris feature detector
struct CV_GpuCornerHarrisTest: cvtest::BaseTest
struct CV_GpuCornerHarrisTest: cvtest::BaseTest
{
CV_GpuCornerHarrisTest() {}
......@@ -616,7 +616,7 @@ struct CV_GpuCornerHarrisTest: cvtest::BaseTest
{
RNG rng;
cv::Mat src(rows, cols, depth);
if (depth == CV_32F)
if (depth == CV_32F)
rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(1));
else if (depth == CV_8U)
rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(256));
......@@ -629,7 +629,7 @@ struct CV_GpuCornerHarrisTest: cvtest::BaseTest
int borderType;
borderType = BORDER_REFLECT101;
cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);
cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);
cv::gpu::cornerHarris(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, k, borderType);
dsth = dst;
......@@ -639,7 +639,7 @@ struct CV_GpuCornerHarrisTest: cvtest::BaseTest
{
float a = dst_gold.at<float>(i, j);
float b = dsth.at<float>(i, j);
if (fabs(a - b) > 1e-3f)
if (fabs(a - b) > 1e-3f)
{
ts->printf(cvtest::TS::CONSOLE, "%d %d %f %f %d\n", i, j, a, b, apertureSize);
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
......@@ -649,7 +649,7 @@ struct CV_GpuCornerHarrisTest: cvtest::BaseTest
}
borderType = BORDER_REPLICATE;
cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);
cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);
cv::gpu::cornerHarris(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, k, borderType);
dsth = dst;
......@@ -659,7 +659,7 @@ struct CV_GpuCornerHarrisTest: cvtest::BaseTest
{
float a = dst_gold.at<float>(i, j);
float b = dsth.at<float>(i, j);
if (fabs(a - b) > 1e-3f)
if (fabs(a - b) > 1e-3f)
{
ts->printf(cvtest::TS::CONSOLE, "%d %d %f %f %d\n", i, j, a, b, apertureSize);
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
......@@ -674,7 +674,7 @@ struct CV_GpuCornerHarrisTest: cvtest::BaseTest
////////////////////////////////////////////////////////////////////////
// Corner Min Eigen Val
struct CV_GpuCornerMinEigenValTest: cvtest::BaseTest
struct CV_GpuCornerMinEigenValTest: cvtest::BaseTest
{
CV_GpuCornerMinEigenValTest() {}
......@@ -694,7 +694,7 @@ struct CV_GpuCornerMinEigenValTest: cvtest::BaseTest
{
RNG rng;
cv::Mat src(rows, cols, depth);
if (depth == CV_32F)
if (depth == CV_32F)
rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(1));
else if (depth == CV_8U)
rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(256));
......@@ -706,8 +706,8 @@ struct CV_GpuCornerMinEigenValTest: cvtest::BaseTest
int borderType;
borderType = BORDER_REFLECT101;
cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType);
cv::gpu::cornerMinEigenVal(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, borderType);
cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType);
cv::gpu::cornerMinEigenVal(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, borderType);
dsth = dst;
for (int i = 0; i < dst.rows; ++i)
......@@ -716,7 +716,7 @@ struct CV_GpuCornerMinEigenValTest: cvtest::BaseTest
{
float a = dst_gold.at<float>(i, j);
float b = dsth.at<float>(i, j);
if (fabs(a - b) > 1e-2f)
if (fabs(a - b) > 1e-2f)
{
ts->printf(cvtest::TS::CONSOLE, "%d %d %f %f %d %d\n", i, j, a, b, apertureSize, blockSize);
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
......@@ -726,8 +726,8 @@ struct CV_GpuCornerMinEigenValTest: cvtest::BaseTest
}
borderType = BORDER_REPLICATE;
cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType);
cv::gpu::cornerMinEigenVal(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, borderType);
cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType);
cv::gpu::cornerMinEigenVal(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, borderType);
dsth = dst;
for (int i = 0; i < dst.rows; ++i)
......@@ -736,7 +736,7 @@ struct CV_GpuCornerMinEigenValTest: cvtest::BaseTest
{
float a = dst_gold.at<float>(i, j);
float b = dsth.at<float>(i, j);
if (fabs(a - b) > 1e-2f)
if (fabs(a - b) > 1e-2f)
{
ts->printf(cvtest::TS::CONSOLE, "%d %d %f %f %d %d\n", i, j, a, b, apertureSize, blockSize);
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
......@@ -749,7 +749,7 @@ struct CV_GpuCornerMinEigenValTest: cvtest::BaseTest
}
};
struct CV_GpuColumnSumTest: cvtest::BaseTest
struct CV_GpuColumnSumTest: cvtest::BaseTest
{
CV_GpuColumnSumTest() {}
......@@ -794,7 +794,7 @@ struct CV_GpuColumnSumTest: cvtest::BaseTest
}
};
struct CV_GpuNormTest : cvtest::BaseTest
struct CV_GpuNormTest : cvtest::BaseTest
{
CV_GpuNormTest() {}
......@@ -924,12 +924,12 @@ TEST(downsample, accuracy_on_8U)
for (int k = 2; k <= 5; ++k)
{
GpuMat d_dst;
downsample(GpuMat(src), d_dst, k);
downsample(GpuMat(src), d_dst, k);
Size dst_gold_size((src.cols + k - 1) / k, (src.rows + k - 1) / k);
ASSERT_EQ(dst_gold_size.width, d_dst.cols)
ASSERT_EQ(dst_gold_size.width, d_dst.cols)
<< "rows=" << size.height << ", cols=" << size.width << ", k=" << k;
ASSERT_EQ(dst_gold_size.height, d_dst.rows)
ASSERT_EQ(dst_gold_size.height, d_dst.rows)
<< "rows=" << size.height << ", cols=" << size.width << ", k=" << k;
Mat dst = d_dst;
......@@ -949,12 +949,12 @@ TEST(downsample, accuracy_on_32F)
for (int k = 2; k <= 5; ++k)
{
GpuMat d_dst;
downsample(GpuMat(src), d_dst, k);
downsample(GpuMat(src), d_dst, k);
Size dst_gold_size((src.cols + k - 1) / k, (src.rows + k - 1) / k);
ASSERT_EQ(dst_gold_size.width, d_dst.cols)
ASSERT_EQ(dst_gold_size.width, d_dst.cols)
<< "rows=" << size.height << ", cols=" << size.width << ", k=" << k;
ASSERT_EQ(dst_gold_size.height, d_dst.rows)
ASSERT_EQ(dst_gold_size.height, d_dst.rows)
<< "rows=" << size.height << ", cols=" << size.width << ", k=" << k;
Mat dst = d_dst;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment