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
0aaaad1e
Commit
0aaaad1e
authored
Sep 21, 2011
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented gpu::addWeighted
parent
64119dd9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
10 deletions
+121
-10
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+4
-0
perf_arithm.cpp
modules/gpu/perf/perf_arithm.cpp
+31
-0
element_operations.cu
modules/gpu/src/cuda/element_operations.cu
+0
-0
element_operations.cpp
modules/gpu/src/element_operations.cpp
+0
-0
test_arithm.cpp
modules/gpu/test/test_arithm.cpp
+86
-10
No files found.
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
0aaaad1e
...
...
@@ -593,6 +593,10 @@ namespace cv
//! computes per-element maximum of array and scalar (dst = max(src1, src2))
CV_EXPORTS
void
max
(
const
GpuMat
&
src1
,
double
src2
,
GpuMat
&
dst
,
Stream
&
stream
=
Stream
::
Null
());
//! computes the weighted sum of two arrays
CV_EXPORTS
void
addWeighted
(
const
GpuMat
&
src1
,
double
alpha
,
const
GpuMat
&
src2
,
double
beta
,
double
gamma
,
GpuMat
&
dst
,
int
dtype
=
-
1
,
Stream
&
stream
=
Stream
::
Null
());
////////////////////////////// Image processing //////////////////////////////
...
...
modules/gpu/perf/perf_arithm.cpp
View file @
0aaaad1e
...
...
@@ -685,3 +685,34 @@ PERF_TEST_P(DevInfo_Size_MatType, countNonZero, testing::Combine(testing::Values
SANITY_CHECK
(
dst
);
}
PERF_TEST_P
(
DevInfo_Size_MatType
,
addWeighted
,
testing
::
Combine
(
testing
::
ValuesIn
(
devices
()),
testing
::
Values
(
GPU_TYPICAL_MAT_SIZES
),
testing
::
Values
(
CV_8UC1
,
CV_16UC1
,
CV_32FC1
)))
{
DeviceInfo
devInfo
=
std
::
tr1
::
get
<
0
>
(
GetParam
());
Size
size
=
std
::
tr1
::
get
<
1
>
(
GetParam
());
int
type
=
std
::
tr1
::
get
<
2
>
(
GetParam
());
setDevice
(
devInfo
.
deviceID
());
Mat
src1_host
(
size
,
type
);
Mat
src2_host
(
size
,
type
);
declare
.
in
(
src1_host
,
src2_host
,
WARMUP_RNG
);
GpuMat
src1
(
src1_host
);
GpuMat
src2
(
src2_host
);
GpuMat
dst
(
size
,
type
);
declare
.
time
(
0.5
).
iterations
(
100
);
SIMPLE_TEST_CYCLE
()
{
addWeighted
(
src1
,
0.5
,
src2
,
0.5
,
0.0
,
dst
);
}
Mat
dst_host
=
dst
;
SANITY_CHECK
(
dst_host
);
}
modules/gpu/src/cuda/element_operations.cu
View file @
0aaaad1e
This diff is collapsed.
Click to expand it.
modules/gpu/src/element_operations.cpp
View file @
0aaaad1e
This diff is collapsed.
Click to expand it.
modules/gpu/test/test_arithm.cpp
View file @
0aaaad1e
...
...
@@ -1135,7 +1135,7 @@ TEST_P(MinMax, Accuracy)
return
;
PRINT_PARAM
(
devInfo
);
PRINT_TYPE
(
type
)
PRINT_TYPE
(
type
)
;
PRINT_PARAM
(
size
);
double
minVal
,
maxVal
;
...
...
@@ -1216,7 +1216,7 @@ TEST_P(MinMaxLoc, Accuracy)
return
;
PRINT_PARAM
(
devInfo
);
PRINT_TYPE
(
type
)
PRINT_TYPE
(
type
)
;
PRINT_PARAM
(
size
);
double
minVal
,
maxVal
;
...
...
@@ -1281,7 +1281,7 @@ TEST_P(CountNonZero, Accuracy)
return
;
PRINT_PARAM
(
devInfo
);
PRINT_TYPE
(
type
)
PRINT_TYPE
(
type
)
;
PRINT_PARAM
(
size
);
int
n
;
...
...
@@ -1333,7 +1333,7 @@ TEST_P(Sum, Accuracy)
return
;
PRINT_PARAM
(
devInfo
);
PRINT_TYPE
(
type
)
PRINT_TYPE
(
type
)
;
PRINT_PARAM
(
size
);
cv
::
Scalar
sum
;
...
...
@@ -1385,7 +1385,7 @@ TEST_P(AbsSum, Accuracy)
return
;
PRINT_PARAM
(
devInfo
);
PRINT_TYPE
(
type
)
PRINT_TYPE
(
type
)
;
PRINT_PARAM
(
size
);
cv
::
Scalar
sum
;
...
...
@@ -1439,7 +1439,7 @@ TEST_P(SqrSum, Accuracy)
return
;
PRINT_PARAM
(
devInfo
);
PRINT_TYPE
(
type
)
PRINT_TYPE
(
type
)
;
PRINT_PARAM
(
size
);
cv
::
Scalar
sum
;
...
...
@@ -1500,7 +1500,7 @@ TEST_P(BitwiseNot, Accuracy)
return
;
PRINT_PARAM
(
devInfo
);
PRINT_TYPE
(
type
)
PRINT_TYPE
(
type
)
;
PRINT_PARAM
(
size
);
cv
::
Mat
dst
;
...
...
@@ -1564,7 +1564,7 @@ TEST_P(BitwiseOr, Accuracy)
return
;
PRINT_PARAM
(
devInfo
);
PRINT_TYPE
(
type
)
PRINT_TYPE
(
type
)
;
PRINT_PARAM
(
size
);
cv
::
Mat
dst
;
...
...
@@ -1628,7 +1628,7 @@ TEST_P(BitwiseAnd, Accuracy)
return
;
PRINT_PARAM
(
devInfo
);
PRINT_TYPE
(
type
)
PRINT_TYPE
(
type
)
;
PRINT_PARAM
(
size
);
cv
::
Mat
dst
;
...
...
@@ -1692,7 +1692,7 @@ TEST_P(BitwiseXor, Accuracy)
return
;
PRINT_PARAM
(
devInfo
);
PRINT_TYPE
(
type
)
PRINT_TYPE
(
type
)
;
PRINT_PARAM
(
size
);
cv
::
Mat
dst
;
...
...
@@ -1712,4 +1712,80 @@ INSTANTIATE_TEST_CASE_P(Arithm, BitwiseXor, testing::Combine(
testing
::
ValuesIn
(
devices
()),
testing
::
ValuesIn
(
all_types
())));
//////////////////////////////////////////////////////////////////////////////
// addWeighted
struct
AddWeighted
:
testing
::
TestWithParam
<
std
::
tr1
::
tuple
<
cv
::
gpu
::
DeviceInfo
,
int
,
int
,
int
>
>
{
cv
::
gpu
::
DeviceInfo
devInfo
;
int
type1
;
int
type2
;
int
dtype
;
cv
::
Size
size
;
cv
::
Mat
src1
;
cv
::
Mat
src2
;
double
alpha
;
double
beta
;
double
gamma
;
cv
::
Mat
dst_gold
;
virtual
void
SetUp
()
{
devInfo
=
std
::
tr1
::
get
<
0
>
(
GetParam
());
type1
=
std
::
tr1
::
get
<
1
>
(
GetParam
());
type2
=
std
::
tr1
::
get
<
2
>
(
GetParam
());
dtype
=
std
::
tr1
::
get
<
3
>
(
GetParam
());
cv
::
gpu
::
setDevice
(
devInfo
.
deviceID
());
cv
::
RNG
&
rng
=
cvtest
::
TS
::
ptr
()
->
get_rng
();
size
=
cv
::
Size
(
rng
.
uniform
(
100
,
200
),
rng
.
uniform
(
100
,
200
));
src1
=
cvtest
::
randomMat
(
rng
,
size
,
type1
,
0.0
,
255.0
,
false
);
src2
=
cvtest
::
randomMat
(
rng
,
size
,
type2
,
0.0
,
255.0
,
false
);
alpha
=
rng
.
uniform
(
-
10.0
,
10.0
);
beta
=
rng
.
uniform
(
-
10.0
,
10.0
);
gamma
=
rng
.
uniform
(
-
10.0
,
10.0
);
cv
::
addWeighted
(
src1
,
alpha
,
src2
,
beta
,
gamma
,
dst_gold
,
dtype
);
}
};
TEST_P
(
AddWeighted
,
Accuracy
)
{
if
((
src1
.
depth
()
==
CV_64F
||
src2
.
depth
()
==
CV_64F
||
dst_gold
.
depth
()
==
CV_64F
)
&&
!
supportFeature
(
devInfo
,
cv
::
gpu
::
NATIVE_DOUBLE
))
return
;
PRINT_PARAM
(
devInfo
);
PRINT_TYPE
(
type1
);
PRINT_TYPE
(
type2
);
PRINT_TYPE
(
dtype
);
PRINT_PARAM
(
size
);
PRINT_PARAM
(
alpha
);
PRINT_PARAM
(
beta
);
PRINT_PARAM
(
gamma
);
cv
::
Mat
dst
;
ASSERT_NO_THROW
(
cv
::
gpu
::
GpuMat
dev_dst
;
cv
::
gpu
::
addWeighted
(
cv
::
gpu
::
GpuMat
(
src1
),
alpha
,
cv
::
gpu
::
GpuMat
(
src2
),
beta
,
gamma
,
dev_dst
,
dtype
);
dev_dst
.
download
(
dst
);
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
dtype
<
CV_32F
?
1.0
:
1e-12
);
}
INSTANTIATE_TEST_CASE_P
(
Arithm
,
AddWeighted
,
testing
::
Combine
(
testing
::
ValuesIn
(
devices
()),
testing
::
ValuesIn
(
types
(
CV_8U
,
CV_64F
,
1
,
1
)),
testing
::
ValuesIn
(
types
(
CV_8U
,
CV_64F
,
1
,
1
)),
testing
::
ValuesIn
(
types
(
CV_8U
,
CV_64F
,
1
,
1
))));
#endif // HAVE_CUDA
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