//! 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
\r
#include "precomp.hpp"\r
\r
+\r
using namespace cv;\r
using namespace cv::gpu;\r
\r
struct NppError\r
{\r
int error;\r
- const char* str;\r
+ string str;\r
} \r
npp_errors [] = \r
{\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
+ //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
namespace gpu\r
{\r
- extern "C" const char* getNppErrorString( int err )\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 (idx != error_num) ? npp_errors[idx].str : ""; \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
\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