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
52a93782
Commit
52a93782
authored
Jul 15, 2013
by
Roman Donchenko
Committed by
OpenCV Buildbot
Jul 15, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #979 from jet47:gpuwarping-refactoring
parents
1590a1a5
0d9e3cfa
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
291 additions
and
249 deletions
+291
-249
warping.rst
modules/gpuwarping/doc/warping.rst
+36
-36
gpuwarping.hpp
modules/gpuwarping/include/opencv2/gpuwarping.hpp
+19
-37
perf_warping.cpp
modules/gpuwarping/perf/perf_warping.cpp
+2
-41
pyramids.cpp
modules/gpuwarping/src/pyramids.cpp
+66
-38
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
+114
-74
cascadeclassifier.cpp
samples/gpu/cascadeclassifier.cpp
+26
-4
No files found.
modules/gpuwarping/doc/warping.rst
View file @
52a93782
...
@@ -9,7 +9,7 @@ gpu::remap
...
@@ -9,7 +9,7 @@ gpu::remap
--------------
--------------
Applies a generic geometrical transformation to an image.
Applies a generic geometrical transformation to an image.
.. ocv:function:: void gpu::remap(
const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap, int interpolation, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream& stream=Stream::Null()
)
.. ocv:function:: void gpu::remap(
InputArray src, OutputArray dst, InputArray xmap, InputArray ymap, int interpolation, int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null()
)
:param src: Source image.
:param src: Source image.
...
@@ -43,7 +43,7 @@ gpu::resize
...
@@ -43,7 +43,7 @@ gpu::resize
---------------
---------------
Resizes an image.
Resizes an image.
.. ocv:function:: void gpu::resize(
const GpuMat& src, GpuMat&
dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::resize(
InputArray src, OutputArray
dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null())
:param src: Source image.
:param src: Source image.
...
@@ -80,7 +80,7 @@ gpu::warpAffine
...
@@ -80,7 +80,7 @@ gpu::warpAffine
-------------------
-------------------
Applies an affine transformation to an image.
Applies an affine transformation to an image.
.. ocv:function:: void gpu::warpAffine(
const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream& stream=Stream::Null()
)
.. ocv:function:: void gpu::warpAffine(
InputArray src, OutputArray dst, InputArray M, Size dsize, int flags = INTER_LINEAR, int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null()
)
:param src: Source image. ``CV_8U`` , ``CV_16U`` , ``CV_32S`` , or ``CV_32F`` depth and 1, 3, or 4 channels are supported.
:param src: Source image. ``CV_8U`` , ``CV_16U`` , ``CV_32S`` , or ``CV_32F`` depth and 1, 3, or 4 channels are supported.
...
@@ -102,7 +102,7 @@ gpu::buildWarpAffineMaps
...
@@ -102,7 +102,7 @@ gpu::buildWarpAffineMaps
------------------------
------------------------
Builds transformation maps for affine transformation.
Builds transformation maps for affine transformation.
.. ocv:function:: void gpu::buildWarpAffineMaps(
const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat&
ymap, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::buildWarpAffineMaps(
InputArray M, bool inverse, Size dsize, OutputArray xmap, OutputArray
ymap, Stream& stream = Stream::Null())
:param M: *2x3* transformation matrix.
:param M: *2x3* transformation matrix.
...
@@ -124,7 +124,7 @@ gpu::warpPerspective
...
@@ -124,7 +124,7 @@ gpu::warpPerspective
------------------------
------------------------
Applies a perspective transformation to an image.
Applies a perspective transformation to an image.
.. ocv:function:: void gpu::warpPerspective(
const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream& stream=Stream::Null()
)
.. ocv:function:: void gpu::warpPerspective(
InputArray src, OutputArray dst, InputArray M, Size dsize, int flags = INTER_LINEAR, int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null()
)
:param src: Source image. ``CV_8U`` , ``CV_16U`` , ``CV_32S`` , or ``CV_32F`` depth and 1, 3, or 4 channels are supported.
:param src: Source image. ``CV_8U`` , ``CV_16U`` , ``CV_32S`` , or ``CV_32F`` depth and 1, 3, or 4 channels are supported.
...
@@ -146,7 +146,7 @@ gpu::buildWarpPerspectiveMaps
...
@@ -146,7 +146,7 @@ gpu::buildWarpPerspectiveMaps
-----------------------------
-----------------------------
Builds transformation maps for perspective transformation.
Builds transformation maps for perspective transformation.
.. ocv:function:: void gpu::buildWarpAffineMaps(
const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat&
ymap, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::buildWarpAffineMaps(
InputArray M, bool inverse, Size dsize, OutputArray xmap, OutputArray
ymap, Stream& stream = Stream::Null())
:param M: *3x3* transformation matrix.
:param M: *3x3* transformation matrix.
...
@@ -164,67 +164,67 @@ Builds transformation maps for perspective transformation.
...
@@ -164,67 +164,67 @@ Builds transformation maps for perspective transformation.
gpu::rotate
gpu::buildWarpPlaneMaps
---------------
-----------------------
Rotates an image around the origin (0,0) and then shifts it.
Builds plane warping maps.
.. ocv:function:: void gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null())
:param src: Source image. Supports 1, 3 or 4 channels images with ``CV_8U`` , ``CV_16U`` or ``CV_32F`` depth.
:param dst: Destination image with the same type as ``src`` . The size is ``dsize`` .
.. ocv:function:: void gpu::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())
:param
dsize: Size of the destination image
.
:param
stream: Stream for the asynchronous version
.
:param angle: Angle of rotation in degrees.
:param xShift: Shift along the horizontal axis.
:param yShift: Shift along the vertical axis.
gpu::buildWarpCylindricalMaps
-----------------------------
Builds cylindrical warping maps.
:param interpolation: Interpolation method. Only ``INTER_NEAREST`` , ``INTER_LINEAR`` , and ``INTER_CUBIC`` are supported.
.. ocv:function:: void gpu::buildWarpCylindricalMaps(Size src_size, Rect dst_roi, InputArray K, InputArray R, float scale, OutputArray map_x, OutputArray map_y, Stream& stream = Stream::Null())
:param stream: Stream for the asynchronous version.
:param stream: Stream for the asynchronous version.
.. seealso:: :ocv:func:`gpu::warpAffine`
gpu::buildWarp
Plane
Maps
gpu::buildWarp
Spherical
Maps
-----------------------
-----------------------
----
Builds
plane
warping maps.
Builds
spherical
warping maps.
.. ocv:function:: void gpu::buildWarp
PlaneMaps( 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()
)
.. ocv:function:: void gpu::buildWarp
SphericalMaps(Size src_size, Rect dst_roi, InputArray K, InputArray R, float scale, OutputArray map_x, OutputArray map_y, Stream& stream = Stream::Null()
)
:param stream: Stream for the asynchronous version.
:param stream: Stream for the asynchronous version.
gpu::
buildWarpCylindricalMaps
gpu::
rotate
---------------
--------------
---------------
Builds cylindrical warping maps
.
Rotates an image around the origin (0,0) and then shifts it
.
.. ocv:function:: void gpu::
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()
)
.. ocv:function:: void gpu::
rotate(InputArray src, OutputArray dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null()
)
:param stream: Stream for the asynchronous version.
:param src: Source image. Supports 1, 3 or 4 channels images with ``CV_8U`` , ``CV_16U`` or ``CV_32F`` depth.
:param dst: Destination image with the same type as ``src`` . The size is ``dsize`` .
:param dsize: Size of the destination image.
:param angle: Angle of rotation in degrees.
gpu::buildWarpSphericalMaps
:param xShift: Shift along the horizontal axis.
---------------------------
Builds spherical warping map
s.
:param yShift: Shift along the vertical axi
s.
.. ocv:function:: void gpu::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() )
:param interpolation: Interpolation method. Only ``INTER_NEAREST`` , ``INTER_LINEAR`` , and ``INTER_CUBIC`` are supported.
:param stream: Stream for the asynchronous version.
:param stream: Stream for the asynchronous version.
.. seealso:: :ocv:func:`gpu::warpAffine`
gpu::pyrDown
gpu::pyrDown
-------------------
-------------------
Smoothes an image and downsamples it.
Smoothes an image and downsamples it.
.. ocv:function:: void gpu::pyrDown(
const GpuMat& src, GpuMat&
dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::pyrDown(
InputArray src, OutputArray
dst, Stream& stream = Stream::Null())
:param src: Source image.
:param src: Source image.
...
@@ -240,7 +240,7 @@ gpu::pyrUp
...
@@ -240,7 +240,7 @@ gpu::pyrUp
-------------------
-------------------
Upsamples an image and then smoothes it.
Upsamples an image and then smoothes it.
.. ocv:function:: void gpu::pyrUp(
const GpuMat& src, GpuMat&
dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::pyrUp(
InputArray src, OutputArray
dst, Stream& stream = Stream::Null())
:param src: Source image.
:param src: Source image.
...
...
modules/gpuwarping/include/opencv2/gpuwarping.hpp
View file @
52a93782
...
@@ -54,78 +54,60 @@ namespace cv { namespace gpu {
...
@@ -54,78 +54,60 @@ namespace cv { namespace gpu {
//! DST[x,y] = SRC[xmap[x,y],ymap[x,y]]
//! DST[x,y] = SRC[xmap[x,y],ymap[x,y]]
//! supports only CV_32FC1 map type
//! 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
(),
int
interpolation
,
int
borderMode
=
BORDER_CONSTANT
,
Scalar
borderValue
=
Scalar
(),
Stream
&
stream
=
Stream
::
Null
());
Stream
&
stream
=
Stream
::
Null
());
//! resizes the image
//! resizes the image
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_AREA
//! 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
//! warps the image using affine transformation
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
//! 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
());
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
//! warps the image using perspective transformation
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
//! 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
());
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
//! 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
,
CV_EXPORTS
void
buildWarpPlaneMaps
(
Size
src_size
,
Rect
dst_roi
,
InputArray
K
,
InputArray
R
,
InputArray
T
,
float
scale
,
GpuMat
&
map_x
,
GpuMat
&
map_y
,
Stream
&
stream
=
Stream
::
Null
());
OutputArray
map_x
,
OutputArray
map_y
,
Stream
&
stream
=
Stream
::
Null
());
//! builds cylindrical warping maps
//! builds cylindrical warping maps
CV_EXPORTS
void
buildWarpCylindricalMaps
(
Size
src_size
,
Rect
dst_roi
,
const
Mat
&
K
,
const
Mat
&
R
,
float
scale
,
CV_EXPORTS
void
buildWarpCylindricalMaps
(
Size
src_size
,
Rect
dst_roi
,
InputArray
K
,
InputArray
R
,
float
scale
,
GpuMat
&
map_x
,
GpuMat
&
map_y
,
Stream
&
stream
=
Stream
::
Null
());
OutputArray
map_x
,
OutputArray
map_y
,
Stream
&
stream
=
Stream
::
Null
());
//! builds spherical warping maps
//! builds spherical warping maps
CV_EXPORTS
void
buildWarpSphericalMaps
(
Size
src_size
,
Rect
dst_roi
,
const
Mat
&
K
,
const
Mat
&
R
,
float
scale
,
CV_EXPORTS
void
buildWarpSphericalMaps
(
Size
src_size
,
Rect
dst_roi
,
InputArray
K
,
InputArray
R
,
float
scale
,
GpuMat
&
map_x
,
GpuMat
&
map_y
,
Stream
&
stream
=
Stream
::
Null
());
OutputArray
map_x
,
OutputArray
map_y
,
Stream
&
stream
=
Stream
::
Null
());
//! rotates an image around the origin (0,0) and then shifts it
//! rotates an image around the origin (0,0) and then shifts it
//! supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
//! supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
//! supports 1, 3 or 4 channels images with CV_8U, CV_16U or CV_32F depth
//! 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
());
int
interpolation
=
INTER_LINEAR
,
Stream
&
stream
=
Stream
::
Null
());
//! smoothes the source image and downsamples it
//! 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
//! 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
class
CV_EXPORTS
ImagePyramid
:
public
Algorithm
{
{
public
:
public
:
inline
ImagePyramid
()
:
nLayers_
(
0
)
{}
virtual
void
getLayer
(
OutputArray
outImg
,
Size
outRoi
,
Stream
&
stream
=
Stream
::
Null
())
const
=
0
;
inline
ImagePyramid
(
const
GpuMat
&
img
,
int
nLayers
,
Stream
&
stream
=
Stream
::
Null
())
{
build
(
img
,
nLayers
,
stream
);
}
void
build
(
const
GpuMat
&
img
,
int
nLayers
,
Stream
&
stream
=
Stream
::
Null
());
void
getLayer
(
GpuMat
&
outImg
,
Size
outRoi
,
Stream
&
stream
=
Stream
::
Null
())
const
;
inline
void
release
()
{
layer0_
.
release
();
pyramid_
.
clear
();
nLayers_
=
0
;
}
private
:
GpuMat
layer0_
;
std
::
vector
<
GpuMat
>
pyramid_
;
int
nLayers_
;
};
};
CV_EXPORTS
Ptr
<
ImagePyramid
>
createImagePyramid
(
InputArray
img
,
int
nLayers
=
-
1
,
Stream
&
stream
=
Stream
::
Null
());
}}
// namespace cv { namespace gpu {
}}
// namespace cv { namespace gpu {
#endif
/* __OPENCV_GPUWARPING_HPP__ */
#endif
/* __OPENCV_GPUWARPING_HPP__ */
modules/gpuwarping/perf/perf_warping.cpp
View file @
52a93782
...
@@ -515,45 +515,6 @@ PERF_TEST_P(Sz_Depth_Cn, PyrUp,
...
@@ -515,45 +515,6 @@ PERF_TEST_P(Sz_Depth_Cn, PyrUp,
}
}
}
}
//////////////////////////////////////////////////////////////////////
// ImagePyramidBuild
PERF_TEST_P
(
Sz_Depth_Cn
,
ImagePyramidBuild
,
Combine
(
GPU_TYPICAL_MAT_SIZES
,
Values
(
CV_8U
,
CV_16U
,
CV_32F
),
GPU_CHANNELS_1_3_4
))
{
const
cv
::
Size
size
=
GET_PARAM
(
0
);
const
int
depth
=
GET_PARAM
(
1
);
const
int
channels
=
GET_PARAM
(
2
);
const
int
type
=
CV_MAKE_TYPE
(
depth
,
channels
);
cv
::
Mat
src
(
size
,
type
);
declare
.
in
(
src
,
WARMUP_RNG
);
const
int
nLayers
=
5
;
const
cv
::
Size
dstSize
(
size
.
width
/
2
+
10
,
size
.
height
/
2
+
10
);
if
(
PERF_RUN_GPU
())
{
const
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
ImagePyramid
d_pyr
;
TEST_CYCLE
()
d_pyr
.
build
(
d_src
,
nLayers
);
cv
::
gpu
::
GpuMat
dst
;
d_pyr
.
getLayer
(
dst
,
dstSize
);
GPU_SANITY_CHECK
(
dst
);
}
else
{
FAIL_NO_CPU
();
}
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// ImagePyramidGetLayer
// ImagePyramidGetLayer
...
@@ -579,9 +540,9 @@ PERF_TEST_P(Sz_Depth_Cn, ImagePyramidGetLayer,
...
@@ -579,9 +540,9 @@ PERF_TEST_P(Sz_Depth_Cn, ImagePyramidGetLayer,
const
cv
::
gpu
::
GpuMat
d_src
(
src
);
const
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
dst
;
cv
::
gpu
::
GpuMat
dst
;
cv
::
gpu
::
ImagePyramid
d_pyr
(
d_src
,
nLayers
);
cv
::
Ptr
<
cv
::
gpu
::
ImagePyramid
>
d_pyr
=
cv
::
gpu
::
createImagePyramid
(
d_src
,
nLayers
);
TEST_CYCLE
()
d_pyr
.
getLayer
(
dst
,
dstSize
);
TEST_CYCLE
()
d_pyr
->
getLayer
(
dst
,
dstSize
);
GPU_SANITY_CHECK
(
dst
);
GPU_SANITY_CHECK
(
dst
);
}
}
...
...
modules/gpuwarping/src/pyramids.cpp
View file @
52a93782
...
@@ -42,14 +42,15 @@
...
@@ -42,14 +42,15 @@
#include "precomp.hpp"
#include "precomp.hpp"
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
using
namespace
cv
;
using
namespace
cv
::
gpu
;
void
cv
::
gpu
::
pyrDown
(
const
GpuMat
&
,
GpuMat
&
,
Stream
&
)
{
throw_no_cuda
();
}
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
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
();
}
Ptr
<
ImagePyramid
>
cv
::
gpu
::
createImagePyramid
(
InputArray
,
int
,
Stream
&
)
{
throw_no_cuda
();
return
Ptr
<
ImagePyramid
>
();
}
void
cv
::
gpu
::
ImagePyramid
::
getLayer
(
GpuMat
&
,
Size
,
Stream
&
)
const
{
throw_no_cuda
();
}
#else // HAVE_CUDA
#else // HAVE_CUDA
...
@@ -64,12 +65,11 @@ namespace cv { namespace gpu { namespace cudev
...
@@ -64,12 +65,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
;
using
namespace
cv
::
gpu
::
cudev
::
imgproc
;
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
PtrStepSzb
dst
,
cudaStream_t
stream
);
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
PtrStepSzb
dst
,
cudaStream_t
stream
);
static
const
func_t
funcs
[
6
][
4
]
=
static
const
func_t
funcs
[
6
][
4
]
=
{
{
{
pyrDown_gpu
<
uchar
>
,
0
/*pyrDown_gpu<uchar2>*/
,
pyrDown_gpu
<
uchar3
>
,
pyrDown_gpu
<
uchar4
>
},
{
pyrDown_gpu
<
uchar
>
,
0
/*pyrDown_gpu<uchar2>*/
,
pyrDown_gpu
<
uchar3
>
,
pyrDown_gpu
<
uchar4
>
},
...
@@ -80,12 +80,15 @@ void cv::gpu::pyrDown(const GpuMat& src, GpuMat& dst, Stream& stream)
...
@@ -80,12 +80,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
>
}
{
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
];
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
));
func
(
src
,
dst
,
StreamAccessor
::
getStream
(
stream
));
}
}
...
@@ -102,12 +105,11 @@ namespace cv { namespace gpu { namespace cudev
...
@@ -102,12 +105,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
;
using
namespace
cv
::
gpu
::
cudev
::
imgproc
;
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
PtrStepSzb
dst
,
cudaStream_t
stream
);
typedef
void
(
*
func_t
)(
PtrStepSzb
src
,
PtrStepSzb
dst
,
cudaStream_t
stream
);
static
const
func_t
funcs
[
6
][
4
]
=
static
const
func_t
funcs
[
6
][
4
]
=
{
{
{
pyrUp_gpu
<
uchar
>
,
0
/*pyrUp_gpu<uchar2>*/
,
pyrUp_gpu
<
uchar3
>
,
pyrUp_gpu
<
uchar4
>
},
{
pyrUp_gpu
<
uchar
>
,
0
/*pyrUp_gpu<uchar2>*/
,
pyrUp_gpu
<
uchar3
>
,
pyrUp_gpu
<
uchar4
>
},
...
@@ -118,36 +120,52 @@ void cv::gpu::pyrUp(const GpuMat& src, GpuMat& dst, Stream& stream)
...
@@ -118,36 +120,52 @@ void cv::gpu::pyrUp(const GpuMat& src, GpuMat& dst, Stream& stream)
{
pyrUp_gpu
<
float
>
,
0
/*pyrUp_gpu<float2>*/
,
pyrUp_gpu
<
float3
>
,
pyrUp_gpu
<
float4
>
}
{
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
];
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
));
func
(
src
,
dst
,
StreamAccessor
::
getStream
(
stream
));
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// ImagePyramid
// ImagePyramid
void
cv
::
gpu
::
ImagePyramid
::
build
(
const
GpuMat
&
img
,
int
numLayers
,
Stream
&
stream
)
#ifdef HAVE_OPENCV_GPULEGACY
namespace
{
{
#ifndef HAVE_OPENCV_GPULEGACY
class
ImagePyramidImpl
:
public
ImagePyramid
(
void
)
img
;
{
(
void
)
numLayers
;
public
:
(
void
)
stream
;
ImagePyramidImpl
(
InputArray
img
,
int
nLayers
,
Stream
&
stream
);
throw_no_cuda
();
#else
void
getLayer
(
OutputArray
outImg
,
Size
outRoi
,
Stream
&
stream
=
Stream
::
Null
())
const
;
CV_Assert
(
img
.
depth
()
<=
CV_32F
&&
img
.
channels
()
<=
4
);
private
:
GpuMat
layer0_
;
std
::
vector
<
GpuMat
>
pyramid_
;
int
nLayers_
;
};
ImagePyramidImpl
::
ImagePyramidImpl
(
InputArray
_img
,
int
numLayers
,
Stream
&
stream
)
{
GpuMat
img
=
_img
.
getGpuMat
();
CV_Assert
(
img
.
depth
()
<=
CV_32F
&&
img
.
channels
()
<=
4
);
img
.
copyTo
(
layer0_
,
stream
);
layer0_
=
img
;
Size
szLastLayer
=
img
.
size
();
Size
szLastLayer
=
img
.
size
();
nLayers_
=
1
;
nLayers_
=
1
;
if
(
numLayers
<=
0
)
if
(
numLayers
<=
0
)
numLayers
=
255
;
//
it will cut-off when any of the dimensions goes 1
numLayers
=
255
;
//
it will cut-off when any of the dimensions goes 1
pyramid_
.
resize
(
numLayers
);
pyramid_
.
resize
(
numLayers
);
...
@@ -167,24 +185,19 @@ void cv::gpu::ImagePyramid::build(const GpuMat& img, int numLayers, Stream& stre
...
@@ -167,24 +185,19 @@ void cv::gpu::ImagePyramid::build(const GpuMat& img, int numLayers, Stream& stre
szLastLayer
=
szCurLayer
;
szLastLayer
=
szCurLayer
;
}
}
#endif
}
}
void
cv
::
gpu
::
ImagePyramid
::
getLayer
(
GpuMat
&
outImg
,
Size
outRoi
,
Stream
&
stream
)
const
void
ImagePyramidImpl
::
getLayer
(
OutputArray
_outImg
,
Size
outRoi
,
Stream
&
stream
)
const
{
{
#ifndef HAVE_OPENCV_GPULEGACY
CV_Assert
(
outRoi
.
width
<=
layer0_
.
cols
&&
outRoi
.
height
<=
layer0_
.
rows
&&
outRoi
.
width
>
0
&&
outRoi
.
height
>
0
);
(
void
)
outImg
;
(
void
)
outRoi
;
(
void
)
stream
;
throw_no_cuda
();
#else
CV_Assert
(
outRoi
.
width
<=
layer0_
.
cols
&&
outRoi
.
height
<=
layer0_
.
rows
&&
outRoi
.
width
>
0
&&
outRoi
.
height
>
0
);
ensureSizeIsEnough
(
outRoi
,
layer0_
.
type
(),
outImg
);
ensureSizeIsEnough
(
outRoi
,
layer0_
.
type
(),
_outImg
);
GpuMat
outImg
=
_outImg
.
getGpuMat
();
if
(
outRoi
.
width
==
layer0_
.
cols
&&
outRoi
.
height
==
layer0_
.
rows
)
if
(
outRoi
.
width
==
layer0_
.
cols
&&
outRoi
.
height
==
layer0_
.
rows
)
{
{
layer0_
.
copyTo
(
outImg
,
stream
);
layer0_
.
copyTo
(
outImg
,
stream
);
return
;
}
}
float
lastScale
=
1.0
f
;
float
lastScale
=
1.0
f
;
...
@@ -210,6 +223,21 @@ void cv::gpu::ImagePyramid::getLayer(GpuMat& outImg, Size outRoi, Stream& stream
...
@@ -210,6 +223,21 @@ void cv::gpu::ImagePyramid::getLayer(GpuMat& outImg, Size outRoi, Stream& stream
}
}
cudev
::
pyramid
::
interpolateFrom1
(
lastLayer
,
outImg
,
outImg
.
depth
(),
outImg
.
channels
(),
StreamAccessor
::
getStream
(
stream
));
cudev
::
pyramid
::
interpolateFrom1
(
lastLayer
,
outImg
,
outImg
.
depth
(),
outImg
.
channels
(),
StreamAccessor
::
getStream
(
stream
));
}
}
#endif
Ptr
<
ImagePyramid
>
cv
::
gpu
::
createImagePyramid
(
InputArray
img
,
int
nLayers
,
Stream
&
stream
)
{
#ifndef HAVE_OPENCV_GPULEGACY
(
void
)
img
;
(
void
)
numLayers
;
(
void
)
stream
;
throw_no_cuda
();
return
Ptr
<
ImagePyramid
>
();
#else
return
new
ImagePyramidImpl
(
img
,
nLayers
,
stream
);
#endif
#endif
}
}
...
...
modules/gpuwarping/src/remap.cpp
View file @
52a93782
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
#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
#else // HAVE_CUDA
...
@@ -58,13 +58,12 @@ namespace cv { namespace gpu { namespace cudev
...
@@ -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
;
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
,
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
);
int
borderMode
,
const
float
*
borderValue
,
cudaStream_t
stream
,
bool
cc20
);
static
const
func_t
funcs
[
6
][
4
]
=
static
const
func_t
funcs
[
6
][
4
]
=
{
{
{
remap_gpu
<
uchar
>
,
0
/*remap_gpu<uchar2>*/
,
remap_gpu
<
uchar3
>
,
remap_gpu
<
uchar4
>
},
{
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
...
@@ -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
>
}
{
remap_gpu
<
float
>
,
0
/*remap_gpu<float2>*/
,
remap_gpu
<
float3
>
,
remap_gpu
<
float4
>
}
};
};
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
GpuMat
src
=
_src
.
getGpuMat
();
CV_Assert
(
xmap
.
type
()
==
CV_32F
&&
ymap
.
type
()
==
CV_32F
&&
xmap
.
size
()
==
ymap
.
size
());
GpuMat
xmap
=
_xmap
.
getGpuMat
();
CV_Assert
(
interpolation
==
INTER_NEAREST
||
interpolation
==
INTER_LINEAR
||
interpolation
==
INTER_CUBIC
);
GpuMat
ymap
=
_ymap
.
getGpuMat
();
CV_Assert
(
borderMode
==
BORDER_REFLECT101
||
borderMode
==
BORDER_REPLICATE
||
borderMode
==
BORDER_CONSTANT
||
borderMode
==
BORDER_REFLECT
||
borderMode
==
BORDER_WRAP
);
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
];
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
;
Scalar_
<
float
>
borderValueFloat
;
borderValueFloat
=
borderValue
;
borderValueFloat
=
borderValue
;
...
...
modules/gpuwarping/src/resize.cpp
View file @
52a93782
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
#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
#else // HAVE_CUDA
...
@@ -58,30 +58,34 @@ namespace cv { namespace gpu { namespace cudev
...
@@ -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
);
GpuMat
src
=
_src
.
getGpuMat
();
CV_Assert
(
interpolation
==
INTER_NEAREST
||
interpolation
==
INTER_LINEAR
||
interpolation
==
INTER_CUBIC
||
interpolation
==
INTER_AREA
);
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
CV_Assert
(
!
(
dsize
==
Size
())
||
(
fx
>
0
&&
fy
>
0
));
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
())
if
(
dsize
==
Size
())
{
dsize
=
Size
(
saturate_cast
<
int
>
(
src
.
cols
*
fx
),
saturate_cast
<
int
>
(
src
.
rows
*
fy
));
dsize
=
Size
(
saturate_cast
<
int
>
(
src
.
cols
*
fx
),
saturate_cast
<
int
>
(
src
.
rows
*
fy
));
}
else
else
{
{
fx
=
static_cast
<
double
>
(
dsize
.
width
)
/
src
.
cols
;
fx
=
static_cast
<
double
>
(
dsize
.
width
)
/
src
.
cols
;
fy
=
static_cast
<
double
>
(
dsize
.
height
)
/
src
.
rows
;
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
())
if
(
dsize
==
src
.
size
())
{
{
src
.
copyTo
(
dst
,
s
);
src
.
copyTo
(
dst
,
_stream
);
return
;
return
;
}
}
cudaStream_t
stream
=
StreamAccessor
::
getStream
(
s
);
cudaStream_t
stream
=
StreamAccessor
::
getStream
(
_stream
);
Size
wholeSize
;
Size
wholeSize
;
Point
ofs
;
Point
ofs
;
...
...
modules/gpuwarping/src/warp.cpp
View file @
52a93782
...
@@ -47,17 +47,17 @@ using namespace cv::gpu;
...
@@ -47,17 +47,17 @@ using namespace cv::gpu;
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
void
cv
::
gpu
::
warpAffine
(
const
GpuMat
&
,
GpuMat
&
,
const
Mat
&
,
Size
,
int
,
int
,
Scalar
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
warpAffine
(
InputArray
,
OutputArray
,
InputArray
,
Size
,
int
,
int
,
Scalar
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
buildWarpAffineMaps
(
const
Mat
&
,
bool
,
Size
,
GpuMat
&
,
GpuMat
&
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
buildWarpAffineMaps
(
InputArray
,
bool
,
Size
,
OutputArray
,
OutputArray
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
warpPerspective
(
const
GpuMat
&
,
GpuMat
&
,
const
Mat
&
,
Size
,
int
,
int
,
Scalar
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
warpPerspective
(
InputArray
,
OutputArray
,
InputArray
,
Size
,
int
,
int
,
Scalar
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
buildWarpPerspectiveMaps
(
const
Mat
&
,
bool
,
Size
,
GpuMat
&
,
GpuMat
&
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
buildWarpPerspectiveMaps
(
InputArray
,
bool
,
Size
,
OutputArray
,
OutputArray
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
buildWarpPlaneMaps
(
Size
,
Rect
,
const
Mat
&
,
const
Mat
&
,
const
Mat
&
,
float
,
GpuMat
&
,
GpuMat
&
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
buildWarpPlaneMaps
(
Size
,
Rect
,
InputArray
,
InputArray
,
InputArray
,
float
,
OutputArray
,
OutputArray
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
buildWarpCylindricalMaps
(
Size
,
Rect
,
const
Mat
&
,
const
Mat
&
,
float
,
GpuMat
&
,
GpuMat
&
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
buildWarpCylindricalMaps
(
Size
,
Rect
,
InputArray
,
InputArray
,
float
,
OutputArray
,
OutputArray
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
buildWarpSphericalMaps
(
Size
,
Rect
,
const
Mat
&
,
const
Mat
&
,
float
,
GpuMat
&
,
GpuMat
&
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
buildWarpSphericalMaps
(
Size
,
Rect
,
InputArray
,
InputArray
,
float
,
OutputArray
,
OutputArray
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
rotate
(
const
GpuMat
&
,
GpuMat
&
,
Size
,
double
,
double
,
double
,
int
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
rotate
(
InputArray
,
OutputArray
,
Size
,
double
,
double
,
double
,
int
,
Stream
&
)
{
throw_no_cuda
();
}
#else // HAVE_CUDA
#else // HAVE_CUDA
...
@@ -79,14 +79,19 @@ namespace cv { namespace gpu { namespace cudev
...
@@ -79,14 +79,19 @@ namespace cv { namespace gpu { namespace cudev
}
}
}}}
}}}
void
cv
::
gpu
::
buildWarpAffineMaps
(
const
Mat
&
M
,
bool
inverse
,
Size
dsize
,
GpuMat
&
xmap
,
GpuMat
&
ymap
,
Stream
&
stream
)
void
cv
::
gpu
::
buildWarpAffineMaps
(
InputArray
_M
,
bool
inverse
,
Size
dsize
,
OutputArray
_xmap
,
OutputArray
_
ymap
,
Stream
&
stream
)
{
{
using
namespace
cv
::
gpu
::
cudev
::
imgproc
;
using
namespace
cv
::
gpu
::
cudev
::
imgproc
;
CV_Assert
(
M
.
rows
==
2
&&
M
.
cols
==
3
);
Mat
M
=
_M
.
getMat
(
);
xmap
.
create
(
dsize
,
CV_32FC1
);
CV_Assert
(
M
.
rows
==
2
&&
M
.
cols
==
3
);
ymap
.
create
(
dsize
,
CV_32FC1
);
_xmap
.
create
(
dsize
,
CV_32FC1
);
_ymap
.
create
(
dsize
,
CV_32FC1
);
GpuMat
xmap
=
_xmap
.
getGpuMat
();
GpuMat
ymap
=
_ymap
.
getGpuMat
();
float
coeffs
[
2
*
3
];
float
coeffs
[
2
*
3
];
Mat
coeffsMat
(
2
,
3
,
CV_32F
,
(
void
*
)
coeffs
);
Mat
coeffsMat
(
2
,
3
,
CV_32F
,
(
void
*
)
coeffs
);
...
@@ -103,14 +108,19 @@ void cv::gpu::buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat
...
@@ -103,14 +108,19 @@ void cv::gpu::buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat
buildWarpAffineMaps_gpu
(
coeffs
,
xmap
,
ymap
,
StreamAccessor
::
getStream
(
stream
));
buildWarpAffineMaps_gpu
(
coeffs
,
xmap
,
ymap
,
StreamAccessor
::
getStream
(
stream
));
}
}
void
cv
::
gpu
::
buildWarpPerspectiveMaps
(
const
Mat
&
M
,
bool
inverse
,
Size
dsize
,
GpuMat
&
xmap
,
GpuMat
&
ymap
,
Stream
&
stream
)
void
cv
::
gpu
::
buildWarpPerspectiveMaps
(
InputArray
_M
,
bool
inverse
,
Size
dsize
,
OutputArray
_xmap
,
OutputArray
_
ymap
,
Stream
&
stream
)
{
{
using
namespace
cv
::
gpu
::
cudev
::
imgproc
;
using
namespace
cv
::
gpu
::
cudev
::
imgproc
;
CV_Assert
(
M
.
rows
==
3
&&
M
.
cols
==
3
);
Mat
M
=
_M
.
getMat
();
CV_Assert
(
M
.
rows
==
3
&&
M
.
cols
==
3
);
xmap
.
create
(
dsize
,
CV_32FC1
);
_xmap
.
create
(
dsize
,
CV_32FC1
);
ymap
.
create
(
dsize
,
CV_32FC1
);
_ymap
.
create
(
dsize
,
CV_32FC1
);
GpuMat
xmap
=
_xmap
.
getGpuMat
();
GpuMat
ymap
=
_ymap
.
getGpuMat
();
float
coeffs
[
3
*
3
];
float
coeffs
[
3
*
3
];
Mat
coeffsMat
(
3
,
3
,
CV_32F
,
(
void
*
)
coeffs
);
Mat
coeffsMat
(
3
,
3
,
CV_32F
,
(
void
*
)
coeffs
);
...
@@ -174,17 +184,21 @@ namespace
...
@@ -174,17 +184,21 @@ namespace
};
};
}
}
void
cv
::
gpu
::
warpAffine
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
const
Mat
&
M
,
Size
dsize
,
int
flags
,
int
borderMode
,
Scalar
borderValue
,
Stream
&
s
)
void
cv
::
gpu
::
warpAffine
(
InputArray
_src
,
OutputArray
_dst
,
InputArray
_M
,
Size
dsize
,
int
flags
,
int
borderMode
,
Scalar
borderValue
,
Stream
&
stream
)
{
{
CV_Assert
(
M
.
rows
==
2
&&
M
.
cols
==
3
);
GpuMat
src
=
_src
.
getGpuMat
();
Mat
M
=
_M
.
getMat
();
CV_Assert
(
M
.
rows
==
2
&&
M
.
cols
==
3
);
int
interpolation
=
flags
&
INTER_MAX
;
const
int
interpolation
=
flags
&
INTER_MAX
;
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
CV_Assert
(
interpolation
==
INTER_NEAREST
||
interpolation
==
INTER_LINEAR
||
interpolation
==
INTER_CUBIC
);
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
);
CV_Assert
(
borderMode
==
BORDER_REFLECT101
||
borderMode
==
BORDER_REPLICATE
||
borderMode
==
BORDER_CONSTANT
||
borderMode
==
BORDER_REFLECT
||
borderMode
==
BORDER_WRAP
);
dst
.
create
(
dsize
,
src
.
type
());
_dst
.
create
(
dsize
,
src
.
type
());
GpuMat
dst
=
_dst
.
getGpuMat
();
Size
wholeSize
;
Size
wholeSize
;
Point
ofs
;
Point
ofs
;
...
@@ -258,7 +272,7 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz
...
@@ -258,7 +272,7 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz
}
}
};
};
dst
.
setTo
(
borderValue
);
dst
.
setTo
(
borderValue
,
stream
);
double
coeffs
[
2
][
3
];
double
coeffs
[
2
][
3
];
Mat
coeffsMat
(
2
,
3
,
CV_64F
,
(
void
*
)
coeffs
);
Mat
coeffsMat
(
2
,
3
,
CV_64F
,
(
void
*
)
coeffs
);
...
@@ -267,7 +281,7 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz
...
@@ -267,7 +281,7 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz
const
func_t
func
=
funcs
[(
flags
&
WARP_INVERSE_MAP
)
!=
0
][
src
.
depth
()][
src
.
channels
()
-
1
];
const
func_t
func
=
funcs
[(
flags
&
WARP_INVERSE_MAP
)
!=
0
][
src
.
depth
()][
src
.
channels
()
-
1
];
CV_Assert
(
func
!=
0
);
CV_Assert
(
func
!=
0
);
func
(
src
,
dst
,
coeffs
,
interpolation
,
StreamAccessor
::
getStream
(
s
));
func
(
src
,
dst
,
coeffs
,
interpolation
,
StreamAccessor
::
getStream
(
s
tream
));
}
}
else
else
{
{
...
@@ -305,21 +319,25 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz
...
@@ -305,21 +319,25 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz
borderValueFloat
=
borderValue
;
borderValueFloat
=
borderValue
;
func
(
src
,
PtrStepSzb
(
wholeSize
.
height
,
wholeSize
.
width
,
src
.
datastart
,
src
.
step
),
ofs
.
x
,
ofs
.
y
,
coeffs
,
func
(
src
,
PtrStepSzb
(
wholeSize
.
height
,
wholeSize
.
width
,
src
.
datastart
,
src
.
step
),
ofs
.
x
,
ofs
.
y
,
coeffs
,
dst
,
interpolation
,
borderMode
,
borderValueFloat
.
val
,
StreamAccessor
::
getStream
(
s
),
deviceSupports
(
FEATURE_SET_COMPUTE_20
));
dst
,
interpolation
,
borderMode
,
borderValueFloat
.
val
,
StreamAccessor
::
getStream
(
s
tream
),
deviceSupports
(
FEATURE_SET_COMPUTE_20
));
}
}
}
}
void
cv
::
gpu
::
warpPerspective
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
const
Mat
&
M
,
Size
dsize
,
int
flags
,
int
borderMode
,
Scalar
borderValue
,
Stream
&
s
)
void
cv
::
gpu
::
warpPerspective
(
InputArray
_src
,
OutputArray
_dst
,
InputArray
_M
,
Size
dsize
,
int
flags
,
int
borderMode
,
Scalar
borderValue
,
Stream
&
stream
)
{
{
CV_Assert
(
M
.
rows
==
3
&&
M
.
cols
==
3
);
GpuMat
src
=
_src
.
getGpuMat
();
Mat
M
=
_M
.
getMat
();
int
interpolation
=
flags
&
INTER_MAX
;
CV_Assert
(
M
.
rows
==
3
&&
M
.
cols
==
3
)
;
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
const
int
interpolation
=
flags
&
INTER_MAX
;
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
);
dst
.
create
(
dsize
,
src
.
type
());
CV_Assert
(
src
.
depth
()
<=
CV_32F
&&
src
.
channels
()
<=
4
);
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
)
;
_dst
.
create
(
dsize
,
src
.
type
());
GpuMat
dst
=
_dst
.
getGpuMat
();
Size
wholeSize
;
Size
wholeSize
;
Point
ofs
;
Point
ofs
;
...
@@ -393,7 +411,7 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size
...
@@ -393,7 +411,7 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size
}
}
};
};
dst
.
setTo
(
borderValue
);
dst
.
setTo
(
borderValue
,
stream
);
double
coeffs
[
3
][
3
];
double
coeffs
[
3
][
3
];
Mat
coeffsMat
(
3
,
3
,
CV_64F
,
(
void
*
)
coeffs
);
Mat
coeffsMat
(
3
,
3
,
CV_64F
,
(
void
*
)
coeffs
);
...
@@ -402,7 +420,7 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size
...
@@ -402,7 +420,7 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size
const
func_t
func
=
funcs
[(
flags
&
WARP_INVERSE_MAP
)
!=
0
][
src
.
depth
()][
src
.
channels
()
-
1
];
const
func_t
func
=
funcs
[(
flags
&
WARP_INVERSE_MAP
)
!=
0
][
src
.
depth
()][
src
.
channels
()
-
1
];
CV_Assert
(
func
!=
0
);
CV_Assert
(
func
!=
0
);
func
(
src
,
dst
,
coeffs
,
interpolation
,
StreamAccessor
::
getStream
(
s
));
func
(
src
,
dst
,
coeffs
,
interpolation
,
StreamAccessor
::
getStream
(
s
tream
));
}
}
else
else
{
{
...
@@ -440,7 +458,7 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size
...
@@ -440,7 +458,7 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size
borderValueFloat
=
borderValue
;
borderValueFloat
=
borderValue
;
func
(
src
,
PtrStepSzb
(
wholeSize
.
height
,
wholeSize
.
width
,
src
.
datastart
,
src
.
step
),
ofs
.
x
,
ofs
.
y
,
coeffs
,
func
(
src
,
PtrStepSzb
(
wholeSize
.
height
,
wholeSize
.
width
,
src
.
datastart
,
src
.
step
),
ofs
.
x
,
ofs
.
y
,
coeffs
,
dst
,
interpolation
,
borderMode
,
borderValueFloat
.
val
,
StreamAccessor
::
getStream
(
s
),
deviceSupports
(
FEATURE_SET_COMPUTE_20
));
dst
,
interpolation
,
borderMode
,
borderValueFloat
.
val
,
StreamAccessor
::
getStream
(
s
tream
),
deviceSupports
(
FEATURE_SET_COMPUTE_20
));
}
}
}
}
...
@@ -457,23 +475,30 @@ namespace cv { namespace gpu { namespace cudev
...
@@ -457,23 +475,30 @@ namespace cv { namespace gpu { namespace cudev
}
}
}}}
}}}
void
cv
::
gpu
::
buildWarpPlaneMaps
(
Size
src_size
,
Rect
dst_roi
,
const
Mat
&
K
,
const
Mat
&
R
,
const
Mat
&
T
,
void
cv
::
gpu
::
buildWarpPlaneMaps
(
Size
src_size
,
Rect
dst_roi
,
InputArray
_K
,
InputArray
_R
,
InputArray
_
T
,
float
scale
,
GpuMat
&
map_x
,
GpuMat
&
map_y
,
Stream
&
stream
)
float
scale
,
OutputArray
_map_x
,
OutputArray
_
map_y
,
Stream
&
stream
)
{
{
(
void
)
src_size
;
(
void
)
src_size
;
using
namespace
::
cv
::
gpu
::
cudev
::
imgproc
;
Mat
K
=
_K
.
getMat
();
Mat
R
=
_R
.
getMat
();
Mat
T
=
_T
.
getMat
();
CV_Assert
(
K
.
size
()
==
Size
(
3
,
3
)
&&
K
.
type
()
==
CV_32F
);
CV_Assert
(
K
.
size
()
==
Size
(
3
,
3
)
&&
K
.
type
()
==
CV_32FC1
);
CV_Assert
(
R
.
size
()
==
Size
(
3
,
3
)
&&
R
.
type
()
==
CV_32F
);
CV_Assert
(
R
.
size
()
==
Size
(
3
,
3
)
&&
R
.
type
()
==
CV_32FC1
);
CV_Assert
(
(
T
.
size
()
==
Size
(
3
,
1
)
||
T
.
size
()
==
Size
(
1
,
3
))
&&
T
.
type
()
==
CV_32F
&&
T
.
isContinuous
()
);
CV_Assert
(
(
T
.
size
()
==
Size
(
3
,
1
)
||
T
.
size
()
==
Size
(
1
,
3
))
&&
T
.
type
()
==
CV_32FC1
&&
T
.
isContinuous
()
);
Mat
K_Rinv
=
K
*
R
.
t
();
Mat
K_Rinv
=
K
*
R
.
t
();
Mat
R_Kinv
=
R
*
K
.
inv
();
Mat
R_Kinv
=
R
*
K
.
inv
();
CV_Assert
(
K_Rinv
.
isContinuous
());
CV_Assert
(
K_Rinv
.
isContinuous
()
);
CV_Assert
(
R_Kinv
.
isContinuous
());
CV_Assert
(
R_Kinv
.
isContinuous
()
);
_map_x
.
create
(
dst_roi
.
size
(),
CV_32FC1
);
_map_y
.
create
(
dst_roi
.
size
(),
CV_32FC1
);
GpuMat
map_x
=
_map_x
.
getGpuMat
();
GpuMat
map_y
=
_map_y
.
getGpuMat
();
map_x
.
create
(
dst_roi
.
size
(),
CV_32F
);
map_y
.
create
(
dst_roi
.
size
(),
CV_32F
);
cudev
::
imgproc
::
buildWarpPlaneMaps
(
dst_roi
.
tl
().
x
,
dst_roi
.
tl
().
y
,
map_x
,
map_y
,
K_Rinv
.
ptr
<
float
>
(),
R_Kinv
.
ptr
<
float
>
(),
cudev
::
imgproc
::
buildWarpPlaneMaps
(
dst_roi
.
tl
().
x
,
dst_roi
.
tl
().
y
,
map_x
,
map_y
,
K_Rinv
.
ptr
<
float
>
(),
R_Kinv
.
ptr
<
float
>
(),
T
.
ptr
<
float
>
(),
scale
,
StreamAccessor
::
getStream
(
stream
));
T
.
ptr
<
float
>
(),
scale
,
StreamAccessor
::
getStream
(
stream
));
}
}
...
@@ -491,22 +516,28 @@ namespace cv { namespace gpu { namespace cudev
...
@@ -491,22 +516,28 @@ namespace cv { namespace gpu { namespace cudev
}
}
}}}
}}}
void
cv
::
gpu
::
buildWarpCylindricalMaps
(
Size
src_size
,
Rect
dst_roi
,
const
Mat
&
K
,
const
Mat
&
R
,
float
scale
,
void
cv
::
gpu
::
buildWarpCylindricalMaps
(
Size
src_size
,
Rect
dst_roi
,
InputArray
_K
,
InputArray
_
R
,
float
scale
,
GpuMat
&
map_x
,
GpuMat
&
map_y
,
Stream
&
stream
)
OutputArray
_map_x
,
OutputArray
_
map_y
,
Stream
&
stream
)
{
{
(
void
)
src_size
;
(
void
)
src_size
;
using
namespace
::
cv
::
gpu
::
cudev
::
imgproc
;
CV_Assert
(
K
.
size
()
==
Size
(
3
,
3
)
&&
K
.
type
()
==
CV_32F
);
Mat
K
=
_K
.
getMat
();
CV_Assert
(
R
.
size
()
==
Size
(
3
,
3
)
&&
R
.
type
()
==
CV_32F
);
Mat
R
=
_R
.
getMat
();
CV_Assert
(
K
.
size
()
==
Size
(
3
,
3
)
&&
K
.
type
()
==
CV_32FC1
);
CV_Assert
(
R
.
size
()
==
Size
(
3
,
3
)
&&
R
.
type
()
==
CV_32FC1
);
Mat
K_Rinv
=
K
*
R
.
t
();
Mat
K_Rinv
=
K
*
R
.
t
();
Mat
R_Kinv
=
R
*
K
.
inv
();
Mat
R_Kinv
=
R
*
K
.
inv
();
CV_Assert
(
K_Rinv
.
isContinuous
());
CV_Assert
(
K_Rinv
.
isContinuous
()
);
CV_Assert
(
R_Kinv
.
isContinuous
());
CV_Assert
(
R_Kinv
.
isContinuous
()
);
_map_x
.
create
(
dst_roi
.
size
(),
CV_32FC1
);
_map_y
.
create
(
dst_roi
.
size
(),
CV_32FC1
);
GpuMat
map_x
=
_map_x
.
getGpuMat
();
GpuMat
map_y
=
_map_y
.
getGpuMat
();
map_x
.
create
(
dst_roi
.
size
(),
CV_32F
);
map_y
.
create
(
dst_roi
.
size
(),
CV_32F
);
cudev
::
imgproc
::
buildWarpCylindricalMaps
(
dst_roi
.
tl
().
x
,
dst_roi
.
tl
().
y
,
map_x
,
map_y
,
K_Rinv
.
ptr
<
float
>
(),
R_Kinv
.
ptr
<
float
>
(),
scale
,
StreamAccessor
::
getStream
(
stream
));
cudev
::
imgproc
::
buildWarpCylindricalMaps
(
dst_roi
.
tl
().
x
,
dst_roi
.
tl
().
y
,
map_x
,
map_y
,
K_Rinv
.
ptr
<
float
>
(),
R_Kinv
.
ptr
<
float
>
(),
scale
,
StreamAccessor
::
getStream
(
stream
));
}
}
...
@@ -524,22 +555,28 @@ namespace cv { namespace gpu { namespace cudev
...
@@ -524,22 +555,28 @@ namespace cv { namespace gpu { namespace cudev
}
}
}}}
}}}
void
cv
::
gpu
::
buildWarpSphericalMaps
(
Size
src_size
,
Rect
dst_roi
,
const
Mat
&
K
,
const
Mat
&
R
,
float
scale
,
void
cv
::
gpu
::
buildWarpSphericalMaps
(
Size
src_size
,
Rect
dst_roi
,
InputArray
_K
,
InputArray
_
R
,
float
scale
,
GpuMat
&
map_x
,
GpuMat
&
map_y
,
Stream
&
stream
)
OutputArray
_map_x
,
OutputArray
_
map_y
,
Stream
&
stream
)
{
{
(
void
)
src_size
;
(
void
)
src_size
;
using
namespace
::
cv
::
gpu
::
cudev
::
imgproc
;
CV_Assert
(
K
.
size
()
==
Size
(
3
,
3
)
&&
K
.
type
()
==
CV_32F
);
Mat
K
=
_K
.
getMat
();
CV_Assert
(
R
.
size
()
==
Size
(
3
,
3
)
&&
R
.
type
()
==
CV_32F
);
Mat
R
=
_R
.
getMat
();
CV_Assert
(
K
.
size
()
==
Size
(
3
,
3
)
&&
K
.
type
()
==
CV_32FC1
);
CV_Assert
(
R
.
size
()
==
Size
(
3
,
3
)
&&
R
.
type
()
==
CV_32FC1
);
Mat
K_Rinv
=
K
*
R
.
t
();
Mat
K_Rinv
=
K
*
R
.
t
();
Mat
R_Kinv
=
R
*
K
.
inv
();
Mat
R_Kinv
=
R
*
K
.
inv
();
CV_Assert
(
K_Rinv
.
isContinuous
());
CV_Assert
(
K_Rinv
.
isContinuous
()
);
CV_Assert
(
R_Kinv
.
isContinuous
());
CV_Assert
(
R_Kinv
.
isContinuous
()
);
_map_x
.
create
(
dst_roi
.
size
(),
CV_32FC1
);
_map_y
.
create
(
dst_roi
.
size
(),
CV_32FC1
);
GpuMat
map_x
=
_map_x
.
getGpuMat
();
GpuMat
map_y
=
_map_y
.
getGpuMat
();
map_x
.
create
(
dst_roi
.
size
(),
CV_32F
);
map_y
.
create
(
dst_roi
.
size
(),
CV_32F
);
cudev
::
imgproc
::
buildWarpSphericalMaps
(
dst_roi
.
tl
().
x
,
dst_roi
.
tl
().
y
,
map_x
,
map_y
,
K_Rinv
.
ptr
<
float
>
(),
R_Kinv
.
ptr
<
float
>
(),
scale
,
StreamAccessor
::
getStream
(
stream
));
cudev
::
imgproc
::
buildWarpSphericalMaps
(
dst_roi
.
tl
().
x
,
dst_roi
.
tl
().
y
,
map_x
,
map_y
,
K_Rinv
.
ptr
<
float
>
(),
R_Kinv
.
ptr
<
float
>
(),
scale
,
StreamAccessor
::
getStream
(
stream
));
}
}
...
@@ -589,10 +626,9 @@ namespace
...
@@ -589,10 +626,9 @@ namespace
};
};
}
}
void
cv
::
gpu
::
rotate
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
Size
dsize
,
double
angle
,
double
xShift
,
double
yShift
,
int
interpolation
,
Stream
&
stream
)
void
cv
::
gpu
::
rotate
(
InputArray
_src
,
OutputArray
_
dst
,
Size
dsize
,
double
angle
,
double
xShift
,
double
yShift
,
int
interpolation
,
Stream
&
stream
)
{
{
typedef
void
(
*
func_t
)(
const
GpuMat
&
src
,
GpuMat
&
dst
,
Size
dsize
,
double
angle
,
double
xShift
,
double
yShift
,
int
interpolation
,
cudaStream_t
stream
);
typedef
void
(
*
func_t
)(
const
GpuMat
&
src
,
GpuMat
&
dst
,
Size
dsize
,
double
angle
,
double
xShift
,
double
yShift
,
int
interpolation
,
cudaStream_t
stream
);
static
const
func_t
funcs
[
6
][
4
]
=
static
const
func_t
funcs
[
6
][
4
]
=
{
{
{
NppRotate
<
CV_8U
,
nppiRotate_8u_C1R
>::
call
,
0
,
NppRotate
<
CV_8U
,
nppiRotate_8u_C3R
>::
call
,
NppRotate
<
CV_8U
,
nppiRotate_8u_C4R
>::
call
},
{
NppRotate
<
CV_8U
,
nppiRotate_8u_C1R
>::
call
,
0
,
NppRotate
<
CV_8U
,
nppiRotate_8u_C3R
>::
call
,
NppRotate
<
CV_8U
,
nppiRotate_8u_C4R
>::
call
},
...
@@ -603,12 +639,16 @@ void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, d
...
@@ -603,12 +639,16 @@ void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, d
{
NppRotate
<
CV_32F
,
nppiRotate_32f_C1R
>::
call
,
0
,
NppRotate
<
CV_32F
,
nppiRotate_32f_C3R
>::
call
,
NppRotate
<
CV_32F
,
nppiRotate_32f_C4R
>::
call
}
{
NppRotate
<
CV_32F
,
nppiRotate_32f_C1R
>::
call
,
0
,
NppRotate
<
CV_32F
,
nppiRotate_32f_C3R
>::
call
,
NppRotate
<
CV_32F
,
nppiRotate_32f_C4R
>::
call
}
};
};
CV_Assert
(
src
.
depth
()
==
CV_8U
||
src
.
depth
()
==
CV_16U
||
src
.
depth
()
==
CV_32F
);
GpuMat
src
=
_src
.
getGpuMat
();
CV_Assert
(
src
.
channels
()
==
1
||
src
.
channels
()
==
3
||
src
.
channels
()
==
4
);
CV_Assert
(
interpolation
==
INTER_NEAREST
||
interpolation
==
INTER_LINEAR
||
interpolation
==
INTER_CUBIC
);
CV_Assert
(
src
.
depth
()
==
CV_8U
||
src
.
depth
()
==
CV_16U
||
src
.
depth
()
==
CV_32F
);
CV_Assert
(
src
.
channels
()
==
1
||
src
.
channels
()
==
3
||
src
.
channels
()
==
4
);
CV_Assert
(
interpolation
==
INTER_NEAREST
||
interpolation
==
INTER_LINEAR
||
interpolation
==
INTER_CUBIC
);
_dst
.
create
(
dsize
,
src
.
type
());
GpuMat
dst
=
_dst
.
getGpuMat
();
dst
.
create
(
dsize
,
src
.
type
());
dst
.
setTo
(
Scalar
::
all
(
0
),
stream
);
dst
.
setTo
(
Scalar
::
all
(
0
));
funcs
[
src
.
depth
()][
src
.
channels
()
-
1
](
src
,
dst
,
dsize
,
angle
,
xShift
,
yShift
,
interpolation
,
StreamAccessor
::
getStream
(
stream
));
funcs
[
src
.
depth
()][
src
.
channels
()
-
1
](
src
,
dst
,
dsize
,
angle
,
xShift
,
yShift
,
interpolation
,
StreamAccessor
::
getStream
(
stream
));
}
}
...
...
samples/gpu/cascadeclassifier.cpp
View file @
52a93782
...
@@ -24,12 +24,11 @@ static void help()
...
@@ -24,12 +24,11 @@ static void help()
}
}
template
<
class
T
>
static
void
convertAndResize
(
const
Mat
&
src
,
Mat
&
gray
,
Mat
&
resized
,
double
scale
)
void
convertAndResize
(
const
T
&
src
,
T
&
gray
,
T
&
resized
,
double
scale
)
{
{
if
(
src
.
channels
()
==
3
)
if
(
src
.
channels
()
==
3
)
{
{
cvtColor
(
src
,
gray
,
COLOR_BGR2GRAY
);
cv
::
cv
tColor
(
src
,
gray
,
COLOR_BGR2GRAY
);
}
}
else
else
{
{
...
@@ -40,7 +39,30 @@ void convertAndResize(const T& src, T& gray, T& resized, double scale)
...
@@ -40,7 +39,30 @@ void convertAndResize(const T& src, T& gray, T& resized, double scale)
if
(
scale
!=
1
)
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
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