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
16e74ab3
Commit
16e74ab3
authored
Feb 01, 2011
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added buffered version of norm, updated performance sample and docs
parent
37951426
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
11 deletions
+32
-11
gpu_matrix_reductions.tex
doc/gpu_matrix_reductions.tex
+9
-2
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+6
-1
matrix_reductions.cpp
modules/gpu/src/matrix_reductions.cpp
+10
-3
tests.cpp
samples/gpu/performance/tests.cpp
+7
-5
No files found.
doc/gpu_matrix_reductions.tex
View file @
16e74ab3
...
...
@@ -17,12 +17,19 @@ See also: \cvCppCross{meanStdDev}.
\cvCppFunc
{
gpu::norm
}
Returns norm of matrix (or of two matrices difference).
\cvdefCpp
{
double norm(const GpuMat
\&
src
1
, int normType=NORM
\_
L2);
}
\cvdefCpp
{
double norm(const GpuMat
\&
src, int normType=NORM
\_
L2);
}
\begin{description}
\cvarg
{
src
1
}{
Source matrix. Any matrices except 64F are supported.
}
\cvarg
{
src
}{
Source matrix. Any matrices except 64F are supported.
}
\cvarg
{
normType
}{
Norm type.
\texttt
{
NORM
\_
L1
}
,
\texttt
{
NORM
\_
L2
}
and
\texttt
{
NORM
\_
INF
}
are supported for now.
}
\end{description}
\cvdefCpp
{
double norm(const GpuMat
\&
src, int normType, GpuMat
\&
buf);
}
\begin{description}
\cvarg
{
src
}{
Source matrix. Any matrices except 64F are supported.
}
\cvarg
{
normType
}{
Norm type.
\texttt
{
NORM
\_
L1
}
,
\texttt
{
NORM
\_
L2
}
and
\texttt
{
NORM
\_
INF
}
are supported for now.
}
\cvarg
{
buf
}{
Optional buffer to avoid extra memory allocations. It's resized automatically.
}
\end{description}
\cvdefCpp
{
double norm(const GpuMat
\&
src1, const GpuMat
\&
src2,
\par
int normType=NORM
\_
L2);
}
\begin{description}
...
...
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
16e74ab3
...
...
@@ -750,9 +750,14 @@ namespace cv
//! computes norm of array
//! supports NORM_INF, NORM_L1, NORM_L2
//! supports
only CV_8UC1 type
//! supports
all matrices except 64F
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
);
//! computes norm of the difference between two arrays
//! supports NORM_INF, NORM_L1, NORM_L2
//! supports only CV_8UC1 type
...
...
modules/gpu/src/matrix_reductions.cpp
View file @
16e74ab3
...
...
@@ -49,6 +49,7 @@ using namespace cv::gpu;
void
cv
::
gpu
::
meanStdDev
(
const
GpuMat
&
,
Scalar
&
,
Scalar
&
)
{
throw_nogpu
();
}
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
&
,
const
GpuMat
&
,
int
)
{
throw_nogpu
();
return
0.0
;
}
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
Scalar
cv
::
gpu
::
sum
(
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
return
Scalar
();
}
...
...
@@ -87,19 +88,25 @@ void cv::gpu::meanStdDev(const GpuMat& src, Scalar& mean, Scalar& stddev)
// norm
double
cv
::
gpu
::
norm
(
const
GpuMat
&
src
,
int
normType
)
{
GpuMat
buf
;
return
norm
(
src
,
normType
,
buf
);
}
double
cv
::
gpu
::
norm
(
const
GpuMat
&
src
,
int
normType
,
GpuMat
&
buf
)
{
GpuMat
src_single_channel
=
src
.
reshape
(
1
);
if
(
normType
==
NORM_L1
)
return
absSum
(
src_single_channel
)[
0
];
return
absSum
(
src_single_channel
,
buf
)[
0
];
if
(
normType
==
NORM_L2
)
return
sqrt
(
sqrSum
(
src_single_channel
)[
0
]);
return
sqrt
(
sqrSum
(
src_single_channel
,
buf
)[
0
]);
if
(
normType
==
NORM_INF
)
{
double
min_val
,
max_val
;
minMax
(
src_single_channel
,
&
min_val
,
&
max_val
);
minMax
(
src_single_channel
,
&
min_val
,
&
max_val
,
GpuMat
(),
buf
);
return
std
::
max
(
std
::
abs
(
min_val
),
std
::
abs
(
max_val
));
}
...
...
samples/gpu/performance/tests.cpp
View file @
16e74ab3
...
...
@@ -198,22 +198,24 @@ TEST(integral)
TEST
(
norm
)
{
Mat
src
;
gpu
::
GpuMat
d_src
;
gpu
::
GpuMat
d_src
,
d_buf
;
for
(
int
size
=
1000
;
size
<=
8000
;
size
*=
2
)
{
SUBTEST
<<
"size "
<<
size
<<
",
8U
"
;
SUBTEST
<<
"size "
<<
size
<<
",
32F
"
;
gen
(
src
,
size
,
size
,
CV_
8U
,
0
,
256
);
gen
(
src
,
size
,
size
,
CV_
32F
,
0
,
1
);
CPU_ON
;
norm
(
src
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
norm
(
src
,
NORM_L2
);
CPU_OFF
;
d_src
=
src
;
GPU_ON
;
gpu
::
norm
(
d_src
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
gpu
::
norm
(
d_src
,
NORM_L2
,
d_buf
);
GPU_OFF
;
}
}
...
...
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