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
2932bedd
Commit
2932bedd
authored
Apr 26, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switched to Input/Output Array in gpuwarping functions
parent
75b86c97
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
52 deletions
+85
-52
gpuwarping.hpp
modules/gpuwarping/include/opencv2/gpuwarping.hpp
+15
-15
pyramids.cpp
modules/gpuwarping/src/pyramids.cpp
+16
-14
remap.cpp
modules/gpuwarping/src/remap.cpp
+14
-9
resize.cpp
modules/gpuwarping/src/resize.cpp
+14
-10
warp.cpp
modules/gpuwarping/src/warp.cpp
+0
-0
cascadeclassifier.cpp
samples/gpu/cascadeclassifier.cpp
+26
-4
No files found.
modules/gpuwarping/include/opencv2/gpuwarping.hpp
View file @
2932bedd
...
...
@@ -54,51 +54,51 @@ namespace cv { namespace gpu {
//! DST[x,y] = SRC[xmap[x,y],ymap[x,y]]
//! supports only CV_32FC1 map type
CV_EXPORTS
void
remap
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
const
GpuMat
&
xmap
,
const
GpuMat
&
ymap
,
CV_EXPORTS
void
remap
(
InputArray
src
,
OutputArray
dst
,
InputArray
xmap
,
InputArray
ymap
,
int
interpolation
,
int
borderMode
=
BORDER_CONSTANT
,
Scalar
borderValue
=
Scalar
(),
Stream
&
stream
=
Stream
::
Null
());
//! resizes the image
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_AREA
CV_EXPORTS
void
resize
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
Size
dsize
,
double
fx
=
0
,
double
fy
=
0
,
int
interpolation
=
INTER_LINEAR
,
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
resize
(
InputArray
src
,
OutputArray
dst
,
Size
dsize
,
double
fx
=
0
,
double
fy
=
0
,
int
interpolation
=
INTER_LINEAR
,
Stream
&
stream
=
Stream
::
Null
());
//! warps the image using affine transformation
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
CV_EXPORTS
void
warpAffine
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
const
Mat
&
M
,
Size
dsize
,
int
flags
=
INTER_LINEAR
,
CV_EXPORTS
void
warpAffine
(
InputArray
src
,
OutputArray
dst
,
InputArray
M
,
Size
dsize
,
int
flags
=
INTER_LINEAR
,
int
borderMode
=
BORDER_CONSTANT
,
Scalar
borderValue
=
Scalar
(),
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
buildWarpAffineMaps
(
const
Mat
&
M
,
bool
inverse
,
Size
dsize
,
GpuMat
&
xmap
,
GpuMat
&
ymap
,
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
buildWarpAffineMaps
(
InputArray
M
,
bool
inverse
,
Size
dsize
,
OutputArray
xmap
,
OutputArray
ymap
,
Stream
&
stream
=
Stream
::
Null
());
//! warps the image using perspective transformation
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
CV_EXPORTS
void
warpPerspective
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
const
Mat
&
M
,
Size
dsize
,
int
flags
=
INTER_LINEAR
,
CV_EXPORTS
void
warpPerspective
(
InputArray
src
,
OutputArray
dst
,
InputArray
M
,
Size
dsize
,
int
flags
=
INTER_LINEAR
,
int
borderMode
=
BORDER_CONSTANT
,
Scalar
borderValue
=
Scalar
(),
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
buildWarpPerspectiveMaps
(
const
Mat
&
M
,
bool
inverse
,
Size
dsize
,
GpuMat
&
xmap
,
GpuMat
&
ymap
,
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
buildWarpPerspectiveMaps
(
InputArray
M
,
bool
inverse
,
Size
dsize
,
OutputArray
xmap
,
OutputArray
ymap
,
Stream
&
stream
=
Stream
::
Null
());
//! builds plane warping maps
CV_EXPORTS
void
buildWarpPlaneMaps
(
Size
src_size
,
Rect
dst_roi
,
const
Mat
&
K
,
const
Mat
&
R
,
const
Mat
&
T
,
float
scale
,
GpuMat
&
map_x
,
GpuMat
&
map_y
,
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
buildWarpPlaneMaps
(
Size
src_size
,
Rect
dst_roi
,
InputArray
K
,
InputArray
R
,
InputArray
T
,
float
scale
,
OutputArray
map_x
,
OutputArray
map_y
,
Stream
&
stream
=
Stream
::
Null
());
//! builds cylindrical warping maps
CV_EXPORTS
void
buildWarpCylindricalMaps
(
Size
src_size
,
Rect
dst_roi
,
const
Mat
&
K
,
const
Mat
&
R
,
float
scale
,
GpuMat
&
map_x
,
GpuMat
&
map_y
,
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
buildWarpCylindricalMaps
(
Size
src_size
,
Rect
dst_roi
,
InputArray
K
,
InputArray
R
,
float
scale
,
OutputArray
map_x
,
OutputArray
map_y
,
Stream
&
stream
=
Stream
::
Null
());
//! builds spherical warping maps
CV_EXPORTS
void
buildWarpSphericalMaps
(
Size
src_size
,
Rect
dst_roi
,
const
Mat
&
K
,
const
Mat
&
R
,
float
scale
,
GpuMat
&
map_x
,
GpuMat
&
map_y
,
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
buildWarpSphericalMaps
(
Size
src_size
,
Rect
dst_roi
,
InputArray
K
,
InputArray
R
,
float
scale
,
OutputArray
map_x
,
OutputArray
map_y
,
Stream
&
stream
=
Stream
::
Null
());
//! rotates an image around the origin (0,0) and then shifts it
//! supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
//! supports 1, 3 or 4 channels images with CV_8U, CV_16U or CV_32F depth
CV_EXPORTS
void
rotate
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
Size
dsize
,
double
angle
,
double
xShift
=
0
,
double
yShift
=
0
,
CV_EXPORTS
void
rotate
(
InputArray
src
,
OutputArray
dst
,
Size
dsize
,
double
angle
,
double
xShift
=
0
,
double
yShift
=
0
,
int
interpolation
=
INTER_LINEAR
,
Stream
&
stream
=
Stream
::
Null
());
//! smoothes the source image and downsamples it
CV_EXPORTS
void
pyrDown
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
pyrDown
(
InputArray
src
,
OutputArray
dst
,
Stream
&
stream
=
Stream
::
Null
());
//! upsamples the source image and then smoothes it
CV_EXPORTS
void
pyrUp
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
pyrUp
(
InputArray
src
,
OutputArray
dst
,
Stream
&
stream
=
Stream
::
Null
());
class
CV_EXPORTS
ImagePyramid
{
...
...
modules/gpuwarping/src/pyramids.cpp
View file @
2932bedd
...
...
@@ -44,9 +44,8 @@
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
void
cv
::
gpu
::
pyrDown
(
const
GpuMat
&
,
GpuMat
&
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
pyrUp
(
const
GpuMat
&
,
GpuMat
&
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
pyrDown
(
InputArray
,
OutputArray
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
pyrUp
(
InputArray
,
OutputArray
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
ImagePyramid
::
build
(
const
GpuMat
&
,
int
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
ImagePyramid
::
getLayer
(
GpuMat
&
,
Size
,
Stream
&
)
const
{
throw_no_cuda
();
}
...
...
@@ -64,12 +63,11 @@ namespace cv { namespace gpu { namespace cudev
}
}}}
void
cv
::
gpu
::
pyrDown
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
Stream
&
stream
)
void
cv
::
gpu
::
pyrDown
(
InputArray
_src
,
OutputArray
_
dst
,
Stream
&
stream
)
{
using
namespace
cv
::
gpu
::
cudev
::
imgproc
;
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
PtrStepSzb
dst
,
cudaStream_t
stream
);
static
const
func_t
funcs
[
6
][
4
]
=
{
{
pyrDown_gpu
<
uchar
>
,
0
/*pyrDown_gpu<uchar2>*/
,
pyrDown_gpu
<
uchar3
>
,
pyrDown_gpu
<
uchar4
>
},
...
...
@@ -80,12 +78,15 @@ void cv::gpu::pyrDown(const GpuMat& src, GpuMat& dst, Stream& stream)
{
pyrDown_gpu
<
float
>
,
0
/*pyrDown_gpu<float2>*/
,
pyrDown_gpu
<
float3
>
,
pyrDown_gpu
<
float4
>
}
};
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
GpuMat
src
=
_src
.
getGpuMat
();
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
const
func_t
func
=
funcs
[
src
.
depth
()][
src
.
channels
()
-
1
];
CV_Assert
(
func
!=
0
);
CV_Assert
(
func
!=
0
);
dst
.
create
((
src
.
rows
+
1
)
/
2
,
(
src
.
cols
+
1
)
/
2
,
src
.
type
());
_dst
.
create
((
src
.
rows
+
1
)
/
2
,
(
src
.
cols
+
1
)
/
2
,
src
.
type
());
GpuMat
dst
=
_dst
.
getGpuMat
();
func
(
src
,
dst
,
StreamAccessor
::
getStream
(
stream
));
}
...
...
@@ -102,12 +103,11 @@ namespace cv { namespace gpu { namespace cudev
}
}}}
void
cv
::
gpu
::
pyrUp
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
Stream
&
stream
)
void
cv
::
gpu
::
pyrUp
(
InputArray
_src
,
OutputArray
_
dst
,
Stream
&
stream
)
{
using
namespace
cv
::
gpu
::
cudev
::
imgproc
;
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
PtrStepSzb
dst
,
cudaStream_t
stream
);
static
const
func_t
funcs
[
6
][
4
]
=
{
{
pyrUp_gpu
<
uchar
>
,
0
/*pyrUp_gpu<uchar2>*/
,
pyrUp_gpu
<
uchar3
>
,
pyrUp_gpu
<
uchar4
>
},
...
...
@@ -118,17 +118,19 @@ void cv::gpu::pyrUp(const GpuMat& src, GpuMat& dst, Stream& stream)
{
pyrUp_gpu
<
float
>
,
0
/*pyrUp_gpu<float2>*/
,
pyrUp_gpu
<
float3
>
,
pyrUp_gpu
<
float4
>
}
};
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
GpuMat
src
=
_src
.
getGpuMat
();
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
const
func_t
func
=
funcs
[
src
.
depth
()][
src
.
channels
()
-
1
];
CV_Assert
(
func
!=
0
);
CV_Assert
(
func
!=
0
);
dst
.
create
(
src
.
rows
*
2
,
src
.
cols
*
2
,
src
.
type
());
_dst
.
create
(
src
.
rows
*
2
,
src
.
cols
*
2
,
src
.
type
());
GpuMat
dst
=
_dst
.
getGpuMat
();
func
(
src
,
dst
,
StreamAccessor
::
getStream
(
stream
));
}
//////////////////////////////////////////////////////////////////////////////
// ImagePyramid
...
...
modules/gpuwarping/src/remap.cpp
View file @
2932bedd
...
...
@@ -44,7 +44,7 @@
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
void
cv
::
gpu
::
remap
(
const
GpuMat
&
,
GpuMat
&
,
const
GpuMat
&
,
const
GpuMat
&
,
int
,
int
,
Scalar
,
Stream
&
){
throw_no_cuda
();
}
void
cv
::
gpu
::
remap
(
InputArray
,
OutputArray
,
InputArray
,
InputArray
,
int
,
int
,
Scalar
,
Stream
&
){
throw_no_cuda
();
}
#else // HAVE_CUDA
...
...
@@ -58,13 +58,12 @@ namespace cv { namespace gpu { namespace cudev
}
}}}
void
cv
::
gpu
::
remap
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
const
GpuMat
&
xmap
,
const
GpuMat
&
ymap
,
int
interpolation
,
int
borderMode
,
Scalar
borderValue
,
Stream
&
stream
)
void
cv
::
gpu
::
remap
(
InputArray
_src
,
OutputArray
_dst
,
InputArray
_xmap
,
InputArray
_
ymap
,
int
interpolation
,
int
borderMode
,
Scalar
borderValue
,
Stream
&
stream
)
{
using
namespace
cv
::
gpu
::
cudev
::
imgproc
;
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
PtrStepSzb
srcWhole
,
int
xoff
,
int
yoff
,
PtrStepSzf
xmap
,
PtrStepSzf
ymap
,
PtrStepSzb
dst
,
int
interpolation
,
int
borderMode
,
const
float
*
borderValue
,
cudaStream_t
stream
,
bool
cc20
);
static
const
func_t
funcs
[
6
][
4
]
=
{
{
remap_gpu
<
uchar
>
,
0
/*remap_gpu<uchar2>*/
,
remap_gpu
<
uchar3
>
,
remap_gpu
<
uchar4
>
},
...
...
@@ -75,15 +74,21 @@ void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const Gp
{
remap_gpu
<
float
>
,
0
/*remap_gpu<float2>*/
,
remap_gpu
<
float3
>
,
remap_gpu
<
float4
>
}
};
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
CV_Assert
(
xmap
.
type
()
==
CV_32F
&&
ymap
.
type
()
==
CV_32F
&&
xmap
.
size
()
==
ymap
.
size
());
CV_Assert
(
interpolation
==
INTER_NEAREST
||
interpolation
==
INTER_LINEAR
||
interpolation
==
INTER_CUBIC
);
CV_Assert
(
borderMode
==
BORDER_REFLECT101
||
borderMode
==
BORDER_REPLICATE
||
borderMode
==
BORDER_CONSTANT
||
borderMode
==
BORDER_REFLECT
||
borderMode
==
BORDER_WRAP
);
GpuMat
src
=
_src
.
getGpuMat
();
GpuMat
xmap
=
_xmap
.
getGpuMat
();
GpuMat
ymap
=
_ymap
.
getGpuMat
();
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
CV_Assert
(
xmap
.
type
()
==
CV_32F
&&
ymap
.
type
()
==
CV_32F
&&
xmap
.
size
()
==
ymap
.
size
()
);
CV_Assert
(
interpolation
==
INTER_NEAREST
||
interpolation
==
INTER_LINEAR
||
interpolation
==
INTER_CUBIC
);
CV_Assert
(
borderMode
==
BORDER_REFLECT101
||
borderMode
==
BORDER_REPLICATE
||
borderMode
==
BORDER_CONSTANT
||
borderMode
==
BORDER_REFLECT
||
borderMode
==
BORDER_WRAP
);
const
func_t
func
=
funcs
[
src
.
depth
()][
src
.
channels
()
-
1
];
CV_Assert
(
func
!=
0
);
if
(
!
func
)
CV_Error
(
Error
::
StsUnsupportedFormat
,
"Unsupported input type"
);
dst
.
create
(
xmap
.
size
(),
src
.
type
());
_dst
.
create
(
xmap
.
size
(),
src
.
type
());
GpuMat
dst
=
_dst
.
getGpuMat
();
Scalar_
<
float
>
borderValueFloat
;
borderValueFloat
=
borderValue
;
...
...
modules/gpuwarping/src/resize.cpp
View file @
2932bedd
...
...
@@ -44,7 +44,7 @@
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
void
cv
::
gpu
::
resize
(
const
GpuMat
&
,
GpuMat
&
,
Size
,
double
,
double
,
int
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
resize
(
InputArray
,
OutputArray
,
Size
,
double
,
double
,
int
,
Stream
&
)
{
throw_no_cuda
();
}
#else // HAVE_CUDA
...
...
@@ -58,30 +58,34 @@ namespace cv { namespace gpu { namespace cudev
}
}}}
void
cv
::
gpu
::
resize
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
Size
dsize
,
double
fx
,
double
fy
,
int
interpolation
,
Stream
&
s
)
void
cv
::
gpu
::
resize
(
InputArray
_src
,
OutputArray
_dst
,
Size
dsize
,
double
fx
,
double
fy
,
int
interpolation
,
Stream
&
_stream
)
{
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
CV_Assert
(
interpolation
==
INTER_NEAREST
||
interpolation
==
INTER_LINEAR
||
interpolation
==
INTER_CUBIC
||
interpolation
==
INTER_AREA
);
CV_Assert
(
!
(
dsize
==
Size
())
||
(
fx
>
0
&&
fy
>
0
));
GpuMat
src
=
_src
.
getGpuMat
();
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
CV_Assert
(
interpolation
==
INTER_NEAREST
||
interpolation
==
INTER_LINEAR
||
interpolation
==
INTER_CUBIC
||
interpolation
==
INTER_AREA
);
CV_Assert
(
!
(
dsize
==
Size
())
||
(
fx
>
0
&&
fy
>
0
)
);
if
(
dsize
==
Size
())
{
dsize
=
Size
(
saturate_cast
<
int
>
(
src
.
cols
*
fx
),
saturate_cast
<
int
>
(
src
.
rows
*
fy
));
}
else
{
fx
=
static_cast
<
double
>
(
dsize
.
width
)
/
src
.
cols
;
fy
=
static_cast
<
double
>
(
dsize
.
height
)
/
src
.
rows
;
}
if
(
dsize
!=
dst
.
size
())
dst
.
create
(
dsize
,
src
.
type
());
_dst
.
create
(
dsize
,
src
.
type
());
GpuMat
dst
=
_dst
.
getGpuMat
();
if
(
dsize
==
src
.
size
())
{
src
.
copyTo
(
dst
,
s
);
src
.
copyTo
(
dst
,
_stream
);
return
;
}
cudaStream_t
stream
=
StreamAccessor
::
getStream
(
s
);
cudaStream_t
stream
=
StreamAccessor
::
getStream
(
_stream
);
Size
wholeSize
;
Point
ofs
;
...
...
modules/gpuwarping/src/warp.cpp
View file @
2932bedd
This diff is collapsed.
Click to expand it.
samples/gpu/cascadeclassifier.cpp
View file @
2932bedd
...
...
@@ -24,12 +24,11 @@ static void help()
}
template
<
class
T
>
void
convertAndResize
(
const
T
&
src
,
T
&
gray
,
T
&
resized
,
double
scale
)
static
void
convertAndResize
(
const
Mat
&
src
,
Mat
&
gray
,
Mat
&
resized
,
double
scale
)
{
if
(
src
.
channels
()
==
3
)
{
cvtColor
(
src
,
gray
,
COLOR_BGR2GRAY
);
cv
::
cv
tColor
(
src
,
gray
,
COLOR_BGR2GRAY
);
}
else
{
...
...
@@ -40,7 +39,30 @@ void convertAndResize(const T& src, T& gray, T& resized, double scale)
if
(
scale
!=
1
)
{
resize
(
gray
,
resized
,
sz
);
cv
::
resize
(
gray
,
resized
,
sz
);
}
else
{
resized
=
gray
;
}
}
static
void
convertAndResize
(
const
GpuMat
&
src
,
GpuMat
&
gray
,
GpuMat
&
resized
,
double
scale
)
{
if
(
src
.
channels
()
==
3
)
{
gpu
::
cvtColor
(
src
,
gray
,
COLOR_BGR2GRAY
);
}
else
{
gray
=
src
;
}
Size
sz
(
cvRound
(
gray
.
cols
*
scale
),
cvRound
(
gray
.
rows
*
scale
));
if
(
scale
!=
1
)
{
gpu
::
resize
(
gray
,
resized
,
sz
);
}
else
{
...
...
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