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
a2f8817d
Commit
a2f8817d
authored
Sep 20, 2010
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor refactoring of GPU module and GPU tests
added gpu compare version for CMP_NE operation
parent
73b58ad0
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
423 additions
and
180 deletions
+423
-180
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+1
-1
arithm.cpp
modules/gpu/src/arithm.cpp
+135
-108
matrix_operations.cu
modules/gpu/src/cuda/matrix_operations.cu
+41
-1
filtering_npp.cpp
modules/gpu/src/filtering_npp.cpp
+3
-3
meanshift.cpp
tests/gpu/src/meanshift.cpp
+16
-2
morf_filters.cpp
tests/gpu/src/morf_filters.cpp
+2
-2
npp_image_arithm.cpp
tests/gpu/src/npp_image_arithm.cpp
+134
-53
operator_async_call.cpp
tests/gpu/src/operator_async_call.cpp
+10
-1
operator_convert_to.cpp
tests/gpu/src/operator_convert_to.cpp
+4
-2
operator_copy_to.cpp
tests/gpu/src/operator_copy_to.cpp
+9
-0
operator_set_to.cpp
tests/gpu/src/operator_set_to.cpp
+9
-0
stereo_bm.cpp
tests/gpu/src/stereo_bm.cpp
+15
-3
stereo_bm_async.cpp
tests/gpu/src/stereo_bm_async.cpp
+14
-1
stereo_bp.cpp
tests/gpu/src/stereo_bp.cpp
+15
-2
stereo_csbp.cpp
tests/gpu/src/stereo_csbp.cpp
+15
-1
No files found.
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
a2f8817d
...
@@ -364,7 +364,7 @@ namespace cv
...
@@ -364,7 +364,7 @@ namespace cv
//! applies fixed threshold to the image.
//! applies fixed threshold to the image.
//! Now supports only THRESH_TRUNC threshold type and one channels float source.
//! Now supports only THRESH_TRUNC threshold type and one channels float source.
CV_EXPORTS
double
threshold
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
double
thresh
,
double
maxVal
,
int
thresholdType
);
CV_EXPORTS
double
threshold
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
double
thresh
);
//! compares elements of two arrays (c = a <cmpop> b)
//! compares elements of two arrays (c = a <cmpop> b)
//! Now doesn't support CMP_NE.
//! Now doesn't support CMP_NE.
...
...
modules/gpu/src/arithm.cpp
View file @
a2f8817d
...
@@ -57,7 +57,7 @@ void cv::gpu::transpose(const GpuMat&, GpuMat&) { throw_nogpu(); }
...
@@ -57,7 +57,7 @@ void cv::gpu::transpose(const GpuMat&, GpuMat&) { throw_nogpu(); }
void
cv
::
gpu
::
absdiff
(
const
GpuMat
&
,
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
absdiff
(
const
GpuMat
&
,
const
GpuMat
&
,
GpuMat
&
)
{
throw_nogpu
();
}
double
cv
::
gpu
::
threshold
(
const
GpuMat
&
,
GpuMat
&
,
double
,
double
,
int
)
{
throw_nogpu
();
return
0.0
;
}
double
cv
::
gpu
::
threshold
(
const
GpuMat
&
,
GpuMat
&
,
double
)
{
throw_nogpu
();
return
0.0
;
}
void
cv
::
gpu
::
compare
(
const
GpuMat
&
,
const
GpuMat
&
,
GpuMat
&
,
int
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
compare
(
const
GpuMat
&
,
const
GpuMat
&
,
GpuMat
&
,
int
)
{
throw_nogpu
();
}
...
@@ -86,26 +86,13 @@ void cv::gpu::rotate(const GpuMat&, GpuMat&, Size, double, double, double, int)
...
@@ -86,26 +86,13 @@ void cv::gpu::rotate(const GpuMat&, GpuMat&, Size, double, double, double, int)
namespace
namespace
{
{
typedef
NppStatus
(
*
npp_warp_8u_t
)(
const
Npp8u
*
pSrc
,
NppiSize
srcSize
,
int
srcStep
,
NppiRect
srcRoi
,
Npp8u
*
pDst
,
typedef
NppStatus
(
*
npp_arithm_8u_t
)(
const
Npp8u
*
pSrc1
,
int
nSrc1Step
,
const
Npp8u
*
pSrc2
,
int
nSrc2Step
,
Npp8u
*
pDst
,
int
nDstStep
,
int
dstStep
,
NppiRect
dstRoi
,
const
double
coeffs
[][
3
],
int
interpolation
);
typedef
NppStatus
(
*
npp_warp_16u_t
)(
const
Npp16u
*
pSrc
,
NppiSize
srcSize
,
int
srcStep
,
NppiRect
srcRoi
,
Npp16u
*
pDst
,
int
dstStep
,
NppiRect
dstRoi
,
const
double
coeffs
[][
3
],
int
interpolation
);
typedef
NppStatus
(
*
npp_warp_32s_t
)(
const
Npp32s
*
pSrc
,
NppiSize
srcSize
,
int
srcStep
,
NppiRect
srcRoi
,
Npp32s
*
pDst
,
int
dstStep
,
NppiRect
dstRoi
,
const
double
coeffs
[][
3
],
int
interpolation
);
typedef
NppStatus
(
*
npp_warp_32f_t
)(
const
Npp32f
*
pSrc
,
NppiSize
srcSize
,
int
srcStep
,
NppiRect
srcRoi
,
Npp32f
*
pDst
,
int
dstStep
,
NppiRect
dstRoi
,
const
double
coeffs
[][
3
],
int
interpolation
);
typedef
NppStatus
(
*
npp_binary_func_8u_scale_t
)(
const
Npp8u
*
pSrc1
,
int
nSrc1Step
,
const
Npp8u
*
pSrc2
,
int
nSrc2Step
,
Npp8u
*
pDst
,
int
nDstStep
,
NppiSize
oSizeROI
,
int
nScaleFactor
);
NppiSize
oSizeROI
,
int
nScaleFactor
);
typedef
NppStatus
(
*
npp_
binary_func
_32f_t
)(
const
Npp32f
*
pSrc1
,
int
nSrc1Step
,
const
Npp32f
*
pSrc2
,
int
nSrc2Step
,
Npp32f
*
pDst
,
typedef
NppStatus
(
*
npp_
arithm
_32f_t
)(
const
Npp32f
*
pSrc1
,
int
nSrc1Step
,
const
Npp32f
*
pSrc2
,
int
nSrc2Step
,
Npp32f
*
pDst
,
int
nDstStep
,
NppiSize
oSizeROI
);
int
nDstStep
,
NppiSize
oSizeROI
);
void
nppFuncCaller
(
const
GpuMat
&
src1
,
const
GpuMat
&
src2
,
GpuMat
&
dst
,
void
nppFuncCaller
(
const
GpuMat
&
src1
,
const
GpuMat
&
src2
,
GpuMat
&
dst
,
npp_
binary_func_8u_scale_t
npp_func_8uc1
,
npp_binary_func_8u_scale_t
npp_func_8uc4
,
npp_binary_func
_32f_t
npp_func_32fc1
)
npp_
arithm_8u_t
npp_func_8uc1
,
npp_arithm_8u_t
npp_func_8uc4
,
npp_arithm
_32f_t
npp_func_32fc1
)
{
{
CV_DbgAssert
(
src1
.
size
()
==
src2
.
size
()
&&
src1
.
type
()
==
src2
.
type
());
CV_DbgAssert
(
src1
.
size
()
==
src2
.
size
()
&&
src1
.
type
()
==
src2
.
type
());
...
@@ -117,26 +104,25 @@ namespace
...
@@ -117,26 +104,25 @@ namespace
sz
.
width
=
src1
.
cols
;
sz
.
width
=
src1
.
cols
;
sz
.
height
=
src1
.
rows
;
sz
.
height
=
src1
.
rows
;
if
(
src1
.
depth
()
==
CV_8U
)
switch
(
src1
.
type
())
{
if
(
src1
.
channels
()
==
1
)
{
nppSafeCall
(
npp_func_8uc1
((
const
Npp8u
*
)
src1
.
ptr
<
char
>
(),
src1
.
step
,
(
const
Npp8u
*
)
src2
.
ptr
<
char
>
(),
src2
.
step
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
sz
,
0
)
);
}
else
{
{
nppSafeCall
(
npp_func_8uc4
((
const
Npp8u
*
)
src1
.
ptr
<
char
>
(),
src1
.
step
,
case
CV_8UC1
:
(
const
Npp8u
*
)
src2
.
ptr
<
char
>
(),
src2
.
step
,
nppSafeCall
(
npp_func_8uc1
(
src1
.
ptr
<
Npp8u
>
(),
src1
.
step
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
sz
,
0
)
);
src2
.
ptr
<
Npp8u
>
(),
src2
.
step
,
}
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
sz
,
0
)
);
}
break
;
else
//if (src1.depth() == CV_32F)
case
CV_8UC4
:
{
nppSafeCall
(
npp_func_8uc4
(
src1
.
ptr
<
Npp8u
>
(),
src1
.
step
,
nppSafeCall
(
npp_func_32fc1
((
const
Npp32f
*
)
src1
.
ptr
<
float
>
(),
src1
.
step
,
src2
.
ptr
<
Npp8u
>
(),
src2
.
step
,
(
const
Npp32f
*
)
src2
.
ptr
<
float
>
(),
src2
.
step
,
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
sz
,
0
)
);
(
Npp32f
*
)
dst
.
ptr
<
float
>
(),
dst
.
step
,
sz
)
);
break
;
case
CV_32FC1
:
nppSafeCall
(
npp_func_32fc1
(
src1
.
ptr
<
Npp32f
>
(),
src1
.
step
,
src2
.
ptr
<
Npp32f
>
(),
src2
.
step
,
dst
.
ptr
<
Npp32f
>
(),
dst
.
step
,
sz
)
);
break
;
default:
CV_Assert
(
!
"Unsupported source type"
);
}
}
}
}
}
}
...
@@ -171,14 +157,14 @@ void cv::gpu::transpose(const GpuMat& src, GpuMat& dst)
...
@@ -171,14 +157,14 @@ void cv::gpu::transpose(const GpuMat& src, GpuMat& dst)
sz
.
width
=
src
.
cols
;
sz
.
width
=
src
.
cols
;
sz
.
height
=
src
.
rows
;
sz
.
height
=
src
.
rows
;
nppSafeCall
(
nppiTranspose_8u_C1R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
src
.
step
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
sz
)
);
nppSafeCall
(
nppiTranspose_8u_C1R
(
src
.
ptr
<
Npp8u
>
(),
src
.
step
,
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
sz
)
);
}
}
void
cv
::
gpu
::
absdiff
(
const
GpuMat
&
src1
,
const
GpuMat
&
src2
,
GpuMat
&
dst
)
void
cv
::
gpu
::
absdiff
(
const
GpuMat
&
src1
,
const
GpuMat
&
src2
,
GpuMat
&
dst
)
{
{
CV_DbgAssert
(
src1
.
size
()
==
src2
.
size
()
&&
src1
.
type
()
==
src2
.
type
());
CV_DbgAssert
(
src1
.
size
()
==
src2
.
size
()
&&
src1
.
type
()
==
src2
.
type
());
CV_Assert
(
(
src1
.
depth
()
==
CV_8U
||
src1
.
depth
()
==
CV_32F
)
&&
src1
.
channels
()
==
1
);
CV_Assert
(
src1
.
type
()
==
CV_8UC1
||
src1
.
type
()
==
CV_32FC
1
);
dst
.
create
(
src1
.
size
(),
src1
.
type
()
);
dst
.
create
(
src1
.
size
(),
src1
.
type
()
);
...
@@ -186,23 +172,23 @@ void cv::gpu::absdiff(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
...
@@ -186,23 +172,23 @@ void cv::gpu::absdiff(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)
sz
.
width
=
src1
.
cols
;
sz
.
width
=
src1
.
cols
;
sz
.
height
=
src1
.
rows
;
sz
.
height
=
src1
.
rows
;
if
(
src1
.
depth
()
==
CV_8U
)
if
(
src1
.
type
()
==
CV_8UC1
)
{
{
nppSafeCall
(
nppiAbsDiff_8u_C1R
(
(
const
Npp8u
*
)
src1
.
ptr
<
char
>
(),
src1
.
step
,
nppSafeCall
(
nppiAbsDiff_8u_C1R
(
src1
.
ptr
<
Npp8u
>
(),
src1
.
step
,
(
const
Npp8u
*
)
src2
.
ptr
<
char
>
(),
src2
.
step
,
src2
.
ptr
<
Npp8u
>
(),
src2
.
step
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
sz
)
);
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
sz
)
);
}
}
else
//if (src1.depth() == CV_32F)
else
{
{
nppSafeCall
(
nppiAbsDiff_32f_C1R
(
(
const
Npp32f
*
)
src1
.
ptr
<
float
>
(),
src1
.
step
,
nppSafeCall
(
nppiAbsDiff_32f_C1R
(
src1
.
ptr
<
Npp32f
>
(),
src1
.
step
,
(
const
Npp32f
*
)
src2
.
ptr
<
float
>
(),
src2
.
step
,
src2
.
ptr
<
Npp32f
>
(),
src2
.
step
,
(
Npp32f
*
)
dst
.
ptr
<
float
>
(),
dst
.
step
,
sz
)
);
dst
.
ptr
<
Npp32f
>
(),
dst
.
step
,
sz
)
);
}
}
}
}
double
cv
::
gpu
::
threshold
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
double
thresh
,
double
/*maxVal*/
,
int
thresholdType
)
double
cv
::
gpu
::
threshold
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
double
thresh
)
{
{
CV_Assert
(
src
.
type
()
==
CV_32FC1
&&
thresholdType
==
THRESH_TRUNC
);
CV_Assert
(
src
.
type
()
==
CV_32FC1
)
dst
.
create
(
src
.
size
(),
src
.
type
()
);
dst
.
create
(
src
.
size
(),
src
.
type
()
);
...
@@ -210,17 +196,23 @@ double cv::gpu::threshold(const GpuMat& src, GpuMat& dst, double thresh, double
...
@@ -210,17 +196,23 @@ double cv::gpu::threshold(const GpuMat& src, GpuMat& dst, double thresh, double
sz
.
width
=
src
.
cols
;
sz
.
width
=
src
.
cols
;
sz
.
height
=
src
.
rows
;
sz
.
height
=
src
.
rows
;
nppSafeCall
(
nppiThreshold_32f_C1R
(
(
const
Npp32f
*
)
src
.
ptr
<
float
>
(),
src
.
step
,
nppSafeCall
(
nppiThreshold_32f_C1R
(
src
.
ptr
<
Npp32f
>
(),
src
.
step
,
(
Npp32f
*
)
dst
.
ptr
<
float
>
(),
dst
.
step
,
sz
,
(
Npp32f
)
thresh
,
NPP_CMP_GREATER
)
);
dst
.
ptr
<
Npp32f
>
(),
dst
.
step
,
sz
,
static_cast
<
Npp32f
>
(
thresh
)
,
NPP_CMP_GREATER
)
);
return
thresh
;
return
thresh
;
}
}
namespace
cv
{
namespace
gpu
{
namespace
matrix_operations
{
void
compare_ne_8u
(
const
DevMem2D
&
src1
,
const
DevMem2D
&
src2
,
const
DevMem2D
&
dst
);
void
compare_ne_32f
(
const
DevMem2D
&
src1
,
const
DevMem2D
&
src2
,
const
DevMem2D
&
dst
);
}}}
void
cv
::
gpu
::
compare
(
const
GpuMat
&
src1
,
const
GpuMat
&
src2
,
GpuMat
&
dst
,
int
cmpop
)
void
cv
::
gpu
::
compare
(
const
GpuMat
&
src1
,
const
GpuMat
&
src2
,
GpuMat
&
dst
,
int
cmpop
)
{
{
CV_DbgAssert
(
src1
.
size
()
==
src2
.
size
()
&&
src1
.
type
()
==
src2
.
type
());
CV_DbgAssert
(
src1
.
size
()
==
src2
.
size
()
&&
src1
.
type
()
==
src2
.
type
());
CV_Assert
(
(
src1
.
type
()
==
CV_8UC4
||
src1
.
type
()
==
CV_32FC1
)
&&
cmpop
!=
CMP_NE
);
CV_Assert
(
src1
.
type
()
==
CV_8UC4
||
src1
.
type
()
==
CV_32FC1
);
dst
.
create
(
src1
.
size
(),
CV_8UC1
);
dst
.
create
(
src1
.
size
(),
CV_8UC1
);
...
@@ -230,17 +222,31 @@ void cv::gpu::compare(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, int c
...
@@ -230,17 +222,31 @@ void cv::gpu::compare(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, int c
sz
.
width
=
src1
.
cols
;
sz
.
width
=
src1
.
cols
;
sz
.
height
=
src1
.
rows
;
sz
.
height
=
src1
.
rows
;
if
(
src1
.
depth
()
==
CV_8U
)
if
(
src1
.
type
()
==
CV_8UC4
)
{
if
(
cmpop
!=
CMP_NE
)
{
{
nppSafeCall
(
nppiCompare_8u_C4R
((
const
Npp8u
*
)
src1
.
ptr
<
char
>
(),
src1
.
step
,
nppSafeCall
(
nppiCompare_8u_C4R
(
src1
.
ptr
<
Npp8u
>
(),
src1
.
step
,
(
const
Npp8u
*
)
src2
.
ptr
<
char
>
(),
src2
.
step
,
src2
.
ptr
<
Npp8u
>
(),
src2
.
step
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
sz
,
nppCmpOp
[
cmpop
])
);
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
sz
,
nppCmpOp
[
cmpop
])
);
}
}
else
//if (src1.depth() == CV_32F)
else
{
{
nppSafeCall
(
nppiCompare_32f_C1R
((
const
Npp32f
*
)
src1
.
ptr
<
float
>
(),
src1
.
step
,
matrix_operations
::
compare_ne_8u
(
src1
,
src2
,
dst
);
(
const
Npp32f
*
)
src2
.
ptr
<
float
>
(),
src2
.
step
,
}
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
sz
,
nppCmpOp
[
cmpop
])
);
}
else
{
if
(
cmpop
!=
CMP_NE
)
{
nppSafeCall
(
nppiCompare_32f_C1R
(
src1
.
ptr
<
Npp32f
>
(),
src1
.
step
,
src2
.
ptr
<
Npp32f
>
(),
src2
.
step
,
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
sz
,
nppCmpOp
[
cmpop
])
);
}
else
{
matrix_operations
::
compare_ne_32f
(
src1
,
src2
,
dst
);
}
}
}
}
}
...
@@ -252,7 +258,7 @@ void cv::gpu::meanStdDev(const GpuMat& src, Scalar& mean, Scalar& stddev)
...
@@ -252,7 +258,7 @@ void cv::gpu::meanStdDev(const GpuMat& src, Scalar& mean, Scalar& stddev)
sz
.
width
=
src
.
cols
;
sz
.
width
=
src
.
cols
;
sz
.
height
=
src
.
rows
;
sz
.
height
=
src
.
rows
;
nppSafeCall
(
nppiMean_StdDev_8u_C1R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
src
.
step
,
sz
,
mean
.
val
,
stddev
.
val
)
);
nppSafeCall
(
nppiMean_StdDev_8u_C1R
(
src
.
ptr
<
Npp8u
>
(),
src
.
step
,
sz
,
mean
.
val
,
stddev
.
val
)
);
}
}
double
cv
::
gpu
::
norm
(
const
GpuMat
&
src1
,
int
normType
)
double
cv
::
gpu
::
norm
(
const
GpuMat
&
src1
,
int
normType
)
...
@@ -264,7 +270,8 @@ double cv::gpu::norm(const GpuMat& src1, const GpuMat& src2, int normType)
...
@@ -264,7 +270,8 @@ double cv::gpu::norm(const GpuMat& src1, const GpuMat& src2, int normType)
{
{
CV_DbgAssert
(
src1
.
size
()
==
src2
.
size
()
&&
src1
.
type
()
==
src2
.
type
());
CV_DbgAssert
(
src1
.
size
()
==
src2
.
size
()
&&
src1
.
type
()
==
src2
.
type
());
CV_Assert
((
src1
.
type
()
==
CV_8UC1
)
&&
(
normType
==
NORM_INF
||
normType
==
NORM_L1
||
normType
==
NORM_L2
));
CV_Assert
(
src1
.
type
()
==
CV_8UC1
);
CV_Assert
(
normType
==
NORM_INF
||
normType
==
NORM_L1
||
normType
==
NORM_L2
);
typedef
NppStatus
(
*
npp_norm_diff_func_t
)(
const
Npp8u
*
pSrc1
,
int
nSrcStep1
,
const
Npp8u
*
pSrc2
,
int
nSrcStep2
,
typedef
NppStatus
(
*
npp_norm_diff_func_t
)(
const
Npp8u
*
pSrc1
,
int
nSrcStep1
,
const
Npp8u
*
pSrc2
,
int
nSrcStep2
,
NppiSize
oSizeROI
,
Npp64f
*
pRetVal
);
NppiSize
oSizeROI
,
Npp64f
*
pRetVal
);
...
@@ -278,8 +285,8 @@ double cv::gpu::norm(const GpuMat& src1, const GpuMat& src2, int normType)
...
@@ -278,8 +285,8 @@ double cv::gpu::norm(const GpuMat& src1, const GpuMat& src2, int normType)
int
funcIdx
=
normType
>>
1
;
int
funcIdx
=
normType
>>
1
;
Scalar
retVal
;
Scalar
retVal
;
nppSafeCall
(
npp_norm_diff_func
[
funcIdx
](
(
const
Npp8u
*
)
src1
.
ptr
<
char
>
(),
src1
.
step
,
nppSafeCall
(
npp_norm_diff_func
[
funcIdx
](
src1
.
ptr
<
Npp8u
>
(),
src1
.
step
,
(
const
Npp8u
*
)
src2
.
ptr
<
char
>
(),
src2
.
step
,
src2
.
ptr
<
Npp8u
>
(),
src2
.
step
,
sz
,
retVal
.
val
)
);
sz
,
retVal
.
val
)
);
return
retVal
[
0
];
return
retVal
[
0
];
...
@@ -295,16 +302,16 @@ void cv::gpu::flip(const GpuMat& src, GpuMat& dst, int flipCode)
...
@@ -295,16 +302,16 @@ void cv::gpu::flip(const GpuMat& src, GpuMat& dst, int flipCode)
sz
.
width
=
src
.
cols
;
sz
.
width
=
src
.
cols
;
sz
.
height
=
src
.
rows
;
sz
.
height
=
src
.
rows
;
if
(
src
.
channels
()
==
1
)
if
(
src
.
type
()
==
CV_8UC
1
)
{
{
nppSafeCall
(
nppiMirror_8u_C1R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
src
.
step
,
nppSafeCall
(
nppiMirror_8u_C1R
(
src
.
ptr
<
Npp8u
>
(),
src
.
step
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
sz
,
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
sz
,
(
flipCode
==
0
?
NPP_HORIZONTAL_AXIS
:
(
flipCode
>
0
?
NPP_VERTICAL_AXIS
:
NPP_BOTH_AXIS
)))
);
(
flipCode
==
0
?
NPP_HORIZONTAL_AXIS
:
(
flipCode
>
0
?
NPP_VERTICAL_AXIS
:
NPP_BOTH_AXIS
)))
);
}
}
else
else
{
{
nppSafeCall
(
nppiMirror_8u_C4R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
src
.
step
,
nppSafeCall
(
nppiMirror_8u_C4R
(
src
.
ptr
<
Npp8u
>
(),
src
.
step
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
sz
,
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
sz
,
(
flipCode
==
0
?
NPP_HORIZONTAL_AXIS
:
(
flipCode
>
0
?
NPP_VERTICAL_AXIS
:
NPP_BOTH_AXIS
)))
);
(
flipCode
==
0
?
NPP_HORIZONTAL_AXIS
:
(
flipCode
>
0
?
NPP_VERTICAL_AXIS
:
NPP_BOTH_AXIS
)))
);
}
}
}
}
...
@@ -313,11 +320,12 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub
...
@@ -313,11 +320,12 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub
{
{
static
const
int
npp_inter
[]
=
{
NPPI_INTER_NN
,
NPPI_INTER_LINEAR
,
NPPI_INTER_CUBIC
,
0
,
NPPI_INTER_LANCZOS
};
static
const
int
npp_inter
[]
=
{
NPPI_INTER_NN
,
NPPI_INTER_LINEAR
,
NPPI_INTER_CUBIC
,
0
,
NPPI_INTER_LANCZOS
};
CV_Assert
(
(
src
.
type
()
==
CV_8UC1
||
src
.
type
()
==
CV_8UC4
)
&&
CV_Assert
(
src
.
type
()
==
CV_8UC1
||
src
.
type
()
==
CV_8UC4
);
(
interpolation
==
INTER_NEAREST
||
interpolation
==
INTER_LINEAR
||
interpolation
==
INTER_CUBIC
||
interpolation
==
INTER_LANCZOS4
)
);
CV_Assert
(
interpolation
==
INTER_NEAREST
||
interpolation
==
INTER_LINEAR
||
interpolation
==
INTER_CUBIC
||
interpolation
==
INTER_LANCZOS4
);
CV_Assert
(
src
.
size
().
area
()
>
0
);
CV_Assert
(
src
.
size
().
area
()
>
0
);
CV_Assert
(
!
(
dsize
==
Size
())
||
(
fx
>
0
&&
fy
>
0
)
);
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
));
...
@@ -327,6 +335,7 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub
...
@@ -327,6 +335,7 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub
fx
=
(
double
)
dsize
.
width
/
src
.
cols
;
fx
=
(
double
)
dsize
.
width
/
src
.
cols
;
fy
=
(
double
)
dsize
.
height
/
src
.
rows
;
fy
=
(
double
)
dsize
.
height
/
src
.
rows
;
}
}
dst
.
create
(
dsize
,
src
.
type
());
dst
.
create
(
dsize
,
src
.
type
());
NppiSize
srcsz
;
NppiSize
srcsz
;
...
@@ -340,15 +349,15 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub
...
@@ -340,15 +349,15 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub
dstsz
.
width
=
dst
.
cols
;
dstsz
.
width
=
dst
.
cols
;
dstsz
.
height
=
dst
.
rows
;
dstsz
.
height
=
dst
.
rows
;
if
(
src
.
channels
()
==
1
)
if
(
src
.
type
()
==
CV_8UC
1
)
{
{
nppSafeCall
(
nppiResize_8u_C1R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
srcsz
,
src
.
step
,
srcrect
,
nppSafeCall
(
nppiResize_8u_C1R
(
src
.
ptr
<
Npp8u
>
(),
srcsz
,
src
.
step
,
srcrect
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
dstsz
,
fx
,
fy
,
npp_inter
[
interpolation
])
);
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
dstsz
,
fx
,
fy
,
npp_inter
[
interpolation
])
);
}
}
else
else
{
{
nppSafeCall
(
nppiResize_8u_C4R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
srcsz
,
src
.
step
,
srcrect
,
nppSafeCall
(
nppiResize_8u_C4R
(
src
.
ptr
<
Npp8u
>
(),
srcsz
,
src
.
step
,
srcrect
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
dstsz
,
fx
,
fy
,
npp_inter
[
interpolation
])
);
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
dstsz
,
fx
,
fy
,
npp_inter
[
interpolation
])
);
}
}
}
}
...
@@ -362,13 +371,13 @@ Scalar cv::gpu::sum(const GpuMat& src)
...
@@ -362,13 +371,13 @@ Scalar cv::gpu::sum(const GpuMat& src)
sz
.
width
=
src
.
cols
;
sz
.
width
=
src
.
cols
;
sz
.
height
=
src
.
rows
;
sz
.
height
=
src
.
rows
;
if
(
src
.
channels
()
==
1
)
if
(
src
.
type
()
==
CV_8UC
1
)
{
{
nppSafeCall
(
nppiSum_8u_C1R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
src
.
step
,
sz
,
res
.
val
)
);
nppSafeCall
(
nppiSum_8u_C1R
(
src
.
ptr
<
Npp8u
>
(),
src
.
step
,
sz
,
res
.
val
)
);
}
}
else
else
{
{
nppSafeCall
(
nppiSum_8u_C4R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
src
.
step
,
sz
,
res
.
val
)
);
nppSafeCall
(
nppiSum_8u_C4R
(
src
.
ptr
<
Npp8u
>
(),
src
.
step
,
sz
,
res
.
val
)
);
}
}
return
res
;
return
res
;
...
@@ -384,7 +393,7 @@ void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal)
...
@@ -384,7 +393,7 @@ void cv::gpu::minMax(const GpuMat& src, double* minVal, double* maxVal)
Npp8u
min_res
,
max_res
;
Npp8u
min_res
,
max_res
;
nppSafeCall
(
nppiMinMax_8u_C1R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
src
.
step
,
sz
,
&
min_res
,
&
max_res
)
);
nppSafeCall
(
nppiMinMax_8u_C1R
(
src
.
ptr
<
Npp8u
>
(),
src
.
step
,
sz
,
&
min_res
,
&
max_res
)
);
if
(
minVal
)
if
(
minVal
)
*
minVal
=
min_res
;
*
minVal
=
min_res
;
...
@@ -406,31 +415,49 @@ void cv::gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom
...
@@ -406,31 +415,49 @@ void cv::gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom
dstsz
.
width
=
dst
.
cols
;
dstsz
.
width
=
dst
.
cols
;
dstsz
.
height
=
dst
.
rows
;
dstsz
.
height
=
dst
.
rows
;
if
(
src
.
depth
()
==
CV_8U
)
switch
(
src
.
type
()
)
{
{
if
(
src
.
channels
()
==
1
)
case
CV_8UC1
:
{
{
Npp8u
nVal
=
(
Npp8u
)
value
[
0
];
Npp8u
nVal
=
static_cast
<
Npp8u
>
(
value
[
0
]);
nppSafeCall
(
nppiCopyConstBorder_8u_C1R
((
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
src
.
step
,
srcsz
,
nppSafeCall
(
nppiCopyConstBorder_8u_C1R
(
src
.
ptr
<
Npp8u
>
(),
src
.
step
,
srcsz
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
dstsz
,
top
,
left
,
nVal
)
);
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
dstsz
,
top
,
left
,
nVal
)
);
break
;
}
}
else
case
CV_8UC4
:
{
{
Npp8u
nVal
[]
=
{
(
Npp8u
)
value
[
0
],
(
Npp8u
)
value
[
1
],
(
Npp8u
)
value
[
2
],
(
Npp8u
)
value
[
3
]
};
Npp8u
nVal
[]
=
{
static_cast
<
Npp8u
>
(
value
[
0
]),
static_cast
<
Npp8u
>
(
value
[
1
]),
static_cast
<
Npp8u
>
(
value
[
2
]),
static_cast
<
Npp8u
>
(
value
[
3
])
};
nppSafeCall
(
nppiCopyConstBorder_8u_C4R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
src
.
step
,
srcsz
,
nppSafeCall
(
nppiCopyConstBorder_8u_C4R
(
src
.
ptr
<
Npp8u
>
(),
src
.
step
,
srcsz
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
dstsz
,
top
,
left
,
nVal
)
);
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
dstsz
,
top
,
left
,
nVal
)
);
}
break
;
}
}
else
//if (src.depth() == CV_32S)
case
CV_32SC1
:
{
{
Npp32s
nVal
=
(
Npp32s
)
value
[
0
];
Npp32s
nVal
=
static_cast
<
Npp32s
>
(
value
[
0
]);
nppSafeCall
(
nppiCopyConstBorder_32s_C1R
((
const
Npp32s
*
)
src
.
ptr
<
char
>
(),
src
.
step
,
srcsz
,
nppSafeCall
(
nppiCopyConstBorder_32s_C1R
(
src
.
ptr
<
Npp32s
>
(),
src
.
step
,
srcsz
,
(
Npp32s
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
dstsz
,
top
,
left
,
nVal
)
);
dst
.
ptr
<
Npp32s
>
(),
dst
.
step
,
dstsz
,
top
,
left
,
nVal
)
);
break
;
}
default
:
CV_Assert
(
!
"Unsupported source type"
);
}
}
}
}
namespace
namespace
{
{
typedef
NppStatus
(
*
npp_warp_8u_t
)(
const
Npp8u
*
pSrc
,
NppiSize
srcSize
,
int
srcStep
,
NppiRect
srcRoi
,
Npp8u
*
pDst
,
int
dstStep
,
NppiRect
dstRoi
,
const
double
coeffs
[][
3
],
int
interpolation
);
typedef
NppStatus
(
*
npp_warp_16u_t
)(
const
Npp16u
*
pSrc
,
NppiSize
srcSize
,
int
srcStep
,
NppiRect
srcRoi
,
Npp16u
*
pDst
,
int
dstStep
,
NppiRect
dstRoi
,
const
double
coeffs
[][
3
],
int
interpolation
);
typedef
NppStatus
(
*
npp_warp_32s_t
)(
const
Npp32s
*
pSrc
,
NppiSize
srcSize
,
int
srcStep
,
NppiRect
srcRoi
,
Npp32s
*
pDst
,
int
dstStep
,
NppiRect
dstRoi
,
const
double
coeffs
[][
3
],
int
interpolation
);
typedef
NppStatus
(
*
npp_warp_32f_t
)(
const
Npp32f
*
pSrc
,
NppiSize
srcSize
,
int
srcStep
,
NppiRect
srcRoi
,
Npp32f
*
pDst
,
int
dstStep
,
NppiRect
dstRoi
,
const
double
coeffs
[][
3
],
int
interpolation
);
void
nppWarpCaller
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
double
coeffs
[][
3
],
const
Size
&
dsize
,
int
flags
,
void
nppWarpCaller
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
double
coeffs
[][
3
],
const
Size
&
dsize
,
int
flags
,
npp_warp_8u_t
npp_warp_8u
[][
2
],
npp_warp_16u_t
npp_warp_16u
[][
2
],
npp_warp_8u_t
npp_warp_8u
[][
2
],
npp_warp_16u_t
npp_warp_16u
[][
2
],
npp_warp_32s_t
npp_warp_32s
[][
2
],
npp_warp_32f_t
npp_warp_32f
[][
2
])
npp_warp_32s_t
npp_warp_32s
[][
2
],
npp_warp_32f_t
npp_warp_32f
[][
2
])
...
@@ -461,20 +488,20 @@ namespace
...
@@ -461,20 +488,20 @@ namespace
switch
(
src
.
depth
())
switch
(
src
.
depth
())
{
{
case
CV_8U
:
case
CV_8U
:
nppSafeCall
(
npp_warp_8u
[
src
.
channels
()][
warpInd
](
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
srcsz
,
src
.
step
,
srcroi
,
nppSafeCall
(
npp_warp_8u
[
src
.
channels
()][
warpInd
](
src
.
ptr
<
Npp8u
>
(),
srcsz
,
src
.
step
,
srcroi
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
dstroi
,
coeffs
,
npp_inter
[
interpolation
])
);
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
dstroi
,
coeffs
,
npp_inter
[
interpolation
])
);
break
;
break
;
case
CV_16U
:
case
CV_16U
:
nppSafeCall
(
npp_warp_16u
[
src
.
channels
()][
warpInd
](
(
const
Npp16u
*
)
src
.
ptr
<
char
>
(),
srcsz
,
src
.
step
,
srcroi
,
nppSafeCall
(
npp_warp_16u
[
src
.
channels
()][
warpInd
](
src
.
ptr
<
Npp16u
>
(),
srcsz
,
src
.
step
,
srcroi
,
(
Npp16u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
dstroi
,
coeffs
,
npp_inter
[
interpolation
])
);
dst
.
ptr
<
Npp16u
>
(),
dst
.
step
,
dstroi
,
coeffs
,
npp_inter
[
interpolation
])
);
break
;
break
;
case
CV_32S
C1
:
case
CV_32S
:
nppSafeCall
(
npp_warp_32s
[
src
.
channels
()][
warpInd
](
(
const
Npp32s
*
)
src
.
ptr
<
char
>
(),
srcsz
,
src
.
step
,
srcroi
,
nppSafeCall
(
npp_warp_32s
[
src
.
channels
()][
warpInd
](
src
.
ptr
<
Npp32s
>
(),
srcsz
,
src
.
step
,
srcroi
,
(
Npp32s
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
dstroi
,
coeffs
,
npp_inter
[
interpolation
])
);
dst
.
ptr
<
Npp32s
>
(),
dst
.
step
,
dstroi
,
coeffs
,
npp_inter
[
interpolation
])
);
break
;
break
;
case
CV_32F
C1
:
case
CV_32F
:
nppSafeCall
(
npp_warp_32f
[
src
.
channels
()][
warpInd
](
(
const
Npp32f
*
)
src
.
ptr
<
char
>
(),
srcsz
,
src
.
step
,
srcroi
,
nppSafeCall
(
npp_warp_32f
[
src
.
channels
()][
warpInd
](
src
.
ptr
<
Npp32f
>
(),
srcsz
,
src
.
step
,
srcroi
,
(
Npp32f
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
dstroi
,
coeffs
,
npp_inter
[
interpolation
])
);
dst
.
ptr
<
Npp32f
>
(),
dst
.
step
,
dstroi
,
coeffs
,
npp_inter
[
interpolation
])
);
break
;
break
;
default:
default:
CV_Assert
(
!
"Unsupported source type"
);
CV_Assert
(
!
"Unsupported source type"
);
...
@@ -591,15 +618,15 @@ void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, d
...
@@ -591,15 +618,15 @@ void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, d
dstroi
.
height
=
dst
.
rows
;
dstroi
.
height
=
dst
.
rows
;
dstroi
.
width
=
dst
.
cols
;
dstroi
.
width
=
dst
.
cols
;
if
(
src
.
channels
()
==
1
)
if
(
src
.
type
()
==
CV_8UC
1
)
{
{
nppSafeCall
(
nppiRotate_8u_C1R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
srcsz
,
src
.
step
,
srcroi
,
nppSafeCall
(
nppiRotate_8u_C1R
(
src
.
ptr
<
Npp8u
>
(),
srcsz
,
src
.
step
,
srcroi
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
dstroi
,
angle
,
xShift
,
yShift
,
npp_inter
[
interpolation
])
);
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
dstroi
,
angle
,
xShift
,
yShift
,
npp_inter
[
interpolation
])
);
}
}
else
else
{
{
nppSafeCall
(
nppiRotate_8u_C4R
(
(
const
Npp8u
*
)
src
.
ptr
<
char
>
(),
srcsz
,
src
.
step
,
srcroi
,
nppSafeCall
(
nppiRotate_8u_C4R
(
src
.
ptr
<
Npp8u
>
(),
srcsz
,
src
.
step
,
srcroi
,
(
Npp8u
*
)
dst
.
ptr
<
char
>
(),
dst
.
step
,
dstroi
,
angle
,
xShift
,
yShift
,
npp_inter
[
interpolation
])
);
dst
.
ptr
<
Npp8u
>
(),
dst
.
step
,
dstroi
,
angle
,
xShift
,
yShift
,
npp_inter
[
interpolation
])
);
}
}
}
}
...
...
modules/gpu/src/cuda/matrix_operations.cu
View file @
a2f8817d
...
@@ -255,6 +255,24 @@ namespace mat_operators
...
@@ -255,6 +255,24 @@ namespace mat_operators
}
}
}
}
///////////////////////////////////////////////////////////////////////////
/////////////////////////////// compare_ne ////////////////////////////////
///////////////////////////////////////////////////////////////////////////
template <typename T>
__global__ void kernel_compare_ne(uchar* src1, size_t src1_step, uchar* src2, size_t src2_step, uchar* dst, size_t dst_step, int cols, int rows)
{
const size_t x = threadIdx.x + blockIdx.x * blockDim.x;
const size_t y = threadIdx.y + blockIdx.y * blockDim.y;
if (x < cols && y < rows)
{
T src1_pix = ((T*)(src1 + y * src1_step))[x];
T src2_pix = ((T*)(src2 + y * src2_step))[x];
uchar res = (uchar)(src1_pix != src2_pix) * 255;
((dst + y * dst_step))[x] = res;
}
}
} // namespace mat_operators
} // namespace mat_operators
namespace cv
namespace cv
...
@@ -460,6 +478,28 @@ namespace cv
...
@@ -460,6 +478,28 @@ namespace cv
cv::gpu::error("Unsupported convert operation", __FILE__, __LINE__);
cv::gpu::error("Unsupported convert operation", __FILE__, __LINE__);
func(src, dst, src.cols * channels, src.rows, alpha, beta, stream);
func(src, dst, src.cols * channels, src.rows, alpha, beta, stream);
}
}
} // namespace impl
///////////////////////////////////////////////////////////////////////////
/////////////////////////////// compare_ne ////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void compare_ne_8u(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst)
{
dim3 block(32, 8);
dim3 grid(divUp(src1.cols, block.x), divUp(src1.rows, block.y));
mat_operators::kernel_compare_ne<uint><<<grid, block>>>(src1.ptr, src1.step, src2.ptr, src2.step, dst.ptr, dst.step, src1.cols, src1.rows);
cudaSafeCall( cudaThreadSynchronize() );
}
void compare_ne_32f(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst)
{
dim3 block(32, 8);
dim3 grid(divUp(src1.cols, block.x), divUp(src1.rows, block.y));
mat_operators::kernel_compare_ne<float><<<grid, block>>>(src1.ptr, src1.step, src2.ptr, src2.step, dst.ptr, dst.step, src1.cols, src1.rows);
cudaSafeCall( cudaThreadSynchronize() );
}
} // namespace matrix_operations
} // namespace gpu
} // namespace gpu
} // namespace cv
} // namespace cv
modules/gpu/src/filtering_npp.cpp
View file @
a2f8817d
...
@@ -48,9 +48,9 @@ using namespace cv::gpu;
...
@@ -48,9 +48,9 @@ using namespace cv::gpu;
#if !defined (HAVE_CUDA)
#if !defined (HAVE_CUDA)
void
cv
::
gpu
::
erode
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
const
Mat
&
kernel
,
Point
anchor
,
int
iterations
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
erode
(
const
GpuMat
&
,
GpuMat
&
,
const
Mat
&
,
Point
,
int
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
dilate
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
const
Mat
&
kernel
,
Point
anchor
,
int
iterations
)
{
throw_nogpu
();
}
void
cv
::
gpu
::
dilate
(
const
GpuMat
&
,
GpuMat
&
,
const
Mat
&
,
Point
,
int
)
{
throw_nogpu
();
}
void
morphologyEx
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
op
,
const
Mat
&
kernel
,
Point
anchor
,
int
iterations
)
{
throw_nogpu
();
}
void
morphologyEx
(
const
GpuMat
&
,
GpuMat
&
,
int
,
const
Mat
&
,
Point
,
int
)
{
throw_nogpu
();
}
#else
#else
...
...
tests/gpu/src/meanshift.cpp
View file @
a2f8817d
...
@@ -75,6 +75,8 @@ void CV_GpuMeanShiftTest::run(int)
...
@@ -75,6 +75,8 @@ void CV_GpuMeanShiftTest::run(int)
cv
::
Mat
rgba
;
cv
::
Mat
rgba
;
cvtColor
(
img
,
rgba
,
CV_BGR2BGRA
);
cvtColor
(
img
,
rgba
,
CV_BGR2BGRA
);
try
{
cv
::
gpu
::
GpuMat
res
;
cv
::
gpu
::
GpuMat
res
;
cv
::
gpu
::
meanShiftFiltering
(
cv
::
gpu
::
GpuMat
(
rgba
),
res
,
spatialRad
,
colorRad
);
cv
::
gpu
::
meanShiftFiltering
(
cv
::
gpu
::
GpuMat
(
rgba
),
res
,
spatialRad
,
colorRad
);
if
(
res
.
type
()
!=
CV_8UC4
)
if
(
res
.
type
()
!=
CV_8UC4
)
...
@@ -98,15 +100,27 @@ void CV_GpuMeanShiftTest::run(int)
...
@@ -98,15 +100,27 @@ void CV_GpuMeanShiftTest::run(int)
{
{
const
uchar
&
ch1
=
res_line
[
result
.
channels
()
*
i
+
k
];
const
uchar
&
ch1
=
res_line
[
result
.
channels
()
*
i
+
k
];
const
uchar
&
ch2
=
ref_line
[
img_template
.
channels
()
*
i
+
k
];
const
uchar
&
ch2
=
ref_line
[
img_template
.
channels
()
*
i
+
k
];
uchar
diff
=
abs
(
ch1
-
ch2
);
uchar
diff
=
static_cast
<
uchar
>
(
abs
(
ch1
-
ch2
)
);
if
(
maxDiff
<
diff
)
if
(
maxDiff
<
diff
)
maxDiff
=
diff
;
maxDiff
=
diff
;
}
}
}
}
}
}
if
(
maxDiff
>
0
)
if
(
maxDiff
>
0
)
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
MeanShift maxDiff = %d
\n
"
,
maxDiff
);
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
MeanShift maxDiff = %d
\n
"
,
maxDiff
);
ts
->
set_failed_test_info
((
maxDiff
==
0
)
?
CvTS
::
OK
:
CvTS
::
FAIL_GENERIC
);
ts
->
set_failed_test_info
(
CvTS
::
FAIL_GENERIC
);
return
;
}
}
catch
(
const
cv
::
Exception
&
e
)
{
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
return
;
}
ts
->
set_failed_test_info
(
CvTS
::
OK
);
}
}
CV_GpuMeanShiftTest
CV_GpuMeanShift_test
;
CV_GpuMeanShiftTest
CV_GpuMeanShift_test
;
tests/gpu/src/morf_filters.cpp
View file @
a2f8817d
...
@@ -81,7 +81,7 @@ protected:
...
@@ -81,7 +81,7 @@ protected:
if
(
res
<
std
::
numeric_limits
<
double
>::
epsilon
())
if
(
res
<
std
::
numeric_limits
<
double
>::
epsilon
())
return
CvTS
::
OK
;
return
CvTS
::
OK
;
ts
->
printf
(
CvTS
::
LOG
,
"
\n
Norm: %f
\n
"
,
res
);
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
Norm: %f
\n
"
,
res
);
return
CvTS
::
FAIL_GENERIC
;
return
CvTS
::
FAIL_GENERIC
;
}
}
};
};
...
@@ -117,6 +117,7 @@ void CV_GpuNppMorphogyTest::run( int )
...
@@ -117,6 +117,7 @@ void CV_GpuNppMorphogyTest::run( int )
{
{
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
throw
;
return
;
}
}
ts
->
set_failed_test_info
(
CvTS
::
OK
);
ts
->
set_failed_test_info
(
CvTS
::
OK
);
...
@@ -174,7 +175,6 @@ protected:
...
@@ -174,7 +175,6 @@ protected:
CV_GpuDilateTest
CV_GpuDilate_test
;
CV_GpuDilateTest
CV_GpuDilate_test
;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Dilate
// Dilate
class
CV_GpuMorphExTest
:
public
CV_GpuNppMorphogyTest
class
CV_GpuMorphExTest
:
public
CV_GpuNppMorphogyTest
...
...
tests/gpu/src/npp_image_arithm.cpp
View file @
a2f8817d
...
@@ -132,7 +132,7 @@ int CV_GpuNppImageArithmTest::CheckNorm(const Mat& m1, const Mat& m2)
...
@@ -132,7 +132,7 @@ int CV_GpuNppImageArithmTest::CheckNorm(const Mat& m1, const Mat& m2)
}
}
else
else
{
{
ts
->
printf
(
CvTS
::
LOG
,
"
\n
Norm: %f
\n
"
,
ret
);
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
Norm: %f
\n
"
,
ret
);
return
CvTS
::
FAIL_GENERIC
;
return
CvTS
::
FAIL_GENERIC
;
}
}
}
}
...
@@ -154,7 +154,7 @@ int CV_GpuNppImageArithmTest::CheckNorm(double d1, double d2)
...
@@ -154,7 +154,7 @@ int CV_GpuNppImageArithmTest::CheckNorm(double d1, double d2)
}
}
else
else
{
{
ts
->
printf
(
CvTS
::
LOG
,
"
\n
Norm: %f
\n
"
,
ret
);
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
Norm: %f
\n
"
,
ret
);
return
CvTS
::
FAIL_GENERIC
;
return
CvTS
::
FAIL_GENERIC
;
}
}
}
}
...
@@ -165,8 +165,14 @@ void CV_GpuNppImageArithmTest::run( int )
...
@@ -165,8 +165,14 @@ void CV_GpuNppImageArithmTest::run( int )
//cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-L.png");
//cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-L.png");
//cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-R.png");
//cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-R.png");
cv
::
Mat
img_l
=
cv
::
imread
(
std
::
string
(
ts
->
get_data_path
())
+
"stereobp/aloe-L.png"
);
//cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");
cv
::
Mat
img_r
=
cv
::
imread
(
std
::
string
(
ts
->
get_data_path
())
+
"stereobp/aloe-R.png"
);
//cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-R.png");
cv
::
RNG
rng
(
*
ts
->
get_rng
());
cv
::
Size
sz
(
200
,
200
);
cv
::
Mat
img_l
(
sz
,
CV_8UC3
),
img_r
(
sz
,
CV_8UC3
);
rng
.
fill
(
img_l
,
cv
::
RNG
::
UNIFORM
,
cv
::
Scalar
::
all
(
10
),
cv
::
Scalar
::
all
(
100
));
rng
.
fill
(
img_r
,
cv
::
RNG
::
UNIFORM
,
cv
::
Scalar
::
all
(
10
),
cv
::
Scalar
::
all
(
100
));
if
(
img_l
.
empty
()
||
img_r
.
empty
())
if
(
img_l
.
empty
()
||
img_r
.
empty
())
{
{
...
@@ -174,6 +180,8 @@ void CV_GpuNppImageArithmTest::run( int )
...
@@ -174,6 +180,8 @@ void CV_GpuNppImageArithmTest::run( int )
return
;
return
;
}
}
try
{
//run tests
//run tests
int
testResult
=
test8UC1
(
img_l
,
img_r
);
int
testResult
=
test8UC1
(
img_l
,
img_r
);
if
(
testResult
!=
CvTS
::
OK
)
if
(
testResult
!=
CvTS
::
OK
)
...
@@ -202,6 +210,13 @@ void CV_GpuNppImageArithmTest::run( int )
...
@@ -202,6 +210,13 @@ void CV_GpuNppImageArithmTest::run( int )
ts
->
set_failed_test_info
(
testResult
);
ts
->
set_failed_test_info
(
testResult
);
return
;
return
;
}
}
}
catch
(
const
cv
::
Exception
&
e
)
{
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
return
;
}
ts
->
set_failed_test_info
(
CvTS
::
OK
);
ts
->
set_failed_test_info
(
CvTS
::
OK
);
}
}
...
@@ -423,15 +438,15 @@ int CV_GpuNppImageThresholdTest::test( const Mat& cpu1, const Mat& )
...
@@ -423,15 +438,15 @@ int CV_GpuNppImageThresholdTest::test( const Mat& cpu1, const Mat& )
if
(
cpu1
.
type
()
!=
CV_32FC1
)
if
(
cpu1
.
type
()
!=
CV_32FC1
)
return
CvTS
::
OK
;
return
CvTS
::
OK
;
c
onst
double
thresh
=
0.5
;
c
v
::
RNG
rng
(
*
ts
->
get_rng
())
;
const
double
maxval
=
0.0
;
const
double
thresh
=
rng
;
cv
::
Mat
cpuRes
;
cv
::
Mat
cpuRes
;
cv
::
threshold
(
cpu1
,
cpuRes
,
thresh
,
maxval
,
THRESH_TRUNC
);
cv
::
threshold
(
cpu1
,
cpuRes
,
thresh
,
0.0
,
THRESH_TRUNC
);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpuRes
;
GpuMat
gpuRes
;
cv
::
gpu
::
threshold
(
gpu1
,
gpuRes
,
thresh
,
maxval
,
THRESH_TRUNC
);
cv
::
gpu
::
threshold
(
gpu1
,
gpuRes
,
thresh
);
return
CheckNorm
(
cpuRes
,
gpuRes
);
return
CheckNorm
(
cpuRes
,
gpuRes
);
}
}
...
@@ -458,15 +473,30 @@ int CV_GpuNppImageCompareTest::test( const Mat& cpu1, const Mat& cpu2 )
...
@@ -458,15 +473,30 @@ int CV_GpuNppImageCompareTest::test( const Mat& cpu1, const Mat& cpu2 )
if
(
cpu1
.
type
()
!=
CV_32FC1
)
if
(
cpu1
.
type
()
!=
CV_32FC1
)
return
CvTS
::
OK
;
return
CvTS
::
OK
;
int
cmp_codes
[]
=
{
CMP_EQ
,
CMP_GT
,
CMP_GE
,
CMP_LT
,
CMP_LE
,
CMP_NE
};
const
char
*
cmp_str
[]
=
{
"CMP_EQ"
,
"CMP_GT"
,
"CMP_GE"
,
"CMP_LT"
,
"CMP_LE"
,
"CMP_NE"
};
int
cmp_num
=
sizeof
(
cmp_codes
)
/
sizeof
(
int
);
int
test_res
=
CvTS
::
OK
;
for
(
int
i
=
0
;
i
<
cmp_num
;
++
i
)
{
cv
::
Mat
cpuRes
;
cv
::
Mat
cpuRes
;
cv
::
compare
(
cpu1
,
cpu2
,
cpuRes
,
CMP_GT
);
cv
::
compare
(
cpu1
,
cpu2
,
cpuRes
,
cmp_codes
[
i
]
);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpu2
(
cpu2
);
GpuMat
gpu2
(
cpu2
);
GpuMat
gpuRes
;
GpuMat
gpuRes
;
cv
::
gpu
::
compare
(
gpu1
,
gpu2
,
gpuRes
,
CMP_GT
);
cv
::
gpu
::
compare
(
gpu1
,
gpu2
,
gpuRes
,
cmp_codes
[
i
]
);
return
CheckNorm
(
cpuRes
,
gpuRes
);
if
(
CheckNorm
(
cpuRes
,
gpuRes
)
!=
CvTS
::
OK
)
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
Compare operation: %s
\n
"
,
cmp_str
[
i
]);
test_res
=
CvTS
::
FAIL_GENERIC
;
}
}
return
test_res
;
}
}
CV_GpuNppImageCompareTest
CV_GpuNppImageCompare_test
;
CV_GpuNppImageCompareTest
CV_GpuNppImageCompare_test
;
...
@@ -525,19 +555,28 @@ int CV_GpuNppImageNormTest::test( const Mat& cpu1, const Mat& cpu2 )
...
@@ -525,19 +555,28 @@ int CV_GpuNppImageNormTest::test( const Mat& cpu1, const Mat& cpu2 )
if
(
cpu1
.
type
()
!=
CV_8UC1
)
if
(
cpu1
.
type
()
!=
CV_8UC1
)
return
CvTS
::
OK
;
return
CvTS
::
OK
;
double
cpu_norm_inf
=
cv
::
norm
(
cpu1
,
cpu2
,
NORM_INF
);
int
norms
[]
=
{
NORM_INF
,
NORM_L1
,
NORM_L2
};
double
cpu_norm_L1
=
cv
::
norm
(
cpu1
,
cpu2
,
NORM_L1
);
const
char
*
norms_str
[]
=
{
"NORM_INF"
,
"NORM_L1"
,
"NORM_L2"
};
double
cpu_norm_L2
=
cv
::
norm
(
cpu1
,
cpu2
,
NORM_L2
);
int
norms_num
=
sizeof
(
norms
)
/
sizeof
(
int
);
int
test_res
=
CvTS
::
OK
;
for
(
int
i
=
0
;
i
<
norms_num
;
++
i
)
{
double
cpu_norm
=
cv
::
norm
(
cpu1
,
cpu2
,
norms
[
i
]);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpu2
(
cpu2
);
GpuMat
gpu2
(
cpu2
);
double
gpu_norm_inf
=
cv
::
gpu
::
norm
(
gpu1
,
gpu2
,
NORM_INF
);
double
gpu_norm
=
cv
::
gpu
::
norm
(
gpu1
,
gpu2
,
norms
[
i
]);
double
gpu_norm_L1
=
cv
::
gpu
::
norm
(
gpu1
,
gpu2
,
NORM_L1
);
double
gpu_norm_L2
=
cv
::
gpu
::
norm
(
gpu1
,
gpu2
,
NORM_L2
);
return
(
CheckNorm
(
cpu_norm_inf
,
gpu_norm_inf
)
==
CvTS
::
OK
if
(
CheckNorm
(
cpu_norm
,
gpu_norm
)
!=
CvTS
::
OK
)
&&
CheckNorm
(
cpu_norm_L1
,
gpu_norm_L1
)
==
CvTS
::
OK
{
&&
CheckNorm
(
cpu_norm_L2
,
gpu_norm_L2
)
==
CvTS
::
OK
)
?
CvTS
::
OK
:
CvTS
::
FAIL_GENERIC
;
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
Norm type: %s
\n
"
,
norms_str
[
i
]);
test_res
=
CvTS
::
FAIL_GENERIC
;
}
}
return
test_res
;
}
}
CV_GpuNppImageNormTest
CV_GpuNppImageNorm_test
;
CV_GpuNppImageNormTest
CV_GpuNppImageNorm_test
;
...
@@ -562,20 +601,29 @@ int CV_GpuNppImageFlipTest::test( const Mat& cpu1, const Mat& )
...
@@ -562,20 +601,29 @@ int CV_GpuNppImageFlipTest::test( const Mat& cpu1, const Mat& )
if
(
cpu1
.
type
()
!=
CV_8UC1
&&
cpu1
.
type
()
!=
CV_8UC4
)
if
(
cpu1
.
type
()
!=
CV_8UC1
&&
cpu1
.
type
()
!=
CV_8UC4
)
return
CvTS
::
OK
;
return
CvTS
::
OK
;
Mat
cpux
,
cpuy
,
cpub
;
int
flip_codes
[]
=
{
0
,
1
,
-
1
};
cv
::
flip
(
cpu1
,
cpux
,
0
);
const
char
*
flip_axis
[]
=
{
"X"
,
"Y"
,
"Both"
};
cv
::
flip
(
cpu1
,
cpuy
,
1
);
int
flip_codes_num
=
sizeof
(
flip_codes
)
/
sizeof
(
int
);
cv
::
flip
(
cpu1
,
cpub
,
-
1
);
int
test_res
=
CvTS
::
OK
;
for
(
int
i
=
0
;
i
<
flip_codes_num
;
++
i
)
{
Mat
cpu_res
;
cv
::
flip
(
cpu1
,
cpu_res
,
flip_codes
[
i
]);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpux
,
gpuy
,
gpub
;
GpuMat
gpu_res
;
cv
::
gpu
::
flip
(
gpu1
,
gpux
,
0
);
cv
::
gpu
::
flip
(
gpu1
,
gpu_res
,
flip_codes
[
i
]);
cv
::
gpu
::
flip
(
gpu1
,
gpuy
,
1
);
cv
::
gpu
::
flip
(
gpu1
,
gpub
,
-
1
);
return
(
CheckNorm
(
cpux
,
gpux
)
==
CvTS
::
OK
&&
if
(
CheckNorm
(
cpu_res
,
gpu_res
)
!=
CvTS
::
OK
)
CheckNorm
(
cpuy
,
gpuy
)
==
CvTS
::
OK
&&
{
CheckNorm
(
cpub
,
gpub
)
==
CvTS
::
OK
)
?
CvTS
::
OK
:
CvTS
::
FAIL_GENERIC
;
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
Flip Axis: %s
\n
"
,
flip_axis
[
i
]);
test_res
=
CvTS
::
FAIL_GENERIC
;
}
}
return
test_res
;
}
}
CV_GpuNppImageFlipTest
CV_GpuNppImageFlip_test
;
CV_GpuNppImageFlipTest
CV_GpuNppImageFlip_test
;
...
@@ -600,25 +648,28 @@ int CV_GpuNppImageResizeTest::test( const Mat& cpu1, const Mat& )
...
@@ -600,25 +648,28 @@ int CV_GpuNppImageResizeTest::test( const Mat& cpu1, const Mat& )
if
(
cpu1
.
type
()
!=
CV_8UC1
&&
cpu1
.
type
()
!=
CV_8UC4
)
if
(
cpu1
.
type
()
!=
CV_8UC1
&&
cpu1
.
type
()
!=
CV_8UC4
)
return
CvTS
::
OK
;
return
CvTS
::
OK
;
Mat
cpunn
,
cpulin
,
cpucub
,
cpulanc
;
int
interpolations
[]
=
{
INTER_NEAREST
,
INTER_LINEAR
,
INTER_CUBIC
,
INTER_LANCZOS4
};
cv
::
resize
(
cpu1
,
cpunn
,
Size
(),
0.5
,
0.5
,
INTER_NEAREST
);
const
char
*
interpolations_str
[]
=
{
"INTER_NEAREST"
,
"INTER_LINEAR"
,
"INTER_CUBIC"
,
"INTER_LANCZOS4"
};
cv
::
resize
(
cpu1
,
cpulin
,
Size
(),
0.5
,
0.5
,
INTER_LINEAR
);
int
interpolations_num
=
sizeof
(
interpolations
)
/
sizeof
(
int
);
cv
::
resize
(
cpu1
,
cpucub
,
Size
(),
0.5
,
0.5
,
INTER_CUBIC
);
cv
::
resize
(
cpu1
,
cpulanc
,
Size
(),
0.5
,
0.5
,
INTER_LANCZOS4
);
GpuMat
gpu1
(
cpu1
);
int
test_res
=
CvTS
::
OK
;
GpuMat
gpunn
,
gpulin
,
gpucub
,
gpulanc
;
cv
::
gpu
::
resize
(
gpu1
,
gpunn
,
Size
(),
0.5
,
0.5
,
INTER_NEAREST
);
cv
::
gpu
::
resize
(
gpu1
,
gpulin
,
Size
(),
0.5
,
0.5
,
INTER_LINEAR
);
cv
::
gpu
::
resize
(
gpu1
,
gpucub
,
Size
(),
0.5
,
0.5
,
INTER_CUBIC
);
cv
::
gpu
::
resize
(
gpu1
,
gpulanc
,
Size
(),
0.5
,
0.5
,
INTER_LANCZOS4
);
int
nnres
=
CheckNorm
(
cpunn
,
gpunn
);
for
(
int
i
=
0
;
i
<
interpolations_num
;
++
i
)
int
linres
=
CheckNorm
(
cpulin
,
gpulin
);
{
int
cubres
=
CheckNorm
(
cpucub
,
gpucub
)
;
Mat
cpu_res
;
int
lancres
=
CheckNorm
(
cpulanc
,
gpulanc
);
cv
::
resize
(
cpu1
,
cpu_res
,
Size
(),
0.5
,
0.5
,
interpolations
[
i
]
);
return
(
nnres
==
CvTS
::
OK
&&
linres
==
CvTS
::
OK
&&
cubres
==
CvTS
::
OK
&&
lancres
==
CvTS
::
OK
)
?
CvTS
::
OK
:
CvTS
::
FAIL_GENERIC
;
GpuMat
gpu1
(
cpu1
),
gpu_res
;
cv
::
gpu
::
resize
(
gpu1
,
gpu_res
,
Size
(),
0.5
,
0.5
,
interpolations
[
i
]);
if
(
CheckNorm
(
cpu_res
,
gpu_res
)
!=
CvTS
::
OK
)
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
Interpolation type: %s
\n
"
,
interpolations_str
[
i
]);
test_res
=
CvTS
::
FAIL_GENERIC
;
}
}
return
test_res
;
}
}
CV_GpuNppImageResizeTest
CV_GpuNppImageResize_test
;
CV_GpuNppImageResizeTest
CV_GpuNppImageResize_test
;
...
@@ -744,14 +795,29 @@ int CV_GpuNppImageWarpAffineTest::test( const Mat& cpu1, const Mat& )
...
@@ -744,14 +795,29 @@ int CV_GpuNppImageWarpAffineTest::test( const Mat& cpu1, const Mat& )
if
(
cpu1
.
type
()
==
CV_32SC1
)
if
(
cpu1
.
type
()
==
CV_32SC1
)
return
CvTS
::
OK
;
return
CvTS
::
OK
;
int
flags
[]
=
{
INTER_NEAREST
,
INTER_LINEAR
,
INTER_CUBIC
,
INTER_NEAREST
|
WARP_INVERSE_MAP
,
INTER_LINEAR
|
WARP_INVERSE_MAP
,
INTER_CUBIC
|
WARP_INVERSE_MAP
};
const
char
*
flags_str
[]
=
{
"INTER_NEAREST"
,
"INTER_LINEAR"
,
"INTER_CUBIC"
,
"INTER_NEAREST | WARP_INVERSE_MAP"
,
"INTER_LINEAR | WARP_INVERSE_MAP"
,
"INTER_CUBIC | WARP_INVERSE_MAP"
};
int
flags_num
=
sizeof
(
flags
)
/
sizeof
(
int
);
int
test_res
=
CvTS
::
OK
;
for
(
int
i
=
0
;
i
<
flags_num
;
++
i
)
{
Mat
cpudst
;
Mat
cpudst
;
cv
::
warpAffine
(
cpu1
,
cpudst
,
M
,
cpu1
.
size
(),
INTER_CUBIC
|
WARP_INVERSE_MAP
);
cv
::
warpAffine
(
cpu1
,
cpudst
,
M
,
cpu1
.
size
(),
flags
[
i
]
);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpudst
;
GpuMat
gpudst
;
cv
::
gpu
::
warpAffine
(
gpu1
,
gpudst
,
M
,
gpu1
.
size
(),
INTER_CUBIC
|
WARP_INVERSE_MAP
);
cv
::
gpu
::
warpAffine
(
gpu1
,
gpudst
,
M
,
gpu1
.
size
(),
flags
[
i
]
);
return
CheckNorm
(
cpudst
,
gpudst
);
if
(
CheckNorm
(
cpudst
,
gpudst
)
!=
CvTS
::
OK
)
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
Flags: %s
\n
"
,
flags_str
[
i
]);
test_res
=
CvTS
::
FAIL_GENERIC
;
}
}
return
test_res
;
}
}
CV_GpuNppImageWarpAffineTest
CV_GpuNppImageWarpAffine_test
;
CV_GpuNppImageWarpAffineTest
CV_GpuNppImageWarpAffine_test
;
...
@@ -784,14 +850,29 @@ int CV_GpuNppImageWarpPerspectiveTest::test( const Mat& cpu1, const Mat& )
...
@@ -784,14 +850,29 @@ int CV_GpuNppImageWarpPerspectiveTest::test( const Mat& cpu1, const Mat& )
if
(
cpu1
.
type
()
==
CV_32SC1
)
if
(
cpu1
.
type
()
==
CV_32SC1
)
return
CvTS
::
OK
;
return
CvTS
::
OK
;
int
flags
[]
=
{
INTER_NEAREST
,
INTER_LINEAR
,
INTER_CUBIC
,
INTER_NEAREST
|
WARP_INVERSE_MAP
,
INTER_LINEAR
|
WARP_INVERSE_MAP
,
INTER_CUBIC
|
WARP_INVERSE_MAP
};
const
char
*
flags_str
[]
=
{
"INTER_NEAREST"
,
"INTER_LINEAR"
,
"INTER_CUBIC"
,
"INTER_NEAREST | WARP_INVERSE_MAP"
,
"INTER_LINEAR | WARP_INVERSE_MAP"
,
"INTER_CUBIC | WARP_INVERSE_MAP"
};
int
flags_num
=
sizeof
(
flags
)
/
sizeof
(
int
);
int
test_res
=
CvTS
::
OK
;
for
(
int
i
=
0
;
i
<
flags_num
;
++
i
)
{
Mat
cpudst
;
Mat
cpudst
;
cv
::
warpPerspective
(
cpu1
,
cpudst
,
M
,
cpu1
.
size
(),
INTER_CUBIC
|
WARP_INVERSE_MAP
);
cv
::
warpPerspective
(
cpu1
,
cpudst
,
M
,
cpu1
.
size
(),
flags
[
i
]
);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpu1
(
cpu1
);
GpuMat
gpudst
;
GpuMat
gpudst
;
cv
::
gpu
::
warpPerspective
(
gpu1
,
gpudst
,
M
,
gpu1
.
size
(),
INTER_CUBIC
|
WARP_INVERSE_MAP
);
cv
::
gpu
::
warpPerspective
(
gpu1
,
gpudst
,
M
,
gpu1
.
size
(),
flags
[
i
]
);
return
CheckNorm
(
cpudst
,
gpudst
);
if
(
CheckNorm
(
cpudst
,
gpudst
)
!=
CvTS
::
OK
)
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
Flags: %s
\n
"
,
flags_str
[
i
]);
test_res
=
CvTS
::
FAIL_GENERIC
;
}
}
return
test_res
;
}
}
CV_GpuNppImageWarpPerspectiveTest
CV_GpuNppImageWarpPerspective_test
;
CV_GpuNppImageWarpPerspectiveTest
CV_GpuNppImageWarpPerspective_test
;
tests/gpu/src/operator_async_call.cpp
View file @
a2f8817d
...
@@ -143,7 +143,16 @@ void CV_GpuMatAsyncCallTest::run( int /* start_from */)
...
@@ -143,7 +143,16 @@ void CV_GpuMatAsyncCallTest::run( int /* start_from */)
Mat
cpumat
(
rows
,
cols
,
CV_8U
);
Mat
cpumat
(
rows
,
cols
,
CV_8U
);
cpumat
.
setTo
(
Scalar
::
all
(
127
));
cpumat
.
setTo
(
Scalar
::
all
(
127
));
try
{
is_test_good
&=
compare_matrix
(
cpumat
);
is_test_good
&=
compare_matrix
(
cpumat
);
}
catch
(
cv
::
Exception
&
e
)
{
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
return
;
}
if
(
is_test_good
==
true
)
if
(
is_test_good
==
true
)
ts
->
set_failed_test_info
(
CvTS
::
OK
);
ts
->
set_failed_test_info
(
CvTS
::
OK
);
...
@@ -151,4 +160,4 @@ void CV_GpuMatAsyncCallTest::run( int /* start_from */)
...
@@ -151,4 +160,4 @@ void CV_GpuMatAsyncCallTest::run( int /* start_from */)
ts
->
set_failed_test_info
(
CvTS
::
FAIL_GENERIC
);
ts
->
set_failed_test_info
(
CvTS
::
FAIL_GENERIC
);
}
}
CV_GpuMatAsyncCallTest
CV_GpuMatAsyncCall_test
;
//
CV_GpuMatAsyncCallTest CV_GpuMatAsyncCall_test;
tests/gpu/src/operator_convert_to.cpp
View file @
a2f8817d
...
@@ -115,10 +115,12 @@ void CV_GpuMatOpConvertToTest::run(int /* start_from */)
...
@@ -115,10 +115,12 @@ void CV_GpuMatOpConvertToTest::run(int /* start_from */)
}
}
catch
(
cv
::
Exception
&
e
)
catch
(
cv
::
Exception
&
e
)
{
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
ERROR: %s
\n
"
,
e
.
what
());
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
return
;
}
}
ts
->
set_failed_test_info
(
passed
?
CvTS
::
OK
:
CvTS
::
FAIL_GENERIC
);
ts
->
set_failed_test_info
(
passed
?
CvTS
::
OK
:
CvTS
::
FAIL_GENERIC
);
}
}
CV_GpuMatOpConvertToTest
CV_GpuMatOpConvertToTest_test
;
CV_GpuMatOpConvertToTest
CV_GpuMatOpConvertToTest_test
;
tests/gpu/src/operator_copy_to.cpp
View file @
a2f8817d
...
@@ -136,6 +136,8 @@ void CV_GpuMatOpCopyToTest::run( int /* start_from */)
...
@@ -136,6 +136,8 @@ void CV_GpuMatOpCopyToTest::run( int /* start_from */)
{
{
bool
is_test_good
=
true
;
bool
is_test_good
=
true
;
try
{
for
(
int
i
=
0
;
i
<
7
;
i
++
)
for
(
int
i
=
0
;
i
<
7
;
i
++
)
{
{
Mat
cpumat
(
rows
,
cols
,
i
);
Mat
cpumat
(
rows
,
cols
,
i
);
...
@@ -145,6 +147,13 @@ void CV_GpuMatOpCopyToTest::run( int /* start_from */)
...
@@ -145,6 +147,13 @@ void CV_GpuMatOpCopyToTest::run( int /* start_from */)
is_test_good
&=
compare_matrix
(
cpumat
,
gpumat
);
is_test_good
&=
compare_matrix
(
cpumat
,
gpumat
);
}
}
}
catch
(
const
cv
::
Exception
&
e
)
{
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
return
;
}
if
(
is_test_good
==
true
)
if
(
is_test_good
==
true
)
ts
->
set_failed_test_info
(
CvTS
::
OK
);
ts
->
set_failed_test_info
(
CvTS
::
OK
);
...
...
tests/gpu/src/operator_set_to.cpp
View file @
a2f8817d
...
@@ -132,12 +132,21 @@ void CV_GpuMatOpSetToTest::run( int /* start_from */)
...
@@ -132,12 +132,21 @@ void CV_GpuMatOpSetToTest::run( int /* start_from */)
{
{
bool
is_test_good
=
true
;
bool
is_test_good
=
true
;
try
{
for
(
int
i
=
0
;
i
<
7
;
i
++
)
for
(
int
i
=
0
;
i
<
7
;
i
++
)
{
{
Mat
cpumat
(
rows
,
cols
,
i
,
Scalar
::
all
(
0
));
Mat
cpumat
(
rows
,
cols
,
i
,
Scalar
::
all
(
0
));
GpuMat
gpumat
(
cpumat
);
GpuMat
gpumat
(
cpumat
);
is_test_good
&=
compare_matrix
(
cpumat
,
gpumat
);
is_test_good
&=
compare_matrix
(
cpumat
,
gpumat
);
}
}
}
catch
(
const
cv
::
Exception
&
e
)
{
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
return
;
}
if
(
is_test_good
==
true
)
if
(
is_test_good
==
true
)
ts
->
set_failed_test_info
(
CvTS
::
OK
);
ts
->
set_failed_test_info
(
CvTS
::
OK
);
...
...
tests/gpu/src/stereo_bm.cpp
View file @
a2f8817d
...
@@ -70,6 +70,8 @@ void CV_GpuStereoBMTest::run(int )
...
@@ -70,6 +70,8 @@ void CV_GpuStereoBMTest::run(int )
return
;
return
;
}
}
try
{
cv
::
gpu
::
GpuMat
disp
;
cv
::
gpu
::
GpuMat
disp
;
cv
::
gpu
::
StereoBM_GPU
bm
(
0
,
128
,
19
);
cv
::
gpu
::
StereoBM_GPU
bm
(
0
,
128
,
19
);
bm
(
cv
::
gpu
::
GpuMat
(
img_l
),
cv
::
gpu
::
GpuMat
(
img_r
),
disp
);
bm
(
cv
::
gpu
::
GpuMat
(
img_l
),
cv
::
gpu
::
GpuMat
(
img_r
),
disp
);
...
@@ -78,10 +80,20 @@ void CV_GpuStereoBMTest::run(int )
...
@@ -78,10 +80,20 @@ void CV_GpuStereoBMTest::run(int )
double
norm
=
cv
::
norm
(
disp
,
img_reference
,
cv
::
NORM_INF
);
double
norm
=
cv
::
norm
(
disp
,
img_reference
,
cv
::
NORM_INF
);
if
(
norm
>=
100
)
if
(
norm
>=
100
)
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
StereoBM norm = %f
\n
"
,
norm
);
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
StereoBM norm = %f
\n
"
,
norm
);
ts
->
set_failed_test_info
((
norm
<
100
)
?
CvTS
::
OK
:
CvTS
::
FAIL_GENERIC
);
ts
->
set_failed_test_info
(
CvTS
::
FAIL_GENERIC
);
}
return
;
}
}
catch
(
const
cv
::
Exception
&
e
)
{
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
return
;
}
ts
->
set_failed_test_info
(
CvTS
::
OK
);
}
CV_GpuStereoBMTest
CV_GpuStereoBM_test
;
CV_GpuStereoBMTest
CV_GpuStereoBM_test
;
tests/gpu/src/stereo_bm_async.cpp
View file @
a2f8817d
...
@@ -74,6 +74,8 @@ void CV_GpuMatAsyncCallStereoBMTest::run( int /* start_from */)
...
@@ -74,6 +74,8 @@ void CV_GpuMatAsyncCallStereoBMTest::run( int /* start_from */)
return
;
return
;
}
}
try
{
cv
::
gpu
::
GpuMat
disp
;
cv
::
gpu
::
GpuMat
disp
;
cv
::
gpu
::
StereoBM_GPU
bm
(
0
,
128
,
19
);
cv
::
gpu
::
StereoBM_GPU
bm
(
0
,
128
,
19
);
...
@@ -89,9 +91,20 @@ void CV_GpuMatAsyncCallStereoBMTest::run( int /* start_from */)
...
@@ -89,9 +91,20 @@ void CV_GpuMatAsyncCallStereoBMTest::run( int /* start_from */)
double
norm
=
cv
::
norm
(
disp
,
img_reference
,
cv
::
NORM_INF
);
double
norm
=
cv
::
norm
(
disp
,
img_reference
,
cv
::
NORM_INF
);
if
(
norm
>=
100
)
if
(
norm
>=
100
)
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
StereoBM norm = %f
\n
"
,
norm
);
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
StereoBM norm = %f
\n
"
,
norm
);
ts
->
set_failed_test_info
((
norm
<
100
)
?
CvTS
::
OK
:
CvTS
::
FAIL_GENERIC
);
ts
->
set_failed_test_info
(
CvTS
::
FAIL_GENERIC
);
return
;
}
}
catch
(
const
cv
::
Exception
&
e
)
{
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
return
;
}
ts
->
set_failed_test_info
(
CvTS
::
OK
);
}
}
CV_GpuMatAsyncCallStereoBMTest
CV_GpuMatAsyncCallStereoBMTest_test
;
CV_GpuMatAsyncCallStereoBMTest
CV_GpuMatAsyncCallStereoBMTest_test
;
tests/gpu/src/stereo_bp.cpp
View file @
a2f8817d
...
@@ -69,6 +69,8 @@ void CV_GpuStereoBPTest::run(int )
...
@@ -69,6 +69,8 @@ void CV_GpuStereoBPTest::run(int )
return
;
return
;
}
}
try
{
cv
::
gpu
::
GpuMat
disp
;
cv
::
gpu
::
GpuMat
disp
;
cv
::
gpu
::
StereoBeliefPropagation
bpm
(
64
,
8
,
2
,
25
,
0.1
f
,
15
,
1
,
CV_16S
);
cv
::
gpu
::
StereoBeliefPropagation
bpm
(
64
,
8
,
2
,
25
,
0.1
f
,
15
,
1
,
CV_16S
);
...
@@ -80,9 +82,20 @@ void CV_GpuStereoBPTest::run(int )
...
@@ -80,9 +82,20 @@ void CV_GpuStereoBPTest::run(int )
double
norm
=
cv
::
norm
(
disp
,
img_template
,
cv
::
NORM_INF
);
double
norm
=
cv
::
norm
(
disp
,
img_template
,
cv
::
NORM_INF
);
if
(
norm
>=
0.5
)
if
(
norm
>=
0.5
)
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
StereoBP norm = %f
\n
"
,
norm
);
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
StereoBP norm = %f
\n
"
,
norm
);
ts
->
set_failed_test_info
((
norm
<
0.5
)
?
CvTS
::
OK
:
CvTS
::
FAIL_GENERIC
);
ts
->
set_failed_test_info
(
CvTS
::
FAIL_GENERIC
);
}
return
;
}
}
catch
(
const
cv
::
Exception
&
e
)
{
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
return
;
}
ts
->
set_failed_test_info
(
CvTS
::
OK
);
}
CV_GpuStereoBPTest
CV_GpuStereoBP_test
;
CV_GpuStereoBPTest
CV_GpuStereoBP_test
;
tests/gpu/src/stereo_csbp.cpp
View file @
a2f8817d
...
@@ -69,6 +69,8 @@ void CV_GpuStereoCSBPTest::run(int )
...
@@ -69,6 +69,8 @@ void CV_GpuStereoCSBPTest::run(int )
return
;
return
;
}
}
try
{
cv
::
gpu
::
GpuMat
disp
;
cv
::
gpu
::
GpuMat
disp
;
cv
::
gpu
::
StereoConstantSpaceBP
bpm
(
128
,
16
,
4
,
4
);
cv
::
gpu
::
StereoConstantSpaceBP
bpm
(
128
,
16
,
4
,
4
);
...
@@ -80,8 +82,20 @@ void CV_GpuStereoCSBPTest::run(int )
...
@@ -80,8 +82,20 @@ void CV_GpuStereoCSBPTest::run(int )
double
norm
=
cv
::
norm
(
disp
,
img_template
,
cv
::
NORM_INF
);
double
norm
=
cv
::
norm
(
disp
,
img_template
,
cv
::
NORM_INF
);
if
(
norm
>=
0.5
)
if
(
norm
>=
0.5
)
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
ConstantSpaceStereoBP norm = %f
\n
"
,
norm
);
ts
->
printf
(
CvTS
::
CONSOLE
,
"
\n
ConstantSpaceStereoBP norm = %f
\n
"
,
norm
);
ts
->
set_failed_test_info
((
norm
<
0.5
)
?
CvTS
::
OK
:
CvTS
::
FAIL_GENERIC
);
ts
->
set_failed_test_info
(
CvTS
::
FAIL_GENERIC
);
return
;
}
}
catch
(
const
cv
::
Exception
&
e
)
{
if
(
!
check_and_treat_gpu_exception
(
e
,
ts
))
throw
;
return
;
}
ts
->
set_failed_test_info
(
CvTS
::
OK
);
}
}
CV_GpuStereoCSBPTest
CV_GpuCSStereoBP_test
;
CV_GpuStereoCSBPTest
CV_GpuCSStereoBP_test
;
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