\cvCppFunc{gpu::norm}\r
Returns norm of matrix (or of two matrices difference).\r
\r
-\cvdefCpp{double norm(const GpuMat\& src1, int normType=NORM\_L2);}\r
+\cvdefCpp{double norm(const GpuMat\& src, int normType=NORM\_L2);}\r
\begin{description}\r
-\cvarg{src1}{Source matrix. Any matrices except 64F are supported.}\r
+\cvarg{src}{Source matrix. Any matrices except 64F are supported.}\r
\cvarg{normType}{Norm type. \texttt{NORM\_L1}, \texttt{NORM\_L2} and \texttt{NORM\_INF} are supported for now.}\r
\end{description}\r
\r
+\cvdefCpp{double norm(const GpuMat\& src, int normType, GpuMat\& buf);}\r
+\begin{description}\r
+\cvarg{src}{Source matrix. Any matrices except 64F are supported.}\r
+\cvarg{normType}{Norm type. \texttt{NORM\_L1}, \texttt{NORM\_L2} and \texttt{NORM\_INF} are supported for now.}\r
+\cvarg{buf}{Optional buffer to avoid extra memory allocations. It's resized automatically.}\r
+\end{description}\r
+\r
\cvdefCpp{double norm(const GpuMat\& src1, const GpuMat\& src2,\par\r
int normType=NORM\_L2);}\r
\begin{description}\r
\r
//! computes norm of array\r
//! supports NORM_INF, NORM_L1, NORM_L2\r
- //! supports only CV_8UC1 type\r
+ //! supports all matrices except 64F\r
CV_EXPORTS double norm(const GpuMat& src1, int normType=NORM_L2);\r
\r
+ //! computes norm of array\r
+ //! supports NORM_INF, NORM_L1, NORM_L2\r
+ //! supports all matrices except 64F\r
+ CV_EXPORTS double norm(const GpuMat& src1, int normType, GpuMat& buf);\r
+\r
//! computes norm of the difference between two arrays\r
//! supports NORM_INF, NORM_L1, NORM_L2\r
//! supports only CV_8UC1 type\r
\r
void cv::gpu::meanStdDev(const GpuMat&, Scalar&, Scalar&) { throw_nogpu(); }\r
double cv::gpu::norm(const GpuMat&, int) { throw_nogpu(); return 0.0; }\r
+double cv::gpu::norm(const GpuMat&, int, GpuMat&) { throw_nogpu(); return 0.0; }\r
double cv::gpu::norm(const GpuMat&, const GpuMat&, int) { throw_nogpu(); return 0.0; }\r
Scalar cv::gpu::sum(const GpuMat&) { throw_nogpu(); return Scalar(); }\r
Scalar cv::gpu::sum(const GpuMat&, GpuMat&) { throw_nogpu(); return Scalar(); }\r
\r
double cv::gpu::norm(const GpuMat& src, int normType)\r
{\r
+ GpuMat buf;\r
+ return norm(src, normType, buf);\r
+}\r
+\r
+double cv::gpu::norm(const GpuMat& src, int normType, GpuMat& buf)\r
+{\r
GpuMat src_single_channel = src.reshape(1);\r
\r
if (normType == NORM_L1)\r
- return absSum(src_single_channel)[0];\r
+ return absSum(src_single_channel, buf)[0];\r
\r
if (normType == NORM_L2)\r
- return sqrt(sqrSum(src_single_channel)[0]);\r
+ return sqrt(sqrSum(src_single_channel, buf)[0]);\r
\r
if (normType == NORM_INF)\r
{\r
double min_val, max_val;\r
- minMax(src_single_channel, &min_val, &max_val);\r
+ minMax(src_single_channel, &min_val, &max_val, GpuMat(), buf);\r
return std::max(std::abs(min_val), std::abs(max_val));\r
}\r
\r
TEST(norm)\r
{\r
Mat src;\r
- gpu::GpuMat d_src;\r
+ gpu::GpuMat d_src, d_buf;\r
\r
for (int size = 1000; size <= 8000; size *= 2)\r
{\r
- SUBTEST << "size " << size << ", 8U";\r
+ SUBTEST << "size " << size << ", 32F";\r
\r
- gen(src, size, size, CV_8U, 0, 256);\r
+ gen(src, size, size, CV_32F, 0, 1);\r
\r
CPU_ON;\r
- norm(src);\r
+ for (int i = 0; i < 10; ++i)\r
+ norm(src, NORM_L2);\r
CPU_OFF;\r
\r
d_src = src;\r
\r
GPU_ON;\r
- gpu::norm(d_src);\r
+ for (int i = 0; i < 10; ++i)\r
+ gpu::norm(d_src, NORM_L2, d_buf);\r
GPU_OFF;\r
}\r
}\r