//! computes norm of array\r
//! Supports NORM_INF, NORM_L1, NORM_L2\r
CV_EXPORTS double norm(const GpuMat& src1, int normType=NORM_L2);\r
+ \r
//! computes norm of the difference between two arrays\r
//! Supports NORM_INF, NORM_L1, NORM_L2\r
CV_EXPORTS double norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM_L2);\r
\r
//! smooths the image using the normalized box filter\r
CV_EXPORTS void boxFilter(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1));\r
+\r
//! a synonym for normalized box filter\r
- static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1))\r
- {\r
- boxFilter(src, dst, ksize, anchor);\r
- }\r
+ static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1)) { boxFilter(src, dst, ksize, anchor); }\r
\r
//! erodes the image (applies the local minimum operator)\r
CV_EXPORTS void erode( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor, int iterations);\r
CV_Assert(src.type() == CV_8UC1 || src.type() == CV_8UC4);\r
\r
Scalar res;\r
+ \r
\r
NppiSize sz;\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
+ int bufsz;\r
+ \r
if (src.type() == CV_8UC1)\r
- {\r
- nppSafeCall( nppiSum_8u_C1R(src.ptr<Npp8u>(), src.step, sz, res.val) );\r
+ { \r
+ nppiReductionGetBufferHostSize_8u_C1R(sz, &bufsz);\r
+ GpuMat buf(1, bufsz, CV_32S);\r
+ nppSafeCall( nppiSum_8u_C1R(src.ptr<Npp8u>(), src.step, sz, buf.ptr<Npp32s>(), res.val) );\r
}\r
else\r
- {\r
- nppSafeCall( nppiSum_8u_C4R(src.ptr<Npp8u>(), src.step, sz, res.val) );\r
+ { \r
+ nppiReductionGetBufferHostSize_8u_C4R(sz, &bufsz);\r
+ GpuMat buf(1, bufsz, CV_32S);\r
+ nppSafeCall( nppiSum_8u_C4R(src.ptr<Npp8u>(), src.step, sz, buf.ptr<Npp32s>(), res.val) );\r
}\r
\r
return res;\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of the copyright holders may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "precomp.hpp"\r
+\r
+\r
+using namespace cv;\r
+using namespace cv::gpu;\r
+\r
+\r
+#if !defined (HAVE_CUDA)\r
+\r
+#else /* !defined (HAVE_CUDA) */\r
+\r
+\r
+namespace \r
+{\r
+ struct NppError\r
+ {\r
+ int error;\r
+ string str;\r
+ } \r
+ npp_errors [] = \r
+ {\r
+ { NPP_NOT_SUPPORTED_MODE_ERROR, "NPP_NOT_SUPPORTED_MODE_ERROR" },\r
+ { NPP_ROUND_MODE_NOT_SUPPORTED_ERROR, "NPP_ROUND_MODE_NOT_SUPPORTED_ERROR" },\r
+ { NPP_RESIZE_NO_OPERATION_ERROR, "NPP_RESIZE_NO_OPERATION_ERROR" },\r
+ { NPP_BAD_ARG_ERROR, "NPP_BAD_ARG_ERROR" },\r
+ { NPP_LUT_NUMBER_OF_LEVELS_ERROR, "NPP_LUT_NUMBER_OF_LEVELS_ERROR" },\r
+ { NPP_TEXTURE_BIND_ERROR, "NPP_TEXTURE_BIND_ERROR" },\r
+ { NPP_COEFF_ERROR, "NPP_COEFF_ERROR" },\r
+ { NPP_RECT_ERROR, "NPP_RECT_ERROR" },\r
+ { NPP_QUAD_ERROR, "NPP_QUAD_ERROR" },\r
+ { NPP_WRONG_INTERSECTION_ROI_ERROR, "NPP_WRONG_INTERSECTION_ROI_ERROR" },\r
+ { NPP_NOT_EVEN_STEP_ERROR, "NPP_NOT_EVEN_STEP_ERROR" },\r
+ { NPP_INTERPOLATION_ERROR, "NPP_INTERPOLATION_ERROR" },\r
+ { NPP_RESIZE_FACTOR_ERROR, "NPP_RESIZE_FACTOR_ERROR" },\r
+ { NPP_HAAR_CLASSIFIER_PIXEL_MATCH_ERROR, "NPP_HAAR_CLASSIFIER_PIXEL_MATCH_ERROR" },\r
+ { NPP_MEMFREE_ERR, "NPP_MEMFREE_ERR" },\r
+ { NPP_MEMSET_ERR, "NPP_MEMSET_ERR" },\r
+ { NPP_MEMCPY_ERROR, "NPP_MEMCPY_ERROR" },\r
+ { NPP_MEM_ALLOC_ERR, "NPP_MEM_ALLOC_ERR" },\r
+ { NPP_HISTO_NUMBER_OF_LEVELS_ERROR, "NPP_HISTO_NUMBER_OF_LEVELS_ERROR" },\r
+ { NPP_MIRROR_FLIP_ERR, "NPP_MIRROR_FLIP_ERR" },\r
+ { NPP_INVALID_INPUT, "NPP_INVALID_INPUT" },\r
+ { NPP_ALIGNMENT_ERROR, "NPP_ALIGNMENT_ERROR" },\r
+ { NPP_STEP_ERROR, "NPP_STEP_ERROR" },\r
+ { NPP_SIZE_ERROR, "NPP_SIZE_ERROR" },\r
+ { NPP_POINTER_ERROR, "NPP_POINTER_ERROR" },\r
+ { NPP_NULL_POINTER_ERROR, "NPP_NULL_POINTER_ERROR" },\r
+ { NPP_CUDA_KERNEL_EXECUTION_ERROR, "NPP_CUDA_KERNEL_EXECUTION_ERROR" },\r
+ { NPP_NOT_IMPLEMENTED_ERROR, "NPP_NOT_IMPLEMENTED_ERROR" },\r
+ { NPP_ERROR, "NPP_ERROR" }, \r
+ { NPP_NO_ERROR, "NPP_NO_ERROR" },\r
+ { NPP_SUCCESS, "NPP_SUCCESS" },\r
+ { NPP_WARNING, "NPP_WARNING" },\r
+ { NPP_WRONG_INTERSECTION_QUAD_WARNING, "NPP_WRONG_INTERSECTION_QUAD_WARNING" },\r
+ { NPP_MISALIGNED_DST_ROI_WARNING, "NPP_MISALIGNED_DST_ROI_WARNING" },\r
+ { NPP_AFFINE_QUAD_INCORRECT_WARNING, "NPP_AFFINE_QUAD_INCORRECT_WARNING" },\r
+ //disabled in NPP for cuda 3.2-rc\r
+ //{ NPP_AFFINE_QUAD_CHANGED_WARNING, "NPP_AFFINE_QUAD_CHANGED_WARNING" },\r
+ //{ NPP_ADJUSTED_ROI_SIZE_WARNING, "NPP_ADJUSTED_ROI_SIZE_WARNING" },\r
+ { NPP_DOUBLE_SIZE_WARNING, "NPP_DOUBLE_SIZE_WARNING" },\r
+ { NPP_ODD_ROI_WARNING, "NPP_ODD_ROI_WARNING" }\r
+ };\r
+\r
+ int error_num = sizeof(npp_errors)/sizeof(npp_errors[0]);\r
+\r
+ struct Searcher\r
+ {\r
+ int err;\r
+ Searcher(int err_) : err(err_) {};\r
+ bool operator()(const NppError& e) const { return e.error == err; }\r
+ };\r
+\r
+}\r
+\r
+namespace cv\r
+{\r
+ namespace gpu\r
+ {\r
+ const string getNppErrorString( int err )\r
+ {\r
+ int idx = std::find_if(npp_errors, npp_errors + error_num, Searcher(err)) - npp_errors;\r
+ const string& msg = (idx != error_num) ? npp_errors[idx].str : string("Unknown error code");\r
+\r
+ std::stringstream interpreter;\r
+ interpreter << "<" << err << "> " << msg;\r
+\r
+ return interpreter.str();\r
+ }\r
+\r
+ extern "C" void npp_error( int err, const char *file, const int line, const char *func)\r
+ { \r
+ cv::error( cv::Exception(CV_GpuNppCallError, getNppErrorString(err), func, file, line) ); \r
+ }\r
+\r
+ extern "C" void error(const char *error_string, const char *file, const int line, const char *func)\r
+ { \r
+ cv::error( cv::Exception(CV_GpuApiCallError, error_string, func, file, line) );\r
+ }\r
+ }\r
+}\r
+\r
+#endif
\ No newline at end of file
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of the copyright holders may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "precomp.hpp"\r
-\r
-using namespace cv;\r
-using namespace cv::gpu;\r
-\r
-\r
-#if !defined (HAVE_CUDA)\r
-\r
-#else /* !defined (HAVE_CUDA) */\r
-\r
-\r
-namespace \r
-{\r
- struct NppError\r
- {\r
- int error;\r
- const char* str;\r
- } \r
- npp_errors [] = \r
- {\r
- { NPP_NOT_SUPPORTED_MODE_ERROR, "NPP_NOT_SUPPORTED_MODE_ERROR" },\r
- { NPP_ROUND_MODE_NOT_SUPPORTED_ERROR, "NPP_ROUND_MODE_NOT_SUPPORTED_ERROR" },\r
- { NPP_RESIZE_NO_OPERATION_ERROR, "NPP_RESIZE_NO_OPERATION_ERROR" },\r
- { NPP_BAD_ARG_ERROR, "NPP_BAD_ARG_ERROR" },\r
- { NPP_LUT_NUMBER_OF_LEVELS_ERROR, "NPP_LUT_NUMBER_OF_LEVELS_ERROR" },\r
- { NPP_TEXTURE_BIND_ERROR, "NPP_TEXTURE_BIND_ERROR" },\r
- { NPP_COEFF_ERROR, "NPP_COEFF_ERROR" },\r
- { NPP_RECT_ERROR, "NPP_RECT_ERROR" },\r
- { NPP_QUAD_ERROR, "NPP_QUAD_ERROR" },\r
- { NPP_WRONG_INTERSECTION_ROI_ERROR, "NPP_WRONG_INTERSECTION_ROI_ERROR" },\r
- { NPP_NOT_EVEN_STEP_ERROR, "NPP_NOT_EVEN_STEP_ERROR" },\r
- { NPP_INTERPOLATION_ERROR, "NPP_INTERPOLATION_ERROR" },\r
- { NPP_RESIZE_FACTOR_ERROR, "NPP_RESIZE_FACTOR_ERROR" },\r
- { NPP_HAAR_CLASSIFIER_PIXEL_MATCH_ERROR, "NPP_HAAR_CLASSIFIER_PIXEL_MATCH_ERROR" },\r
- { NPP_MEMFREE_ERR, "NPP_MEMFREE_ERR" },\r
- { NPP_MEMSET_ERR, "NPP_MEMSET_ERR" },\r
- { NPP_MEMCPY_ERROR, "NPP_MEMCPY_ERROR" },\r
- { NPP_MEM_ALLOC_ERR, "NPP_MEM_ALLOC_ERR" },\r
- { NPP_HISTO_NUMBER_OF_LEVELS_ERROR, "NPP_HISTO_NUMBER_OF_LEVELS_ERROR" },\r
- { NPP_MIRROR_FLIP_ERR, "NPP_MIRROR_FLIP_ERR" },\r
- { NPP_INVALID_INPUT, "NPP_INVALID_INPUT" },\r
- { NPP_ALIGNMENT_ERROR, "NPP_ALIGNMENT_ERROR" },\r
- { NPP_STEP_ERROR, "NPP_STEP_ERROR" },\r
- { NPP_SIZE_ERROR, "NPP_SIZE_ERROR" },\r
- { NPP_POINTER_ERROR, "NPP_POINTER_ERROR" },\r
- { NPP_NULL_POINTER_ERROR, "NPP_NULL_POINTER_ERROR" },\r
- { NPP_CUDA_KERNEL_EXECUTION_ERROR, "NPP_CUDA_KERNEL_EXECUTION_ERROR" },\r
- { NPP_NOT_IMPLEMENTED_ERROR, "NPP_NOT_IMPLEMENTED_ERROR" },\r
- { NPP_ERROR, "NPP_ERROR" }, \r
- { NPP_NO_ERROR, "NPP_NO_ERROR" },\r
- { NPP_SUCCESS, "NPP_SUCCESS" },\r
- { NPP_WARNING, "NPP_WARNING" },\r
- { NPP_WRONG_INTERSECTION_QUAD_WARNING, "NPP_WRONG_INTERSECTION_QUAD_WARNING" },\r
- { NPP_MISALIGNED_DST_ROI_WARNING, "NPP_MISALIGNED_DST_ROI_WARNING" },\r
- { NPP_AFFINE_QUAD_INCORRECT_WARNING, "NPP_AFFINE_QUAD_INCORRECT_WARNING" },\r
- { NPP_AFFINE_QUAD_CHANGED_WARNING, "NPP_AFFINE_QUAD_CHANGED_WARNING" },\r
- { NPP_ADJUSTED_ROI_SIZE_WARNING, "NPP_ADJUSTED_ROI_SIZE_WARNING" },\r
- { NPP_DOUBLE_SIZE_WARNING, "NPP_DOUBLE_SIZE_WARNING" },\r
- { NPP_ODD_ROI_WARNING, "NPP_ODD_ROI_WARNING" }\r
- };\r
-\r
- int error_num = sizeof(npp_errors)/sizeof(npp_errors[0]);\r
-\r
- struct Searcher\r
- {\r
- int err;\r
- Searcher(int err_) : err(err_) {};\r
- bool operator()(const NppError& e) const { return e.error == err; }\r
- };\r
-\r
-}\r
-\r
-namespace cv\r
-{\r
- namespace gpu\r
- {\r
- extern "C" const char* getNppErrorString( int err )\r
- {\r
- int idx = std::find_if(npp_errors, npp_errors + error_num, Searcher(err)) - npp_errors;\r
-\r
- return (idx != error_num) ? npp_errors[idx].str : ""; \r
- }\r
-\r
- extern "C" void npp_error( int err, const char *file, const int line, const char *func)\r
- { \r
- cv::error( cv::Exception(CV_GpuNppCallError, getNppErrorString(err), func, file, line) ); \r
- }\r
- }\r
-}\r
-\r
-#endif
\ No newline at end of file
\r
#include "precomp.hpp"\r
\r
-/* End of file. */\r
-\r
-\r
-namespace cv\r
-{\r
- namespace gpu\r
- {\r
- extern "C" void error(const char *error_string, const char *file, const int line, const char *func)\r
- { \r
- cv::error( cv::Exception(CV_GpuApiCallError, error_string, func, file, line) );\r
- }\r
- }\r
-}\r
+/* End of file. */
\ No newline at end of file
#include <limits>\r
#include <vector>\r
#include <algorithm>\r
+#include <sstream>\r
\r
#include "opencv2/gpu/gpu.hpp"\r
#include "opencv2/imgproc/imgproc.hpp"\r