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
2c198f6c
Commit
2c198f6c
authored
Jun 19, 2013
by
yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revise accuracy and perf tests
parent
843094a0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
268 additions
and
516 deletions
+268
-516
main.cpp
modules/ocl/perf/main.cpp
+2
-0
perf_calib3d.cpp
modules/ocl/perf/perf_calib3d.cpp
+50
-42
perf_filters.cpp
modules/ocl/perf/perf_filters.cpp
+8
-8
perf_hog.cpp
modules/ocl/perf/perf_hog.cpp
+5
-71
perf_imgproc.cpp
modules/ocl/perf/perf_imgproc.cpp
+44
-2
perf_moments.cpp
modules/ocl/perf/perf_moments.cpp
+33
-30
precomp.cpp
modules/ocl/perf/precomp.cpp
+0
-14
test_haar.cpp
modules/ocl/test/test_haar.cpp
+0
-180
test_imgproc.cpp
modules/ocl/test/test_imgproc.cpp
+43
-3
test_objdetect.cpp
modules/ocl/test/test_objdetect.cpp
+0
-0
test_pyramids.cpp
modules/ocl/test/test_pyramids.cpp
+33
-11
test_pyrup.cpp
modules/ocl/test/test_pyrup.cpp
+0
-92
utility.cpp
modules/ocl/test/utility.cpp
+45
-57
utility.hpp
modules/ocl/test/utility.hpp
+5
-6
No files found.
modules/ocl/perf/main.cpp
View file @
2c198f6c
...
...
@@ -52,6 +52,8 @@ int main(int argc, const char *argv[])
cerr
<<
"no device found
\n
"
;
return
-
1
;
}
// set this to overwrite binary cache every time the test starts
ocl
::
setBinaryDiskCache
(
ocl
::
CACHE_UPDATE
);
int
devidx
=
0
;
...
...
modules/ocl/
test/test_columnsum
.cpp
→
modules/ocl/
perf/perf_calib3d
.cpp
View file @
2c198f6c
...
...
@@ -15,8 +15,8 @@
// Third party copyrights are property of their respective owners.
//
// @Authors
//
Chunpeng Zhang chunpe
ng@multicorewareinc.com
//
//
Fangfang Bai, fangfa
ng@multicorewareinc.com
//
Jin Ma, jin@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
...
...
@@ -31,7 +31,7 @@
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors
"as is"
and
// This software is provided by the copyright holders and contributors
as is
and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
...
...
@@ -45,50 +45,57 @@
//M*/
#include "precomp.hpp"
#include <iomanip>
///////////// StereoMatchBM ////////////////////////
PERFTEST
(
StereoMatchBM
)
{
Mat
left_image
=
imread
(
abspath
(
"aloeL.jpg"
),
cv
::
IMREAD_GRAYSCALE
);
Mat
right_image
=
imread
(
abspath
(
"aloeR.jpg"
),
cv
::
IMREAD_GRAYSCALE
);
Mat
disp
,
dst
;
ocl
::
oclMat
d_left
,
d_right
,
d_disp
;
int
n_disp
=
128
;
int
winSize
=
19
;
#ifdef HAVE_OPENCL
SUBTEST
<<
left_image
.
cols
<<
'x'
<<
left_image
.
rows
<<
"; aloeL.jpg ;"
<<
right_image
.
cols
<<
'x'
<<
right_image
.
rows
<<
"; aloeR.jpg "
;
PARAM_TEST_CASE
(
ColumnSum
,
cv
::
Size
)
{
cv
::
Size
size
;
cv
::
Mat
src
;
StereoBM
bm
(
0
,
n_disp
,
winSize
);
bm
(
left_image
,
right_image
,
dst
);
virtual
void
SetUp
()
{
size
=
GET_PARAM
(
0
);
}
};
CPU_ON
;
bm
(
left_image
,
right_image
,
dst
);
CPU_OFF
;
TEST_P
(
ColumnSum
,
Accuracy
)
{
cv
::
Mat
src
=
randomMat
(
size
,
CV_32FC1
);
cv
::
ocl
::
oclMat
d_dst
;
cv
::
ocl
::
oclMat
d_src
(
src
);
cv
::
ocl
::
columnSum
(
d_src
,
d_dst
);
cv
::
Mat
dst
(
d_dst
);
for
(
int
j
=
0
;
j
<
src
.
cols
;
++
j
)
{
float
gold
=
src
.
at
<
float
>
(
0
,
j
);
float
res
=
dst
.
at
<
float
>
(
0
,
j
);
ASSERT_NEAR
(
res
,
gold
,
1e-5
);
}
for
(
int
i
=
1
;
i
<
src
.
rows
;
++
i
)
{
for
(
int
j
=
0
;
j
<
src
.
cols
;
++
j
)
{
float
gold
=
src
.
at
<
float
>
(
i
,
j
)
+=
src
.
at
<
float
>
(
i
-
1
,
j
);
float
res
=
dst
.
at
<
float
>
(
i
,
j
);
ASSERT_NEAR
(
res
,
gold
,
1e-5
);
}
}
d_left
.
upload
(
left_image
);
d_right
.
upload
(
right_image
);
ocl
::
StereoBM_OCL
d_bm
(
0
,
n_disp
,
winSize
);
WARMUP_ON
;
d_bm
(
d_left
,
d_right
,
d_disp
);
WARMUP_OFF
;
cv
::
Mat
ocl_mat
;
d_disp
.
download
(
ocl_mat
);
ocl_mat
.
convertTo
(
ocl_mat
,
dst
.
type
());
GPU_ON
;
d_bm
(
d_left
,
d_right
,
d_disp
);
GPU_OFF
;
GPU_FULL_ON
;
d_left
.
upload
(
left_image
);
d_right
.
upload
(
right_image
);
d_bm
(
d_left
,
d_right
,
d_disp
);
d_disp
.
download
(
disp
);
GPU_FULL_OFF
;
TestSystem
::
instance
().
setAccurate
(
-
1
,
0.
);
}
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
ColumnSum
,
DIFFERENT_SIZES
);
#endif
\ No newline at end of file
modules/ocl/perf/perf_filters.cpp
View file @
2c198f6c
...
...
@@ -284,6 +284,7 @@ PERFTEST(GaussianBlur)
Mat
src
,
dst
,
ocl_dst
;
int
all_type
[]
=
{
CV_8UC1
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
};
std
::
string
type_name
[]
=
{
"CV_8UC1"
,
"CV_8UC4"
,
"CV_32FC1"
,
"CV_32FC4"
};
const
int
ksize
=
7
;
for
(
int
size
=
Min_Size
;
size
<=
Max_Size
;
size
*=
Multiple
)
{
...
...
@@ -291,29 +292,28 @@ PERFTEST(GaussianBlur)
{
SUBTEST
<<
size
<<
'x'
<<
size
<<
"; "
<<
type_name
[
j
]
;
gen
(
src
,
size
,
size
,
all_type
[
j
],
5
,
1
6
);
gen
(
src
,
size
,
size
,
all_type
[
j
],
0
,
25
6
);
GaussianBlur
(
src
,
dst
,
Size
(
9
,
9
),
0
);
GaussianBlur
(
src
,
dst
,
Size
(
ksize
,
ksize
),
0
);
CPU_ON
;
GaussianBlur
(
src
,
dst
,
Size
(
9
,
9
),
0
);
GaussianBlur
(
src
,
dst
,
Size
(
ksize
,
ksize
),
0
);
CPU_OFF
;
ocl
::
oclMat
d_src
(
src
);
ocl
::
oclMat
d_dst
(
src
.
size
(),
src
.
type
());
ocl
::
oclMat
d_buf
;
ocl
::
oclMat
d_dst
;
WARMUP_ON
;
ocl
::
GaussianBlur
(
d_src
,
d_dst
,
Size
(
9
,
9
),
0
);
ocl
::
GaussianBlur
(
d_src
,
d_dst
,
Size
(
ksize
,
ksize
),
0
);
WARMUP_OFF
;
GPU_ON
;
ocl
::
GaussianBlur
(
d_src
,
d_dst
,
Size
(
9
,
9
),
0
);
ocl
::
GaussianBlur
(
d_src
,
d_dst
,
Size
(
ksize
,
ksize
),
0
);
GPU_OFF
;
GPU_FULL_ON
;
d_src
.
upload
(
src
);
ocl
::
GaussianBlur
(
d_src
,
d_dst
,
Size
(
9
,
9
),
0
);
ocl
::
GaussianBlur
(
d_src
,
d_dst
,
Size
(
ksize
,
ksize
),
0
);
d_dst
.
download
(
ocl_dst
);
GPU_FULL_OFF
;
...
...
modules/ocl/perf/perf_hog.cpp
View file @
2c198f6c
...
...
@@ -46,11 +46,6 @@
#include "precomp.hpp"
///////////// HOG////////////////////////
bool
match_rect
(
cv
::
Rect
r1
,
cv
::
Rect
r2
,
int
threshold
)
{
return
((
abs
(
r1
.
x
-
r2
.
x
)
<
threshold
)
&&
(
abs
(
r1
.
y
-
r2
.
y
)
<
threshold
)
&&
(
abs
(
r1
.
width
-
r2
.
width
)
<
threshold
)
&&
(
abs
(
r1
.
height
-
r2
.
height
)
<
threshold
));
}
PERFTEST
(
HOG
)
{
...
...
@@ -61,13 +56,12 @@ PERFTEST(HOG)
throw
runtime_error
(
"can't open road.png"
);
}
cv
::
HOGDescriptor
hog
;
hog
.
setSVMDetector
(
hog
.
getDefaultPeopleDetector
());
std
::
vector
<
cv
::
Rect
>
found_locations
;
std
::
vector
<
cv
::
Rect
>
d_found_locations
;
SUBTEST
<<
768
<<
'x'
<<
576
<<
"; road.png"
;
SUBTEST
<<
src
.
cols
<<
'x'
<<
src
.
rows
<<
"; road.png"
;
hog
.
detectMultiScale
(
src
,
found_locations
);
...
...
@@ -84,70 +78,10 @@ PERFTEST(HOG)
ocl_hog
.
detectMultiScale
(
d_src
,
d_found_locations
);
WARMUP_OFF
;
// Ground-truth rectangular people window
cv
::
Rect
win1_64x128
(
231
,
190
,
72
,
144
);
cv
::
Rect
win2_64x128
(
621
,
156
,
97
,
194
);
cv
::
Rect
win1_48x96
(
238
,
198
,
63
,
126
);
cv
::
Rect
win2_48x96
(
619
,
161
,
92
,
185
);
cv
::
Rect
win3_48x96
(
488
,
136
,
56
,
112
);
// Compare whether ground-truth windows are detected and compare the number of windows detected.
std
::
vector
<
int
>
d_comp
(
4
);
std
::
vector
<
int
>
comp
(
4
);
for
(
int
i
=
0
;
i
<
(
int
)
d_comp
.
size
();
i
++
)
{
d_comp
[
i
]
=
0
;
comp
[
i
]
=
0
;
}
int
threshold
=
10
;
int
val
=
32
;
d_comp
[
0
]
=
(
int
)
d_found_locations
.
size
();
comp
[
0
]
=
(
int
)
found_locations
.
size
();
cv
::
Size
winSize
=
hog
.
winSize
;
if
(
winSize
==
cv
::
Size
(
48
,
96
))
{
for
(
int
i
=
0
;
i
<
(
int
)
d_found_locations
.
size
();
i
++
)
{
if
(
match_rect
(
d_found_locations
[
i
],
win1_48x96
,
threshold
))
d_comp
[
1
]
=
val
;
if
(
match_rect
(
d_found_locations
[
i
],
win2_48x96
,
threshold
))
d_comp
[
2
]
=
val
;
if
(
match_rect
(
d_found_locations
[
i
],
win3_48x96
,
threshold
))
d_comp
[
3
]
=
val
;
}
for
(
int
i
=
0
;
i
<
(
int
)
found_locations
.
size
();
i
++
)
{
if
(
match_rect
(
found_locations
[
i
],
win1_48x96
,
threshold
))
comp
[
1
]
=
val
;
if
(
match_rect
(
found_locations
[
i
],
win2_48x96
,
threshold
))
comp
[
2
]
=
val
;
if
(
match_rect
(
found_locations
[
i
],
win3_48x96
,
threshold
))
comp
[
3
]
=
val
;
}
}
else
if
(
winSize
==
cv
::
Size
(
64
,
128
))
{
for
(
int
i
=
0
;
i
<
(
int
)
d_found_locations
.
size
();
i
++
)
{
if
(
match_rect
(
d_found_locations
[
i
],
win1_64x128
,
threshold
))
d_comp
[
1
]
=
val
;
if
(
match_rect
(
d_found_locations
[
i
],
win2_64x128
,
threshold
))
d_comp
[
2
]
=
val
;
}
for
(
int
i
=
0
;
i
<
(
int
)
found_locations
.
size
();
i
++
)
{
if
(
match_rect
(
found_locations
[
i
],
win1_64x128
,
threshold
))
comp
[
1
]
=
val
;
if
(
match_rect
(
found_locations
[
i
],
win2_64x128
,
threshold
))
comp
[
2
]
=
val
;
}
}
cv
::
Mat
gpu_rst
(
d_comp
),
cpu_rst
(
comp
);
TestSystem
::
instance
().
ExpectedMatNear
(
gpu_rst
,
cpu_rst
,
3
);
if
(
d_found_locations
.
size
()
==
found_locations
.
size
())
TestSystem
::
instance
().
setAccurate
(
1
,
0
);
else
TestSystem
::
instance
().
setAccurate
(
0
,
abs
((
int
)
found_locations
.
size
()
-
(
int
)
d_found_locations
.
size
()));
GPU_ON
;
ocl_hog
.
detectMultiScale
(
d_src
,
found_locations
);
...
...
modules/ocl/perf/perf_imgproc.cpp
View file @
2c198f6c
...
...
@@ -743,12 +743,12 @@ PERFTEST(meanShiftFiltering)
WARMUP_OFF
;
GPU_ON
;
ocl
::
meanShiftFiltering
(
d_src
,
d_dst
,
sp
,
sr
);
ocl
::
meanShiftFiltering
(
d_src
,
d_dst
,
sp
,
sr
,
crit
);
GPU_OFF
;
GPU_FULL_ON
;
d_src
.
upload
(
src
);
ocl
::
meanShiftFiltering
(
d_src
,
d_dst
,
sp
,
sr
);
ocl
::
meanShiftFiltering
(
d_src
,
d_dst
,
sp
,
sr
,
crit
);
d_dst
.
download
(
ocl_dst
);
GPU_FULL_OFF
;
...
...
@@ -969,3 +969,45 @@ PERFTEST(CLAHE)
}
}
}
///////////// columnSum////////////////////////
PERFTEST
(
columnSum
)
{
Mat
src
,
dst
,
ocl_dst
;
ocl
::
oclMat
d_src
,
d_dst
;
for
(
int
size
=
Min_Size
;
size
<=
Max_Size
;
size
*=
Multiple
)
{
SUBTEST
<<
size
<<
'x'
<<
size
<<
"; CV_32FC1"
;
gen
(
src
,
size
,
size
,
CV_32FC1
,
0
,
256
);
CPU_ON
;
dst
.
create
(
src
.
size
(),
src
.
type
());
for
(
int
j
=
0
;
j
<
src
.
cols
;
j
++
)
dst
.
at
<
float
>
(
0
,
j
)
=
src
.
at
<
float
>
(
0
,
j
);
for
(
int
i
=
1
;
i
<
src
.
rows
;
++
i
)
for
(
int
j
=
0
;
j
<
src
.
cols
;
++
j
)
dst
.
at
<
float
>
(
i
,
j
)
=
dst
.
at
<
float
>
(
i
-
1
,
j
)
+
src
.
at
<
float
>
(
i
,
j
);
CPU_OFF
;
d_src
.
upload
(
src
);
WARMUP_ON
;
ocl
::
columnSum
(
d_src
,
d_dst
);
WARMUP_OFF
;
GPU_ON
;
ocl
::
columnSum
(
d_src
,
d_dst
);
GPU_OFF
;
GPU_FULL_ON
;
d_src
.
upload
(
src
);
ocl
::
columnSum
(
d_src
,
d_dst
);
d_dst
.
download
(
ocl_dst
);
GPU_FULL_OFF
;
TestSystem
::
instance
().
ExpectedMatNear
(
dst
,
ocl_dst
,
5e-1
);
}
}
modules/ocl/perf/perf_
columnsum
.cpp
→
modules/ocl/perf/perf_
moments
.cpp
View file @
2c198f6c
...
...
@@ -44,45 +44,49 @@
//
//M*/
#include "precomp.hpp"
///////////// columnSum////////////////////////
PERFTEST
(
columnSum
)
///////////// Moments ////////////////////////
PERFTEST
(
Moments
)
{
Mat
src
,
dst
,
ocl_dst
;
ocl
::
oclMat
d_src
,
d_dst
;
Mat
src
;
bool
binaryImage
=
0
;
int
all_type
[]
=
{
CV_8UC1
,
CV_16SC1
,
CV_32FC1
,
CV_64FC1
};
std
::
string
type_name
[]
=
{
"CV_8UC1"
,
"CV_16SC1"
,
"CV_32FC1"
,
"CV_64FC1"
};
for
(
int
size
=
Min_Size
;
size
<=
Max_Size
;
size
*=
Multiple
)
{
SUBTEST
<<
size
<<
'x'
<<
size
<<
"; CV_32FC1"
;
for
(
size_t
j
=
0
;
j
<
sizeof
(
all_type
)
/
sizeof
(
int
);
j
++
)
{
SUBTEST
<<
size
<<
'x'
<<
size
<<
"; "
<<
type_name
[
j
];
gen
(
src
,
size
,
size
,
all_type
[
j
],
0
,
256
);
cv
::
Moments
CvMom
=
moments
(
src
,
binaryImage
);
gen
(
src
,
size
,
size
,
CV_32FC1
,
0
,
256
);
CPU_ON
;
moments
(
src
,
binaryImage
);
CPU_OFF
;
CPU_ON
;
dst
.
create
(
src
.
size
(),
src
.
type
())
;
for
(
int
j
=
0
;
j
<
src
.
cols
;
j
++
)
dst
.
at
<
float
>
(
0
,
j
)
=
src
.
at
<
float
>
(
0
,
j
)
;
cv
::
Moments
oclMom
;
WARMUP_ON
;
oclMom
=
ocl
::
ocl_moments
(
src
,
binaryImage
);
WARMUP_OFF
;
for
(
int
i
=
1
;
i
<
src
.
rows
;
++
i
)
for
(
int
j
=
0
;
j
<
src
.
cols
;
++
j
)
dst
.
at
<
float
>
(
i
,
j
)
=
dst
.
at
<
float
>
(
i
-
1
,
j
)
+
src
.
at
<
float
>
(
i
,
j
);
CPU_OFF
;
Mat
gpu_dst
,
cpu_dst
;
HuMoments
(
CvMom
,
cpu_dst
);
HuMoments
(
oclMom
,
gpu_dst
);
d_src
.
upload
(
src
);
GPU_ON
;
ocl
::
ocl_moments
(
src
,
binaryImage
);
GPU_OFF
;
WARMUP
_ON
;
ocl
::
columnSum
(
d_src
,
d_dst
);
WARMUP
_OFF
;
GPU_FULL
_ON
;
ocl
::
ocl_moments
(
src
,
binaryImage
);
GPU_FULL
_OFF
;
GPU_ON
;
ocl
::
columnSum
(
d_src
,
d_dst
);
GPU_OFF
;
TestSystem
::
instance
().
ExpectedMatNear
(
gpu_dst
,
cpu_dst
,
.5
);
GPU_FULL_ON
;
d_src
.
upload
(
src
);
ocl
::
columnSum
(
d_src
,
d_dst
);
d_dst
.
download
(
ocl_dst
);
GPU_FULL_OFF
;
}
TestSystem
::
instance
().
ExpectedMatNear
(
dst
,
ocl_dst
,
5e-1
);
}
}
\ No newline at end of file
}
modules/ocl/perf/precomp.cpp
View file @
2c198f6c
...
...
@@ -331,20 +331,6 @@ void TestSystem::printMetrics(int is_accurate, double cpu_time, double gpu_time,
cout
<<
setiosflags
(
ios_base
::
left
);
stringstream
stream
;
#if 0
if(is_accurate == 1)
stream << "Pass";
else if(is_accurate_ == 0)
stream << "Fail";
else if(is_accurate == -1)
stream << " ";
else
{
std::cout<<"is_accurate errer: "<<is_accurate<<"\n";
exit(-1);
}
#endif
std
::
stringstream
&
cur_subtest_description
=
getCurSubtestDescription
();
#if GTEST_OS_WINDOWS&&!GTEST_OS_WINDOWS_MOBILE
...
...
modules/ocl/test/test_haar.cpp
deleted
100644 → 0
View file @
843094a0
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Jia Haipeng, jiahaipeng95@gmail.com
// Sen Liu, swjutls1987@126.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other oclMaterials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "opencv2/objdetect/objdetect.hpp"
#include "precomp.hpp"
#ifdef HAVE_OPENCL
using
namespace
cvtest
;
using
namespace
testing
;
using
namespace
std
;
using
namespace
cv
;
extern
string
workdir
;
namespace
{
IMPLEMENT_PARAM_CLASS
(
CascadeName
,
std
::
string
);
CascadeName
cascade_frontalface_alt
(
std
::
string
(
"haarcascade_frontalface_alt.xml"
));
CascadeName
cascade_frontalface_alt2
(
std
::
string
(
"haarcascade_frontalface_alt2.xml"
));
struct
getRect
{
Rect
operator
()(
const
CvAvgComp
&
e
)
const
{
return
e
.
rect
;
}
};
}
PARAM_TEST_CASE
(
Haar
,
double
,
int
,
CascadeName
)
{
cv
::
ocl
::
OclCascadeClassifier
cascade
,
nestedCascade
;
cv
::
CascadeClassifier
cpucascade
,
cpunestedCascade
;
double
scale
;
int
flags
;
std
::
string
cascadeName
;
virtual
void
SetUp
()
{
scale
=
GET_PARAM
(
0
);
flags
=
GET_PARAM
(
1
);
cascadeName
=
(
workdir
+
"../../data/haarcascades/"
).
append
(
GET_PARAM
(
2
));
if
(
(
!
cascade
.
load
(
cascadeName
))
||
(
!
cpucascade
.
load
(
cascadeName
))
)
{
cout
<<
"ERROR: Could not load classifier cascade"
<<
endl
;
return
;
}
}
};
////////////////////////////////faceDetect/////////////////////////////////////////////////
TEST_P
(
Haar
,
FaceDetect
)
{
string
imgName
=
workdir
+
"lena.jpg"
;
Mat
img
=
imread
(
imgName
,
1
);
if
(
img
.
empty
())
{
std
::
cout
<<
"Couldn't read "
<<
imgName
<<
std
::
endl
;
return
;
}
vector
<
Rect
>
faces
,
oclfaces
;
Mat
gray
,
smallImg
(
cvRound
(
img
.
rows
/
scale
),
cvRound
(
img
.
cols
/
scale
),
CV_8UC1
);
MemStorage
storage
(
cvCreateMemStorage
(
0
));
cvtColor
(
img
,
gray
,
CV_BGR2GRAY
);
resize
(
gray
,
smallImg
,
smallImg
.
size
(),
0
,
0
,
INTER_LINEAR
);
equalizeHist
(
smallImg
,
smallImg
);
cv
::
ocl
::
oclMat
image
;
CvSeq
*
_objects
;
image
.
upload
(
smallImg
);
_objects
=
cascade
.
oclHaarDetectObjects
(
image
,
storage
,
1.1
,
3
,
flags
,
Size
(
30
,
30
),
Size
(
0
,
0
)
);
vector
<
CvAvgComp
>
vecAvgComp
;
Seq
<
CvAvgComp
>
(
_objects
).
copyTo
(
vecAvgComp
);
oclfaces
.
resize
(
vecAvgComp
.
size
());
std
::
transform
(
vecAvgComp
.
begin
(),
vecAvgComp
.
end
(),
oclfaces
.
begin
(),
getRect
());
cpucascade
.
detectMultiScale
(
smallImg
,
faces
,
1.1
,
3
,
flags
,
Size
(
30
,
30
),
Size
(
0
,
0
)
);
EXPECT_EQ
(
faces
.
size
(),
oclfaces
.
size
());
}
TEST_P
(
Haar
,
FaceDetectUseBuf
)
{
string
imgName
=
workdir
+
"lena.jpg"
;
Mat
img
=
imread
(
imgName
,
1
);
if
(
img
.
empty
())
{
std
::
cout
<<
"Couldn't read "
<<
imgName
<<
std
::
endl
;
return
;
}
vector
<
Rect
>
faces
,
oclfaces
;
Mat
gray
,
smallImg
(
cvRound
(
img
.
rows
/
scale
),
cvRound
(
img
.
cols
/
scale
),
CV_8UC1
);
cvtColor
(
img
,
gray
,
CV_BGR2GRAY
);
resize
(
gray
,
smallImg
,
smallImg
.
size
(),
0
,
0
,
INTER_LINEAR
);
equalizeHist
(
smallImg
,
smallImg
);
cv
::
ocl
::
oclMat
image
;
image
.
upload
(
smallImg
);
cv
::
ocl
::
OclCascadeClassifierBuf
cascadebuf
;
if
(
!
cascadebuf
.
load
(
cascadeName
)
)
{
cout
<<
"ERROR: Could not load classifier cascade for FaceDetectUseBuf!"
<<
endl
;
return
;
}
cascadebuf
.
detectMultiScale
(
image
,
oclfaces
,
1.1
,
3
,
flags
,
Size
(
30
,
30
),
Size
(
0
,
0
)
);
cpucascade
.
detectMultiScale
(
smallImg
,
faces
,
1.1
,
3
,
flags
,
Size
(
30
,
30
),
Size
(
0
,
0
)
);
EXPECT_EQ
(
faces
.
size
(),
oclfaces
.
size
());
// intentionally run ocl facedetect again and check if it still works after the first run
cascadebuf
.
detectMultiScale
(
image
,
oclfaces
,
1.1
,
3
,
flags
,
Size
(
30
,
30
));
cascadebuf
.
release
();
EXPECT_EQ
(
faces
.
size
(),
oclfaces
.
size
());
}
INSTANTIATE_TEST_CASE_P
(
FaceDetect
,
Haar
,
Combine
(
Values
(
1.0
),
Values
(
CV_HAAR_SCALE_IMAGE
,
0
),
Values
(
cascade_frontalface_alt
,
cascade_frontalface_alt2
)));
#endif // HAVE_OPENCL
modules/ocl/test/test_imgproc.cpp
View file @
2c198f6c
...
...
@@ -1573,6 +1573,47 @@ TEST_P(Convolve, Mat)
}
}
//////////////////////////////// ColumnSum //////////////////////////////////////
PARAM_TEST_CASE
(
ColumnSum
,
cv
::
Size
)
{
cv
::
Size
size
;
cv
::
Mat
src
;
virtual
void
SetUp
()
{
size
=
GET_PARAM
(
0
);
}
};
TEST_P
(
ColumnSum
,
Accuracy
)
{
cv
::
Mat
src
=
randomMat
(
size
,
CV_32FC1
);
cv
::
ocl
::
oclMat
d_dst
;
cv
::
ocl
::
oclMat
d_src
(
src
);
cv
::
ocl
::
columnSum
(
d_src
,
d_dst
);
cv
::
Mat
dst
(
d_dst
);
for
(
int
j
=
0
;
j
<
src
.
cols
;
++
j
)
{
float
gold
=
src
.
at
<
float
>
(
0
,
j
);
float
res
=
dst
.
at
<
float
>
(
0
,
j
);
ASSERT_NEAR
(
res
,
gold
,
1e-5
);
}
for
(
int
i
=
1
;
i
<
src
.
rows
;
++
i
)
{
for
(
int
j
=
0
;
j
<
src
.
cols
;
++
j
)
{
float
gold
=
src
.
at
<
float
>
(
i
,
j
)
+=
src
.
at
<
float
>
(
i
-
1
,
j
);
float
res
=
dst
.
at
<
float
>
(
i
,
j
);
ASSERT_NEAR
(
res
,
gold
,
1e-5
);
}
}
}
/////////////////////////////////////////////////////////////////////////////////////
INSTANTIATE_TEST_CASE_P
(
ImgprocTestBase
,
equalizeHist
,
Combine
(
ONE_TYPE
(
CV_8UC1
),
NULL_TYPE
,
...
...
@@ -1688,7 +1729,6 @@ INSTANTIATE_TEST_CASE_P(ImgProc, CLAHE, Combine(
Values
(
cv
::
Size
(
128
,
128
),
cv
::
Size
(
113
,
113
),
cv
::
Size
(
1300
,
1300
)),
Values
(
0.0
,
40.0
)));
//INSTANTIATE_TEST_CASE_P(ConvolveTestBase, Convolve, Combine(
// Values(CV_32FC1, CV_32FC1),
// Values(false))); // Values(false) is the reserved parameter
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
ColumnSum
,
DIFFERENT_SIZES
);
#endif // HAVE_OPENCL
modules/ocl/test/test_
hog
.cpp
→
modules/ocl/test/test_
objdetect
.cpp
View file @
2c198f6c
This diff is collapsed.
Click to expand it.
modules/ocl/test/test_pyr
down
.cpp
→
modules/ocl/test/test_pyr
amids
.cpp
View file @
2c198f6c
...
...
@@ -15,7 +15,6 @@
// Third party copyrights are property of their respective owners.
//
// @Authors
// Dachuan Zhao, dachuan@multicorewareinc.com
// Yao Wang yao@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
...
...
@@ -56,11 +55,12 @@ using namespace cvtest;
using
namespace
testing
;
using
namespace
std
;
PARAM_TEST_CASE
(
Pyr
Down
,
MatType
,
int
)
PARAM_TEST_CASE
(
Pyr
Base
,
MatType
,
int
)
{
int
type
;
int
channels
;
Mat
dst_cpu
;
oclMat
gdst
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
...
...
@@ -69,19 +69,19 @@ PARAM_TEST_CASE(PyrDown, MatType, int)
};
/////////////////////// PyrDown //////////////////////////
struct
PyrDown
:
PyrBase
{};
TEST_P
(
PyrDown
,
Mat
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
cv
::
Size
size
(
MWIDTH
,
MHEIGHT
);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Mat
src
=
randomMat
(
rng
,
size
,
CV_MAKETYPE
(
type
,
channels
),
0
,
100
,
false
);
cv
::
ocl
::
oclMat
gsrc
(
src
),
gdst
;
cv
::
Mat
dst_cpu
;
cv
::
pyrDown
(
src
,
dst_cpu
);
cv
::
ocl
::
pyrDown
(
gsrc
,
gdst
);
Size
size
(
MWIDTH
,
MHEIGHT
);
Mat
src
=
randomMat
(
size
,
CV_MAKETYPE
(
type
,
channels
));
oclMat
gsrc
(
src
);
pyrDown
(
src
,
dst_cpu
);
pyrDown
(
gsrc
,
gdst
);
EXPECT_MAT_NEAR
(
dst_cpu
,
Mat
(
gdst
),
type
==
CV_32F
?
1e-4
f
:
1.0
f
);
}
...
...
@@ -90,5 +90,27 @@ TEST_P(PyrDown, Mat)
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
PyrDown
,
Combine
(
Values
(
CV_8U
,
CV_32F
),
Values
(
1
,
3
,
4
)));
/////////////////////// PyrUp //////////////////////////
struct
PyrUp
:
PyrBase
{};
TEST_P
(
PyrUp
,
Accuracy
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
Size
size
(
MWIDTH
,
MHEIGHT
);
Mat
src
=
randomMat
(
size
,
CV_MAKETYPE
(
type
,
channels
));
oclMat
gsrc
(
src
);
pyrUp
(
src
,
dst_cpu
);
pyrUp
(
gsrc
,
gdst
);
EXPECT_MAT_NEAR
(
dst_cpu
,
Mat
(
gdst
),
(
type
==
CV_32F
?
1e-4
f
:
1.0
));
}
}
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
PyrUp
,
testing
::
Combine
(
Values
(
CV_8U
,
CV_32F
),
Values
(
1
,
3
,
4
)));
#endif // HAVE_OPENCL
modules/ocl/test/test_pyrup.cpp
deleted
100644 → 0
View file @
843094a0
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Zhang Chunpeng chunpeng@multicorewareinc.com
// Yao Wang yao@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other oclMaterials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
#include "opencv2/core/core.hpp"
#ifdef HAVE_OPENCL
using
namespace
cv
;
using
namespace
cvtest
;
using
namespace
testing
;
using
namespace
std
;
PARAM_TEST_CASE
(
PyrUp
,
MatType
,
int
)
{
int
type
;
int
channels
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
channels
=
GET_PARAM
(
1
);
}
};
TEST_P
(
PyrUp
,
Accuracy
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
Size
size
(
MWIDTH
,
MHEIGHT
);
Mat
src
=
randomMat
(
size
,
CV_MAKETYPE
(
type
,
channels
));
Mat
dst_gold
;
pyrUp
(
src
,
dst_gold
);
ocl
::
oclMat
dst
;
ocl
::
oclMat
srcMat
(
src
);
ocl
::
pyrUp
(
srcMat
,
dst
);
EXPECT_MAT_NEAR
(
dst_gold
,
Mat
(
dst
),
(
type
==
CV_32F
?
1e-4
f
:
1.0
));
}
}
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
PyrUp
,
testing
::
Combine
(
Values
(
CV_8U
,
CV_32F
),
Values
(
1
,
3
,
4
)));
#endif // HAVE_OPENCL
\ No newline at end of file
modules/ocl/test/utility.cpp
View file @
2c198f6c
...
...
@@ -100,12 +100,6 @@ Mat randomMat(Size size, int type, double minVal, double maxVal)
return
randomMat
(
TS
::
ptr
()
->
get_rng
(),
size
,
type
,
minVal
,
maxVal
,
false
);
}
/*
void showDiff(InputArray gold_, InputArray actual_, double eps)
{
...
...
@@ -137,58 +131,7 @@ void showDiff(InputArray gold_, InputArray actual_, double eps)
}
*/
/*
bool supportFeature(const DeviceInfo& info, FeatureSet feature)
{
return TargetArchs::builtWith(feature) && info.supports(feature);
}
const vector<DeviceInfo>& devices()
{
static vector<DeviceInfo> devs;
static bool first = true;
if (first)
{
int deviceCount = getCudaEnabledDeviceCount();
devs.reserve(deviceCount);
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
if (info.isCompatible())
devs.push_back(info);
}
first = false;
}
return devs;
}
vector<DeviceInfo> devices(FeatureSet feature)
{
const vector<DeviceInfo>& d = devices();
vector<DeviceInfo> devs_filtered;
if (TargetArchs::builtWith(feature))
{
devs_filtered.reserve(d.size());
for (size_t i = 0, size = d.size(); i < size; ++i)
{
const DeviceInfo& info = d[i];
if (info.supports(feature))
devs_filtered.push_back(info);
}
}
return devs_filtered;
}
*/
vector
<
MatType
>
types
(
int
depth_start
,
int
depth_end
,
int
cn_start
,
int
cn_end
)
{
...
...
@@ -264,3 +207,48 @@ void PrintTo(const Inverse &inverse, std::ostream *os)
(
*
os
)
<<
"direct"
;
}
double
checkRectSimilarity
(
Size
sz
,
std
::
vector
<
Rect
>&
ob1
,
std
::
vector
<
Rect
>&
ob2
)
{
double
final_test_result
=
0.0
;
size_t
sz1
=
ob1
.
size
();
size_t
sz2
=
ob2
.
size
();
if
(
sz1
!=
sz2
)
{
return
sz1
>
sz2
?
(
double
)(
sz1
-
sz2
)
:
(
double
)(
sz2
-
sz1
);
}
else
{
if
(
sz1
==
0
&&
sz2
==
0
)
return
0
;
cv
::
Mat
cpu_result
(
sz
,
CV_8UC1
);
cpu_result
.
setTo
(
0
);
for
(
vector
<
Rect
>::
const_iterator
r
=
ob1
.
begin
();
r
!=
ob1
.
end
();
r
++
)
{
cv
::
Mat
cpu_result_roi
(
cpu_result
,
*
r
);
cpu_result_roi
.
setTo
(
1
);
cpu_result
.
copyTo
(
cpu_result
);
}
int
cpu_area
=
cv
::
countNonZero
(
cpu_result
>
0
);
cv
::
Mat
gpu_result
(
sz
,
CV_8UC1
);
gpu_result
.
setTo
(
0
);
for
(
vector
<
Rect
>::
const_iterator
r2
=
ob2
.
begin
();
r2
!=
ob2
.
end
();
r2
++
)
{
cv
::
Mat
gpu_result_roi
(
gpu_result
,
*
r2
);
gpu_result_roi
.
setTo
(
1
);
gpu_result
.
copyTo
(
gpu_result
);
}
cv
::
Mat
result_
;
multiply
(
cpu_result
,
gpu_result
,
result_
);
int
result
=
cv
::
countNonZero
(
result_
>
0
);
if
(
cpu_area
!=
0
&&
result
!=
0
)
final_test_result
=
1.0
-
(
double
)
result
/
(
double
)
cpu_area
;
else
if
(
cpu_area
==
0
&&
result
!=
0
)
final_test_result
=
-
1
;
}
return
final_test_result
;
}
modules/ocl/test/utility.hpp
View file @
2c198f6c
...
...
@@ -55,13 +55,12 @@ cv::Mat randomMat(cv::Size size, int type, double minVal = 0.0, double maxVal =
void
showDiff
(
cv
::
InputArray
gold
,
cv
::
InputArray
actual
,
double
eps
);
//! return true if device supports specified feature and gpu module was built with support the feature.
//bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature);
// This function test if gpu_rst matches cpu_rst.
// If the two vectors are not equal, it will return the difference in vector size
// Else it will return (total diff of each cpu and gpu rects covered pixels)/(total cpu rects covered pixels)
// The smaller, the better matched
double
checkRectSimilarity
(
cv
::
Size
sz
,
std
::
vector
<
cv
::
Rect
>&
ob1
,
std
::
vector
<
cv
::
Rect
>&
ob2
);
//! return all devices compatible with current gpu module build.
//const std::vector<cv::ocl::DeviceInfo>& devices();
//! return all devices compatible with current gpu module build which support specified feature.
//std::vector<cv::ocl::DeviceInfo> devices(cv::gpu::FeatureSet feature);
//! read image from testdata folder.
cv
::
Mat
readImage
(
const
std
::
string
&
fileName
,
int
flags
=
cv
::
IMREAD_COLOR
);
...
...
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