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
cbb132cc
Commit
cbb132cc
authored
Jan 18, 2011
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added ensureSizeIsEnough into gpu module, updated reduction methods
parent
f3a26568
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
21 deletions
+58
-21
gpu_data_structures.tex
doc/gpu_data_structures.tex
+21
-0
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+5
-1
matrix_operations.hpp
modules/gpu/include/opencv2/gpu/matrix_operations.hpp
+5
-0
matrix_operations.cpp
modules/gpu/src/matrix_operations.cpp
+7
-0
matrix_reductions.cpp
modules/gpu/src/matrix_reductions.cpp
+20
-20
No files found.
doc/gpu_data_structures.tex
View file @
cbb132cc
...
...
@@ -12,4 +12,24 @@ Creates continuous matrix in GPU memory.
\cvarg
{
m
}{
Destination matrix. Will be only reshaped if it has proper type and area (
\texttt
{
rows
}
$
\times
$
\texttt
{
cols
}
).
}
\end{description}
Also the following wrappers are available:
\cvdefCpp
{
GpuMat createContinuous(int rows, int cols, int type);
\newline
void createContinuous(Size size, int type, GpuMat
\&
m);
\newline
GpuMat createContinuous(Size size, int type);
}
Matrix is called continuous if its elements are stored continuously, i.e. wuthout gaps in the end of each row.
\cvCppFunc
{
gpu::ensureSizeIsEnough
}
Ensures that size of matrix is big enough and matrix has proper type. The function doesn't reallocate memory if matrix has proper attributes already.
\cvdefCpp
{
void ensureSizeIsEnough(int rows, int cols, int type, GpuMat
\&
m);
}
\begin{description}
\cvarg
{
rows
}{
Minimum desired number of rows.
}
\cvarg
{
cols
}{
Minimum desired number of cols.
}
\cvarg
{
type
}{
Desired matrix type.
}
\cvarg
{
m
}{
Destination matrix.
}
\end{description}
Also the following wrapper is available:
\cvdefCpp
{
void ensureSizeIsEnough(Size size, int type, GpuMat
\&
m);
}
\ No newline at end of file
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
cbb132cc
...
...
@@ -252,9 +252,13 @@ namespace cv
#include "GpuMat_BetaDeprecated.hpp"
#endif
//!
c
reates continuous GPU matrix
//!
C
reates continuous GPU matrix
CV_EXPORTS
void
createContinuous
(
int
rows
,
int
cols
,
int
type
,
GpuMat
&
m
);
//! Ensures that size of the given matrix is not less than (rows, cols) size
//! and matrix type is match specified one too
CV_EXPORTS
void
ensureSizeIsEnough
(
int
rows
,
int
cols
,
int
type
,
GpuMat
&
m
);
//////////////////////////////// CudaMem ////////////////////////////////
// CudaMem is limited cv::Mat with page locked memory allocation.
// Page locked memory is only needed for async and faster coping to GPU.
...
...
modules/gpu/include/opencv2/gpu/matrix_operations.hpp
View file @
cbb132cc
...
...
@@ -364,6 +364,10 @@ inline GpuMat createContinuous(Size size, int type)
return
m
;
}
inline
void
ensureSizeIsEnough
(
Size
size
,
int
type
,
GpuMat
&
m
)
{
ensureSizeIsEnough
(
size
.
height
,
size
.
width
,
type
,
m
);
}
///////////////////////////////////////////////////////////////////////
...
...
@@ -401,6 +405,7 @@ inline CudaMem::CudaMem(const Mat& m, int _alloc_type) : flags(0), rows(0), cols
inline
CudaMem
::~
CudaMem
()
{
release
();
}
inline
CudaMem
&
CudaMem
::
operator
=
(
const
CudaMem
&
m
)
...
...
modules/gpu/src/matrix_operations.cpp
View file @
cbb132cc
...
...
@@ -551,6 +551,13 @@ void cv::gpu::createContinuous(int rows, int cols, int type, GpuMat& m)
m
=
m
.
reshape
(
0
,
rows
);
}
void
cv
::
gpu
::
ensureSizeIsEnough
(
int
rows
,
int
cols
,
int
type
,
GpuMat
&
m
)
{
if
(
m
.
type
()
==
type
&&
m
.
rows
>=
rows
&&
m
.
cols
>=
cols
)
return
;
m
.
create
(
rows
,
cols
,
type
);
}
///////////////////////////////////////////////////////////////////////
//////////////////////////////// CudaMem //////////////////////////////
...
...
modules/gpu/src/matrix_reductions.cpp
View file @
cbb132cc
...
...
@@ -159,7 +159,7 @@ Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf)
Size
bufSize
;
sum
::
get_buf_size_required
(
src
.
cols
,
src
.
rows
,
src
.
channels
(),
bufSize
.
width
,
bufSize
.
height
);
buf
.
create
(
bufSize
,
CV_8U
);
ensureSizeIsEnough
(
bufSize
,
CV_8U
,
buf
);
Caller
caller
=
callers
[
hasAtomicsSupport
(
getDevice
())][
src
.
depth
()];
if
(
!
caller
)
CV_Error
(
CV_StsBadArg
,
"sum: unsupported type"
);
...
...
@@ -192,7 +192,7 @@ Scalar cv::gpu::sqrSum(const GpuMat& src, GpuMat& buf)
Size
bufSize
;
sum
::
get_buf_size_required
(
src
.
cols
,
src
.
rows
,
src
.
channels
(),
bufSize
.
width
,
bufSize
.
height
);
buf
.
create
(
bufSize
,
CV_8U
);
ensureSizeIsEnough
(
bufSize
,
CV_8U
,
buf
);
Caller
caller
=
callers
[
hasAtomicsSupport
(
getDevice
())][
src
.
depth
()];
if
(
!
caller
)
CV_Error
(
CV_StsBadArg
,
"sqrSum: unsupported type"
);
...
...
@@ -265,7 +265,7 @@ void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal, const Gp
Size
bufSize
;
get_buf_size_required
(
src
.
cols
,
src
.
rows
,
src
.
elemSize
(),
bufSize
.
width
,
bufSize
.
height
);
buf
.
create
(
bufSize
,
CV_8U
);
ensureSizeIsEnough
(
bufSize
,
CV_8U
,
buf
);
if
(
mask
.
empty
())
{
...
...
@@ -292,31 +292,31 @@ namespace cv { namespace gpu { namespace mathfunc { namespace minmaxloc {
template
<
typename
T
>
void
min_max_loc_caller
(
const
DevMem2D
src
,
double
*
minval
,
double
*
maxval
,
int
minloc
[
2
],
int
maxloc
[
2
],
PtrStep
val
buf
,
PtrStep
locb
uf
);
int
minloc
[
2
],
int
maxloc
[
2
],
PtrStep
val
Buf
,
PtrStep
locB
uf
);
template
<
typename
T
>
void
min_max_loc_mask_caller
(
const
DevMem2D
src
,
const
PtrStep
mask
,
double
*
minval
,
double
*
maxval
,
int
minloc
[
2
],
int
maxloc
[
2
],
PtrStep
val
buf
,
PtrStep
locb
uf
);
int
minloc
[
2
],
int
maxloc
[
2
],
PtrStep
val
Buf
,
PtrStep
locB
uf
);
template
<
typename
T
>
void
min_max_loc_multipass_caller
(
const
DevMem2D
src
,
double
*
minval
,
double
*
maxval
,
int
minloc
[
2
],
int
maxloc
[
2
],
PtrStep
val
buf
,
PtrStep
locb
uf
);
int
minloc
[
2
],
int
maxloc
[
2
],
PtrStep
val
Buf
,
PtrStep
locB
uf
);
template
<
typename
T
>
void
min_max_loc_mask_multipass_caller
(
const
DevMem2D
src
,
const
PtrStep
mask
,
double
*
minval
,
double
*
maxval
,
int
minloc
[
2
],
int
maxloc
[
2
],
PtrStep
val
buf
,
PtrStep
locb
uf
);
int
minloc
[
2
],
int
maxloc
[
2
],
PtrStep
val
Buf
,
PtrStep
locB
uf
);
}}}}
void
cv
::
gpu
::
minMaxLoc
(
const
GpuMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
Point
*
minLoc
,
Point
*
maxLoc
,
const
GpuMat
&
mask
)
{
GpuMat
val
buf
,
locb
uf
;
minMaxLoc
(
src
,
minVal
,
maxVal
,
minLoc
,
maxLoc
,
mask
,
val
buf
,
locb
uf
);
GpuMat
val
Buf
,
locB
uf
;
minMaxLoc
(
src
,
minVal
,
maxVal
,
minLoc
,
maxLoc
,
mask
,
val
Buf
,
locB
uf
);
}
void
cv
::
gpu
::
minMaxLoc
(
const
GpuMat
&
src
,
double
*
minVal
,
double
*
maxVal
,
Point
*
minLoc
,
Point
*
maxLoc
,
const
GpuMat
&
mask
,
GpuMat
&
val
buf
,
GpuMat
&
locb
uf
)
const
GpuMat
&
mask
,
GpuMat
&
val
Buf
,
GpuMat
&
locB
uf
)
{
using
namespace
mathfunc
::
minmaxloc
;
...
...
@@ -348,23 +348,23 @@ void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point
int
minLoc_
[
2
];
int
maxLoc_
[
2
];
Size
val
buf_size
,
locbuf_s
ize
;
get_buf_size_required
(
src
.
cols
,
src
.
rows
,
src
.
elemSize
(),
val
buf_s
ize
.
width
,
val
buf_size
.
height
,
locbuf_size
.
width
,
locbuf_s
ize
.
height
);
valbuf
.
create
(
valbuf_size
,
CV_8U
);
locbuf
.
create
(
locbuf_size
,
CV_8U
);
Size
val
BufSize
,
locBufS
ize
;
get_buf_size_required
(
src
.
cols
,
src
.
rows
,
src
.
elemSize
(),
val
BufS
ize
.
width
,
val
BufSize
.
height
,
locBufSize
.
width
,
locBufS
ize
.
height
);
ensureSizeIsEnough
(
valBufSize
,
CV_8U
,
valBuf
);
ensureSizeIsEnough
(
locBufSize
,
CV_8U
,
locBuf
);
if
(
mask
.
empty
())
{
Caller
caller
=
callers
[
hasAtomicsSupport
(
getDevice
())][
src
.
type
()];
if
(
!
caller
)
CV_Error
(
CV_StsBadArg
,
"minMaxLoc: unsupported type"
);
caller
(
src
,
minVal
,
maxVal
,
minLoc_
,
maxLoc_
,
val
buf
,
locb
uf
);
caller
(
src
,
minVal
,
maxVal
,
minLoc_
,
maxLoc_
,
val
Buf
,
locB
uf
);
}
else
{
MaskedCaller
caller
=
masked_callers
[
hasAtomicsSupport
(
getDevice
())][
src
.
type
()];
if
(
!
caller
)
CV_Error
(
CV_StsBadArg
,
"minMaxLoc: unsupported type"
);
caller
(
src
,
mask
,
minVal
,
maxVal
,
minLoc_
,
maxLoc_
,
val
buf
,
locb
uf
);
caller
(
src
,
mask
,
minVal
,
maxVal
,
minLoc_
,
maxLoc_
,
val
Buf
,
locB
uf
);
}
if
(
minLoc
)
{
minLoc
->
x
=
minLoc_
[
0
];
minLoc
->
y
=
minLoc_
[
1
];
}
...
...
@@ -411,9 +411,9 @@ int cv::gpu::countNonZero(const GpuMat& src, GpuMat& buf)
CV_Assert
(
src
.
channels
()
==
1
);
CV_Assert
(
src
.
type
()
!=
CV_64F
||
hasNativeDoubleSupport
(
getDevice
()));
Size
buf
_s
ize
;
get_buf_size_required
(
src
.
cols
,
src
.
rows
,
buf
_size
.
width
,
buf_s
ize
.
height
);
buf
.
create
(
buf_size
,
CV_8U
);
Size
buf
S
ize
;
get_buf_size_required
(
src
.
cols
,
src
.
rows
,
buf
Size
.
width
,
bufS
ize
.
height
);
ensureSizeIsEnough
(
bufSize
,
CV_8U
,
buf
);
Caller
caller
=
callers
[
hasAtomicsSupport
(
getDevice
())][
src
.
type
()];
if
(
!
caller
)
CV_Error
(
CV_StsBadArg
,
"countNonZero: unsupported type"
);
...
...
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