From c7857e8c1341426f9a16c55ac0923adec5a996d0 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 20 Feb 2014 16:05:50 +0400 Subject: [PATCH] small fixes --- modules/photo/perf/opencl/perf_denoising.cpp | 2 +- .../src/fast_nlmeans_denoising_opencl.hpp | 13 +++--- modules/photo/src/opencl/nlmeans.cl | 2 - modules/photo/test/ocl/test_denoising.cpp | 45 +++---------------- 4 files changed, 13 insertions(+), 49 deletions(-) diff --git a/modules/photo/perf/opencl/perf_denoising.cpp b/modules/photo/perf/opencl/perf_denoising.cpp index cd0d3a2420..a2ee9178a1 100644 --- a/modules/photo/perf/opencl/perf_denoising.cpp +++ b/modules/photo/perf/opencl/perf_denoising.cpp @@ -42,7 +42,7 @@ OCL_PERF_TEST(Photo, DenoisingColored) OCL_TEST_CYCLE() cv::fastNlMeansDenoisingColored(original, result, 10, 10); - SANITY_CHECK(result); + SANITY_CHECK(result, 2); } OCL_PERF_TEST(Photo, DISABLED_DenoisingGrayscaleMulti) diff --git a/modules/photo/src/fast_nlmeans_denoising_opencl.hpp b/modules/photo/src/fast_nlmeans_denoising_opencl.hpp index 9e4cd06090..a121321675 100644 --- a/modules/photo/src/fast_nlmeans_denoising_opencl.hpp +++ b/modules/photo/src/fast_nlmeans_denoising_opencl.hpp @@ -9,20 +9,20 @@ #define __OPENCV_FAST_NLMEANS_DENOISING_OPENCL_HPP__ #include "precomp.hpp" - -#define CV_OPENCL_RUN_ASSERT #include "opencl_kernels.hpp" +#ifdef HAVE_OPENCL + namespace cv { enum { BLOCK_ROWS = 32, - BLOCK_COLS = 128, + BLOCK_COLS = 32, CTA_SIZE = 256 }; -static inline int getNearestPowerOf2(int value) +static inline int getNearestPowerOf2OpenCL(int value) { int p = 0; while (1 << p < value) @@ -51,7 +51,7 @@ static bool ocl_calcAlmostDist2Weight(UMat & almostDist2Weight, int searchWindow // additional optimization of precalced weights to replace division(averaging) by binary shift CV_Assert(templateWindowSize <= 46340); // sqrt(INT_MAX) int templateWindowSizeSq = templateWindowSize * templateWindowSize; - almostTemplateWindowSizeSqBinShift = getNearestPowerOf2(templateWindowSizeSq); + almostTemplateWindowSizeSqBinShift = getNearestPowerOf2OpenCL(templateWindowSizeSq); FT almostDist2ActualDistMultiplier = (FT)(1 << almostTemplateWindowSizeSqBinShift) / templateWindowSizeSq; const FT WEIGHT_THRESHOLD = 1e-3f; @@ -128,7 +128,7 @@ static bool ocl_fastNlMeansDenoising(InputArray _src, OutputArray _dst, float h, ocl::KernelArg::PtrReadOnly(almostDist2Weight), ocl::KernelArg::PtrReadOnly(buffer), almostTemplateWindowSizeSqBinShift); - size_t globalsize[2] = { nblocksx * BLOCK_COLS, nblocksy * BLOCK_ROWS }, localsize[2] = { CTA_SIZE, 1 }; + size_t globalsize[2] = { nblocksx * CTA_SIZE, nblocksy }, localsize[2] = { CTA_SIZE, 1 }; return k.run(2, globalsize, localsize, false); } @@ -167,3 +167,4 @@ static bool ocl_fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst, } #endif +#endif diff --git a/modules/photo/src/opencl/nlmeans.cl b/modules/photo/src/opencl/nlmeans.cl index 7b13ea5e11..67a6ec61f8 100644 --- a/modules/photo/src/opencl/nlmeans.cl +++ b/modules/photo/src/opencl/nlmeans.cl @@ -115,8 +115,6 @@ inline void calcFirstElementInRow(__global const uchar * src, int src_step, int for (int j = 0; j < TEMPLATE_SIZE; ++j) col_dists_current[j] = col_dists_current_private[j]; -// COND printf("%d %d\n", i, convert_int(dist)); - dists[i] = dist; up_col_dists[0 + i] = col_dists[TEMPLATE_SIZE - 1]; } diff --git a/modules/photo/test/ocl/test_denoising.cpp b/modules/photo/test/ocl/test_denoising.cpp index 51de634622..819c65daaf 100644 --- a/modules/photo/test/ocl/test_denoising.cpp +++ b/modules/photo/test/ocl/test_denoising.cpp @@ -1,44 +1,9 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. // Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of the copyright holders may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ #include "test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp"