Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
61b54149
Commit
61b54149
authored
Feb 13, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added mask support to gpu norm and sum
parent
08914aa7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
41 deletions
+75
-41
matrix_reductions.rst
modules/gpu/doc/matrix_reductions.rst
+16
-0
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+4
-19
perf_core.cpp
modules/gpu/perf/perf_core.cpp
+4
-4
matrix_reductions.cu
modules/gpu/src/cuda/matrix_reductions.cu
+0
-0
matrix_reductions.cpp
modules/gpu/src/matrix_reductions.cpp
+47
-16
test_core.cpp
modules/gpu/test/test_core.cpp
+4
-2
No files found.
modules/gpu/doc/matrix_reductions.rst
View file @
61b54149
...
@@ -32,6 +32,8 @@ Returns the norm of a matrix (or difference of two matrices).
...
@@ -32,6 +32,8 @@ Returns the norm of a matrix (or difference of two matrices).
.. ocv:function:: double gpu::norm(const GpuMat& src1, int normType, GpuMat& buf)
.. ocv:function:: double gpu::norm(const GpuMat& src1, int normType, GpuMat& buf)
.. ocv:function:: double gpu::norm(const GpuMat& src1, int normType, const GpuMat& mask, GpuMat& buf)
.. ocv:function:: double gpu::norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM_L2)
.. ocv:function:: double gpu::norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM_L2)
:param src1: Source matrix. Any matrices except 64F are supported.
:param src1: Source matrix. Any matrices except 64F are supported.
...
@@ -40,6 +42,8 @@ Returns the norm of a matrix (or difference of two matrices).
...
@@ -40,6 +42,8 @@ Returns the norm of a matrix (or difference of two matrices).
:param normType: Norm type. ``NORM_L1`` , ``NORM_L2`` , and ``NORM_INF`` are supported for now.
:param normType: Norm type. ``NORM_L1`` , ``NORM_L2`` , and ``NORM_INF`` are supported for now.
:param mask: optional operation mask; it must have the same size as ``src1`` and ``CV_8UC1`` type.
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
.. seealso:: :ocv:func:`norm`
.. seealso:: :ocv:func:`norm`
...
@@ -54,8 +58,12 @@ Returns the sum of matrix elements.
...
@@ -54,8 +58,12 @@ Returns the sum of matrix elements.
.. ocv:function:: Scalar gpu::sum(const GpuMat& src, GpuMat& buf)
.. ocv:function:: Scalar gpu::sum(const GpuMat& src, GpuMat& buf)
.. ocv:function:: Scalar gpu::sum(const GpuMat& src, const GpuMat& mask, GpuMat& buf)
:param src: Source image of any depth except for ``CV_64F`` .
:param src: Source image of any depth except for ``CV_64F`` .
:param mask: optional operation mask; it must have the same size as ``src1`` and ``CV_8UC1`` type.
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
.. seealso:: :ocv:func:`sum`
.. seealso:: :ocv:func:`sum`
...
@@ -70,8 +78,12 @@ Returns the sum of absolute values for matrix elements.
...
@@ -70,8 +78,12 @@ Returns the sum of absolute values for matrix elements.
.. ocv:function:: Scalar gpu::absSum(const GpuMat& src, GpuMat& buf)
.. ocv:function:: Scalar gpu::absSum(const GpuMat& src, GpuMat& buf)
.. ocv:function:: Scalar gpu::absSum(const GpuMat& src, const GpuMat& mask, GpuMat& buf)
:param src: Source image of any depth except for ``CV_64F`` .
:param src: Source image of any depth except for ``CV_64F`` .
:param mask: optional operation mask; it must have the same size as ``src1`` and ``CV_8UC1`` type.
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
...
@@ -84,8 +96,12 @@ Returns the squared sum of matrix elements.
...
@@ -84,8 +96,12 @@ Returns the squared sum of matrix elements.
.. ocv:function:: Scalar gpu::sqrSum(const GpuMat& src, GpuMat& buf)
.. ocv:function:: Scalar gpu::sqrSum(const GpuMat& src, GpuMat& buf)
.. ocv:function:: Scalar gpu::sqrSum(const GpuMat& src, const GpuMat& mask, GpuMat& buf)
:param src: Source image of any depth except for ``CV_64F`` .
:param src: Source image of any depth except for ``CV_64F`` .
:param mask: optional operation mask; it must have the same size as ``src1`` and ``CV_8UC1`` type.
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
...
...
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
61b54149
...
@@ -919,11 +919,8 @@ CV_EXPORTS void meanStdDev(const GpuMat& mtx, Scalar& mean, Scalar& stddev, GpuM
...
@@ -919,11 +919,8 @@ CV_EXPORTS void meanStdDev(const GpuMat& mtx, Scalar& mean, Scalar& stddev, GpuM
//! supports NORM_INF, NORM_L1, NORM_L2
//! supports NORM_INF, NORM_L1, NORM_L2
//! supports all matrices except 64F
//! supports all matrices except 64F
CV_EXPORTS
double
norm
(
const
GpuMat
&
src1
,
int
normType
=
NORM_L2
);
CV_EXPORTS
double
norm
(
const
GpuMat
&
src1
,
int
normType
=
NORM_L2
);
//! computes norm of array
//! supports NORM_INF, NORM_L1, NORM_L2
//! supports all matrices except 64F
CV_EXPORTS
double
norm
(
const
GpuMat
&
src1
,
int
normType
,
GpuMat
&
buf
);
CV_EXPORTS
double
norm
(
const
GpuMat
&
src1
,
int
normType
,
GpuMat
&
buf
);
CV_EXPORTS
double
norm
(
const
GpuMat
&
src1
,
int
normType
,
const
GpuMat
&
mask
,
GpuMat
&
buf
);
//! computes norm of the difference between two arrays
//! computes norm of the difference between two arrays
//! supports NORM_INF, NORM_L1, NORM_L2
//! supports NORM_INF, NORM_L1, NORM_L2
...
@@ -933,45 +930,33 @@ CV_EXPORTS double norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM
...
@@ -933,45 +930,33 @@ CV_EXPORTS double norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM
//! computes sum of array elements
//! computes sum of array elements
//! supports only single channel images
//! supports only single channel images
CV_EXPORTS
Scalar
sum
(
const
GpuMat
&
src
);
CV_EXPORTS
Scalar
sum
(
const
GpuMat
&
src
);
//! computes sum of array elements
//! supports only single channel images
CV_EXPORTS
Scalar
sum
(
const
GpuMat
&
src
,
GpuMat
&
buf
);
CV_EXPORTS
Scalar
sum
(
const
GpuMat
&
src
,
GpuMat
&
buf
);
CV_EXPORTS
Scalar
sum
(
const
GpuMat
&
src
,
const
GpuMat
&
mask
,
GpuMat
&
buf
);
//! computes sum of array elements absolute values
//! computes sum of array elements absolute values
//! supports only single channel images
//! supports only single channel images
CV_EXPORTS
Scalar
absSum
(
const
GpuMat
&
src
);
CV_EXPORTS
Scalar
absSum
(
const
GpuMat
&
src
);
//! computes sum of array elements absolute values
//! supports only single channel images
CV_EXPORTS
Scalar
absSum
(
const
GpuMat
&
src
,
GpuMat
&
buf
);
CV_EXPORTS
Scalar
absSum
(
const
GpuMat
&
src
,
GpuMat
&
buf
);
CV_EXPORTS
Scalar
absSum
(
const
GpuMat
&
src
,
const
GpuMat
&
mask
,
GpuMat
&
buf
);
//! computes squared sum of array elements
//! computes squared sum of array elements
//! supports only single channel images
//! supports only single channel images
CV_EXPORTS
Scalar
sqrSum
(
const
GpuMat
&
src
);
CV_EXPORTS
Scalar
sqrSum
(
const
GpuMat
&
src
);
//! computes squared sum of array elements
//! supports only single channel images
CV_EXPORTS
Scalar
sqrSum
(
const
GpuMat
&
src
,
GpuMat
&
buf
);
CV_EXPORTS
Scalar
sqrSum
(
const
GpuMat
&
src
,
GpuMat
&
buf
);
CV_EXPORTS
Scalar
sqrSum
(
const
GpuMat
&
src
,
const
GpuMat
&
mask
,
GpuMat
&
buf
);
//! finds global minimum and maximum array elements and returns their values
//! finds global minimum and maximum array elements and returns their values
CV_EXPORTS
void
minMax
(
const
GpuMat
&
src
,
double
*
minVal
,
double
*
maxVal
=
0
,
const
GpuMat
&
mask
=
GpuMat
());
CV_EXPORTS
void
minMax
(
const
GpuMat
&
src
,
double
*
minVal
,
double
*
maxVal
=
0
,
const
GpuMat
&
mask
=
GpuMat
());
//! finds global minimum and maximum array elements and returns their values
CV_EXPORTS
void
minMax
(
const
GpuMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
const
GpuMat
&
mask
,
GpuMat
&
buf
);
CV_EXPORTS
void
minMax
(
const
GpuMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
const
GpuMat
&
mask
,
GpuMat
&
buf
);
//! finds global minimum and maximum array elements and returns their values with locations
//! finds global minimum and maximum array elements and returns their values with locations
CV_EXPORTS
void
minMaxLoc
(
const
GpuMat
&
src
,
double
*
minVal
,
double
*
maxVal
=
0
,
Point
*
minLoc
=
0
,
Point
*
maxLoc
=
0
,
CV_EXPORTS
void
minMaxLoc
(
const
GpuMat
&
src
,
double
*
minVal
,
double
*
maxVal
=
0
,
Point
*
minLoc
=
0
,
Point
*
maxLoc
=
0
,
const
GpuMat
&
mask
=
GpuMat
());
const
GpuMat
&
mask
=
GpuMat
());
//! finds global minimum and maximum array elements and returns their values with locations
CV_EXPORTS
void
minMaxLoc
(
const
GpuMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
Point
*
minLoc
,
Point
*
maxLoc
,
CV_EXPORTS
void
minMaxLoc
(
const
GpuMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
Point
*
minLoc
,
Point
*
maxLoc
,
const
GpuMat
&
mask
,
GpuMat
&
valbuf
,
GpuMat
&
locbuf
);
const
GpuMat
&
mask
,
GpuMat
&
valbuf
,
GpuMat
&
locbuf
);
//! counts non-zero array elements
//! counts non-zero array elements
CV_EXPORTS
int
countNonZero
(
const
GpuMat
&
src
);
CV_EXPORTS
int
countNonZero
(
const
GpuMat
&
src
);
//! counts non-zero array elements
CV_EXPORTS
int
countNonZero
(
const
GpuMat
&
src
,
GpuMat
&
buf
);
CV_EXPORTS
int
countNonZero
(
const
GpuMat
&
src
,
GpuMat
&
buf
);
//! reduces a matrix to a vector
//! reduces a matrix to a vector
...
...
modules/gpu/perf/perf_core.cpp
View file @
61b54149
...
@@ -1631,7 +1631,7 @@ PERF_TEST_P(Sz_Depth_Norm, Core_Norm, Combine(
...
@@ -1631,7 +1631,7 @@ PERF_TEST_P(Sz_Depth_Norm, Core_Norm, Combine(
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
d_buf
;
cv
::
gpu
::
GpuMat
d_buf
;
TEST_CYCLE
()
dst
=
cv
::
gpu
::
norm
(
d_src
,
normType
,
d_buf
);
TEST_CYCLE
()
dst
=
cv
::
gpu
::
norm
(
d_src
,
normType
,
cv
::
gpu
::
GpuMat
(),
d_buf
);
}
}
else
else
{
{
...
@@ -1701,7 +1701,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Sum, Combine(
...
@@ -1701,7 +1701,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Sum, Combine(
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
d_buf
;
cv
::
gpu
::
GpuMat
d_buf
;
TEST_CYCLE
()
dst
=
cv
::
gpu
::
sum
(
d_src
,
d_buf
);
TEST_CYCLE
()
dst
=
cv
::
gpu
::
sum
(
d_src
,
cv
::
gpu
::
GpuMat
(),
d_buf
);
}
}
else
else
{
{
...
@@ -1736,7 +1736,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumAbs, Combine(
...
@@ -1736,7 +1736,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumAbs, Combine(
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
d_buf
;
cv
::
gpu
::
GpuMat
d_buf
;
TEST_CYCLE
()
dst
=
cv
::
gpu
::
absSum
(
d_src
,
d_buf
);
TEST_CYCLE
()
dst
=
cv
::
gpu
::
absSum
(
d_src
,
cv
::
gpu
::
GpuMat
(),
d_buf
);
SANITY_CHECK
(
dst
,
1e-6
);
SANITY_CHECK
(
dst
,
1e-6
);
}
}
...
@@ -1770,7 +1770,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumSqr, Combine(
...
@@ -1770,7 +1770,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_SumSqr, Combine(
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
d_buf
;
cv
::
gpu
::
GpuMat
d_buf
;
TEST_CYCLE
()
dst
=
cv
::
gpu
::
sqrSum
(
d_src
,
d_buf
);
TEST_CYCLE
()
dst
=
cv
::
gpu
::
sqrSum
(
d_src
,
cv
::
gpu
::
GpuMat
(),
d_buf
);
SANITY_CHECK
(
dst
,
1e-6
);
SANITY_CHECK
(
dst
,
1e-6
);
}
}
...
...
modules/gpu/src/cuda/matrix_reductions.cu
View file @
61b54149
This diff is collapsed.
Click to expand it.
modules/gpu/src/matrix_reductions.cpp
View file @
61b54149
...
@@ -51,13 +51,17 @@ void cv::gpu::meanStdDev(const GpuMat&, Scalar&, Scalar&) { throw_nogpu(); }
...
@@ -51,13 +51,17 @@ void cv::gpu::meanStdDev(const GpuMat&, Scalar&, Scalar&) { throw_nogpu(); }
void
cv
::
gpu
::
meanStdDev
(
const
GpuMat
&
,
Scalar
&
,
Scalar
&
,
GpuMat
&
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
meanStdDev
(
const
GpuMat
&
,
Scalar
&
,
Scalar
&
,
GpuMat
&
)
{
throw_nogpu
();
}
double
cv
::
gpu
::
norm
(
const
GpuMat
&
,
int
)
{
throw_nogpu
();
return
0.0
;
}
double
cv
::
gpu
::
norm
(
const
GpuMat
&
,
int
)
{
throw_nogpu
();
return
0.0
;
}
double
cv
::
gpu
::
norm
(
const
GpuMat
&
,
int
,
GpuMat
&
)
{
throw_nogpu
();
return
0.0
;
}
double
cv
::
gpu
::
norm
(
const
GpuMat
&
,
int
,
GpuMat
&
)
{
throw_nogpu
();
return
0.0
;
}
double
cv
::
gpu
::
norm
(
const
GpuMat
&
,
int
,
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
return
0.0
;
}
double
cv
::
gpu
::
norm
(
const
GpuMat
&
,
const
GpuMat
&
,
int
)
{
throw_nogpu
();
return
0.0
;
}
double
cv
::
gpu
::
norm
(
const
GpuMat
&
,
const
GpuMat
&
,
int
)
{
throw_nogpu
();
return
0.0
;
}
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
,
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
absSum
(
const
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
absSum
(
const
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
absSum
(
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
absSum
(
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
absSum
(
const
GpuMat
&
,
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
sqrSum
(
const
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
sqrSum
(
const
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
sqrSum
(
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
sqrSum
(
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
sqrSum
(
const
GpuMat
&
,
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
void
cv
::
gpu
::
minMax
(
const
GpuMat
&
,
double
*
,
double
*
,
const
GpuMat
&
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
minMax
(
const
GpuMat
&
,
double
*
,
double
*
,
const
GpuMat
&
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
minMax
(
const
GpuMat
&
,
double
*
,
double
*
,
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
minMax
(
const
GpuMat
&
,
double
*
,
double
*
,
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
minMaxLoc
(
const
GpuMat
&
,
double
*
,
double
*
,
Point
*
,
Point
*
,
const
GpuMat
&
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
minMaxLoc
(
const
GpuMat
&
,
double
*
,
double
*
,
Point
*
,
Point
*
,
const
GpuMat
&
)
{
throw_nogpu
();
}
...
@@ -150,24 +154,30 @@ void cv::gpu::meanStdDev(const GpuMat& src, Scalar& mean, Scalar& stddev, GpuMat
...
@@ -150,24 +154,30 @@ void cv::gpu::meanStdDev(const GpuMat& src, Scalar& mean, Scalar& stddev, GpuMat
double
cv
::
gpu
::
norm
(
const
GpuMat
&
src
,
int
normType
)
double
cv
::
gpu
::
norm
(
const
GpuMat
&
src
,
int
normType
)
{
{
GpuMat
buf
;
GpuMat
buf
;
return
norm
(
src
,
normType
,
buf
);
return
norm
(
src
,
normType
,
GpuMat
(),
buf
);
}
}
double
cv
::
gpu
::
norm
(
const
GpuMat
&
src
,
int
normType
,
GpuMat
&
buf
)
double
cv
::
gpu
::
norm
(
const
GpuMat
&
src
,
int
normType
,
GpuMat
&
buf
)
{
return
norm
(
src
,
normType
,
GpuMat
(),
buf
);
}
double
cv
::
gpu
::
norm
(
const
GpuMat
&
src
,
int
normType
,
const
GpuMat
&
mask
,
GpuMat
&
buf
)
{
{
CV_Assert
(
normType
==
NORM_INF
||
normType
==
NORM_L1
||
normType
==
NORM_L2
);
CV_Assert
(
normType
==
NORM_INF
||
normType
==
NORM_L1
||
normType
==
NORM_L2
);
CV_Assert
(
mask
.
empty
()
||
(
mask
.
type
()
==
CV_8UC1
&&
mask
.
size
()
==
src
.
size
()
&&
src
.
channels
()
==
1
));
GpuMat
src_single_channel
=
src
.
reshape
(
1
);
GpuMat
src_single_channel
=
src
.
reshape
(
1
);
if
(
normType
==
NORM_L1
)
if
(
normType
==
NORM_L1
)
return
absSum
(
src_single_channel
,
buf
)[
0
];
return
absSum
(
src_single_channel
,
mask
,
buf
)[
0
];
if
(
normType
==
NORM_L2
)
if
(
normType
==
NORM_L2
)
return
std
::
sqrt
(
sqrSum
(
src_single_channel
,
buf
)[
0
]);
return
std
::
sqrt
(
sqrSum
(
src_single_channel
,
mask
,
buf
)[
0
]);
// NORM_INF
// NORM_INF
double
min_val
,
max_val
;
double
min_val
,
max_val
;
minMax
(
src_single_channel
,
&
min_val
,
&
max_val
,
GpuMat
()
,
buf
);
minMax
(
src_single_channel
,
&
min_val
,
&
max_val
,
mask
,
buf
);
return
std
::
max
(
std
::
abs
(
min_val
),
std
::
abs
(
max_val
));
return
std
::
max
(
std
::
abs
(
min_val
),
std
::
abs
(
max_val
));
}
}
...
@@ -209,24 +219,29 @@ namespace sum
...
@@ -209,24 +219,29 @@ namespace sum
void
getBufSize
(
int
cols
,
int
rows
,
int
cn
,
int
&
bufcols
,
int
&
bufrows
);
void
getBufSize
(
int
cols
,
int
rows
,
int
cn
,
int
&
bufcols
,
int
&
bufrows
);
template
<
typename
T
,
int
cn
>
template
<
typename
T
,
int
cn
>
void
run
(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
);
void
run
(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
,
PtrStepSzb
mask
);
template
<
typename
T
,
int
cn
>
template
<
typename
T
,
int
cn
>
void
runAbs
(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
);
void
runAbs
(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
,
PtrStepSzb
mask
);
template
<
typename
T
,
int
cn
>
template
<
typename
T
,
int
cn
>
void
runSqr
(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
);
void
runSqr
(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
,
PtrStepSzb
mask
);
}
}
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
src
)
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
src
)
{
{
GpuMat
buf
;
GpuMat
buf
;
return
sum
(
src
,
buf
);
return
sum
(
src
,
GpuMat
(),
buf
);
}
}
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
src
,
GpuMat
&
buf
)
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
src
,
GpuMat
&
buf
)
{
{
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
);
return
sum
(
src
,
GpuMat
(),
buf
);
}
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
src
,
const
GpuMat
&
mask
,
GpuMat
&
buf
)
{
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
,
PtrStepSzb
mask
);
static
const
func_t
funcs
[
7
][
5
]
=
static
const
func_t
funcs
[
7
][
5
]
=
{
{
{
0
,
::
sum
::
run
<
uchar
,
1
>
,
::
sum
::
run
<
uchar
,
2
>
,
::
sum
::
run
<
uchar
,
3
>
,
::
sum
::
run
<
uchar
,
4
>
},
{
0
,
::
sum
::
run
<
uchar
,
1
>
,
::
sum
::
run
<
uchar
,
2
>
,
::
sum
::
run
<
uchar
,
3
>
,
::
sum
::
run
<
uchar
,
4
>
},
...
@@ -238,6 +253,8 @@ Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf)
...
@@ -238,6 +253,8 @@ Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf)
{
0
,
::
sum
::
run
<
double
,
1
>
,
::
sum
::
run
<
double
,
2
>
,
::
sum
::
run
<
double
,
3
>
,
::
sum
::
run
<
double
,
4
>
}
{
0
,
::
sum
::
run
<
double
,
1
>
,
::
sum
::
run
<
double
,
2
>
,
::
sum
::
run
<
double
,
3
>
,
::
sum
::
run
<
double
,
4
>
}
};
};
CV_Assert
(
mask
.
empty
()
||
(
mask
.
type
()
==
CV_8UC1
&&
mask
.
size
()
==
src
.
size
())
);
if
(
src
.
depth
()
==
CV_64F
)
if
(
src
.
depth
()
==
CV_64F
)
{
{
if
(
!
deviceSupports
(
NATIVE_DOUBLE
))
if
(
!
deviceSupports
(
NATIVE_DOUBLE
))
...
@@ -252,7 +269,7 @@ Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf)
...
@@ -252,7 +269,7 @@ Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf)
const
func_t
func
=
funcs
[
src
.
depth
()][
src
.
channels
()];
const
func_t
func
=
funcs
[
src
.
depth
()][
src
.
channels
()];
double
result
[
4
];
double
result
[
4
];
func
(
src
,
buf
.
data
,
result
);
func
(
src
,
buf
.
data
,
result
,
mask
);
return
Scalar
(
result
[
0
],
result
[
1
],
result
[
2
],
result
[
3
]);
return
Scalar
(
result
[
0
],
result
[
1
],
result
[
2
],
result
[
3
]);
}
}
...
@@ -260,12 +277,17 @@ Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf)
...
@@ -260,12 +277,17 @@ Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf)
Scalar
cv
::
gpu
::
absSum
(
const
GpuMat
&
src
)
Scalar
cv
::
gpu
::
absSum
(
const
GpuMat
&
src
)
{
{
GpuMat
buf
;
GpuMat
buf
;
return
absSum
(
src
,
buf
);
return
absSum
(
src
,
GpuMat
(),
buf
);
}
}
Scalar
cv
::
gpu
::
absSum
(
const
GpuMat
&
src
,
GpuMat
&
buf
)
Scalar
cv
::
gpu
::
absSum
(
const
GpuMat
&
src
,
GpuMat
&
buf
)
{
{
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
);
return
absSum
(
src
,
GpuMat
(),
buf
);
}
Scalar
cv
::
gpu
::
absSum
(
const
GpuMat
&
src
,
const
GpuMat
&
mask
,
GpuMat
&
buf
)
{
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
,
PtrStepSzb
mask
);
static
const
func_t
funcs
[
7
][
5
]
=
static
const
func_t
funcs
[
7
][
5
]
=
{
{
{
0
,
::
sum
::
runAbs
<
uchar
,
1
>
,
::
sum
::
runAbs
<
uchar
,
2
>
,
::
sum
::
runAbs
<
uchar
,
3
>
,
::
sum
::
runAbs
<
uchar
,
4
>
},
{
0
,
::
sum
::
runAbs
<
uchar
,
1
>
,
::
sum
::
runAbs
<
uchar
,
2
>
,
::
sum
::
runAbs
<
uchar
,
3
>
,
::
sum
::
runAbs
<
uchar
,
4
>
},
...
@@ -277,6 +299,8 @@ Scalar cv::gpu::absSum(const GpuMat& src, GpuMat& buf)
...
@@ -277,6 +299,8 @@ Scalar cv::gpu::absSum(const GpuMat& src, GpuMat& buf)
{
0
,
::
sum
::
runAbs
<
double
,
1
>
,
::
sum
::
runAbs
<
double
,
2
>
,
::
sum
::
runAbs
<
double
,
3
>
,
::
sum
::
runAbs
<
double
,
4
>
}
{
0
,
::
sum
::
runAbs
<
double
,
1
>
,
::
sum
::
runAbs
<
double
,
2
>
,
::
sum
::
runAbs
<
double
,
3
>
,
::
sum
::
runAbs
<
double
,
4
>
}
};
};
CV_Assert
(
mask
.
empty
()
||
(
mask
.
type
()
==
CV_8UC1
&&
mask
.
size
()
==
src
.
size
())
);
if
(
src
.
depth
()
==
CV_64F
)
if
(
src
.
depth
()
==
CV_64F
)
{
{
if
(
!
deviceSupports
(
NATIVE_DOUBLE
))
if
(
!
deviceSupports
(
NATIVE_DOUBLE
))
...
@@ -291,7 +315,7 @@ Scalar cv::gpu::absSum(const GpuMat& src, GpuMat& buf)
...
@@ -291,7 +315,7 @@ Scalar cv::gpu::absSum(const GpuMat& src, GpuMat& buf)
const
func_t
func
=
funcs
[
src
.
depth
()][
src
.
channels
()];
const
func_t
func
=
funcs
[
src
.
depth
()][
src
.
channels
()];
double
result
[
4
];
double
result
[
4
];
func
(
src
,
buf
.
data
,
result
);
func
(
src
,
buf
.
data
,
result
,
mask
);
return
Scalar
(
result
[
0
],
result
[
1
],
result
[
2
],
result
[
3
]);
return
Scalar
(
result
[
0
],
result
[
1
],
result
[
2
],
result
[
3
]);
}
}
...
@@ -299,12 +323,17 @@ Scalar cv::gpu::absSum(const GpuMat& src, GpuMat& buf)
...
@@ -299,12 +323,17 @@ Scalar cv::gpu::absSum(const GpuMat& src, GpuMat& buf)
Scalar
cv
::
gpu
::
sqrSum
(
const
GpuMat
&
src
)
Scalar
cv
::
gpu
::
sqrSum
(
const
GpuMat
&
src
)
{
{
GpuMat
buf
;
GpuMat
buf
;
return
sqrSum
(
src
,
buf
);
return
sqrSum
(
src
,
GpuMat
(),
buf
);
}
}
Scalar
cv
::
gpu
::
sqrSum
(
const
GpuMat
&
src
,
GpuMat
&
buf
)
Scalar
cv
::
gpu
::
sqrSum
(
const
GpuMat
&
src
,
GpuMat
&
buf
)
{
{
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
);
return
sqrSum
(
src
,
GpuMat
(),
buf
);
}
Scalar
cv
::
gpu
::
sqrSum
(
const
GpuMat
&
src
,
const
GpuMat
&
mask
,
GpuMat
&
buf
)
{
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
void
*
buf
,
double
*
sum
,
PtrStepSzb
mask
);
static
const
func_t
funcs
[
7
][
5
]
=
static
const
func_t
funcs
[
7
][
5
]
=
{
{
{
0
,
::
sum
::
runSqr
<
uchar
,
1
>
,
::
sum
::
runSqr
<
uchar
,
2
>
,
::
sum
::
runSqr
<
uchar
,
3
>
,
::
sum
::
runSqr
<
uchar
,
4
>
},
{
0
,
::
sum
::
runSqr
<
uchar
,
1
>
,
::
sum
::
runSqr
<
uchar
,
2
>
,
::
sum
::
runSqr
<
uchar
,
3
>
,
::
sum
::
runSqr
<
uchar
,
4
>
},
...
@@ -316,6 +345,8 @@ Scalar cv::gpu::sqrSum(const GpuMat& src, GpuMat& buf)
...
@@ -316,6 +345,8 @@ Scalar cv::gpu::sqrSum(const GpuMat& src, GpuMat& buf)
{
0
,
::
sum
::
runSqr
<
double
,
1
>
,
::
sum
::
runSqr
<
double
,
2
>
,
::
sum
::
runSqr
<
double
,
3
>
,
::
sum
::
runSqr
<
double
,
4
>
}
{
0
,
::
sum
::
runSqr
<
double
,
1
>
,
::
sum
::
runSqr
<
double
,
2
>
,
::
sum
::
runSqr
<
double
,
3
>
,
::
sum
::
runSqr
<
double
,
4
>
}
};
};
CV_Assert
(
mask
.
empty
()
||
(
mask
.
type
()
==
CV_8UC1
&&
mask
.
size
()
==
src
.
size
())
);
if
(
src
.
depth
()
==
CV_64F
)
if
(
src
.
depth
()
==
CV_64F
)
{
{
if
(
!
deviceSupports
(
NATIVE_DOUBLE
))
if
(
!
deviceSupports
(
NATIVE_DOUBLE
))
...
@@ -330,7 +361,7 @@ Scalar cv::gpu::sqrSum(const GpuMat& src, GpuMat& buf)
...
@@ -330,7 +361,7 @@ Scalar cv::gpu::sqrSum(const GpuMat& src, GpuMat& buf)
const
func_t
func
=
funcs
[
src
.
depth
()][
src
.
channels
()];
const
func_t
func
=
funcs
[
src
.
depth
()][
src
.
channels
()];
double
result
[
4
];
double
result
[
4
];
func
(
src
,
buf
.
data
,
result
);
func
(
src
,
buf
.
data
,
result
,
mask
);
return
Scalar
(
result
[
0
],
result
[
1
],
result
[
2
],
result
[
3
]);
return
Scalar
(
result
[
0
],
result
[
1
],
result
[
2
],
result
[
3
]);
}
}
...
...
modules/gpu/test/test_core.cpp
View file @
61b54149
...
@@ -2918,10 +2918,12 @@ PARAM_TEST_CASE(Norm, cv::gpu::DeviceInfo, cv::Size, MatDepth, NormCode, UseRoi)
...
@@ -2918,10 +2918,12 @@ PARAM_TEST_CASE(Norm, cv::gpu::DeviceInfo, cv::Size, MatDepth, NormCode, UseRoi)
GPU_TEST_P
(
Norm
,
Accuracy
)
GPU_TEST_P
(
Norm
,
Accuracy
)
{
{
cv
::
Mat
src
=
randomMat
(
size
,
depth
);
cv
::
Mat
src
=
randomMat
(
size
,
depth
);
cv
::
Mat
mask
=
randomMat
(
size
,
CV_8UC1
,
0
,
2
);
double
val
=
cv
::
gpu
::
norm
(
loadMat
(
src
,
useRoi
),
normCode
);
cv
::
gpu
::
GpuMat
d_buf
;
double
val
=
cv
::
gpu
::
norm
(
loadMat
(
src
,
useRoi
),
normCode
,
loadMat
(
mask
,
useRoi
),
d_buf
);
double
val_gold
=
cv
::
norm
(
src
,
normCode
);
double
val_gold
=
cv
::
norm
(
src
,
normCode
,
mask
);
EXPECT_NEAR
(
val_gold
,
val
,
depth
<
CV_32F
?
0.0
:
1.0
);
EXPECT_NEAR
(
val_gold
,
val
,
depth
<
CV_32F
?
0.0
:
1.0
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment