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
fad96b95
Commit
fad96b95
authored
May 24, 2013
by
yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add results verification to facedetect and hog samples
parent
036b0579
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
2 deletions
+62
-2
facedetect.cpp
samples/ocl/facedetect.cpp
+0
-0
hog.cpp
samples/ocl/hog.cpp
+62
-2
No files found.
samples/ocl/facedetect.cpp
View file @
fad96b95
This diff is collapsed.
Click to expand it.
samples/ocl/hog.cpp
View file @
fad96b95
...
...
@@ -45,7 +45,6 @@ public:
bool
gamma_corr
;
};
class
App
{
public
:
...
...
@@ -64,6 +63,13 @@ public:
string
message
()
const
;
// 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 if will return
// (total diff of each cpu and gpu rects covered pixels)/(total cpu rects covered pixels)
double
checkRectSimilarity
(
Size
sz
,
std
::
vector
<
Rect
>&
cpu_rst
,
std
::
vector
<
Rect
>&
gpu_rst
);
private
:
App
operator
=
(
App
&
);
...
...
@@ -290,6 +296,7 @@ void App::run()
ocl
::
oclMat
gpu_img
;
// Iterate over all frames
bool
verify
=
false
;
while
(
running
&&
!
frame
.
empty
())
{
workBegin
();
...
...
@@ -316,7 +323,18 @@ void App::run()
gpu_img
.
upload
(
img
);
gpu_hog
.
detectMultiScale
(
gpu_img
,
found
,
hit_threshold
,
win_stride
,
Size
(
0
,
0
),
scale
,
gr_threshold
);
}
if
(
!
verify
)
{
// verify if GPU output same objects with CPU at 1st run
verify
=
true
;
vector
<
Rect
>
ref_rst
;
cvtColor
(
img
,
img
,
CV_BGRA2BGR
);
cpu_hog
.
detectMultiScale
(
img
,
ref_rst
,
hit_threshold
,
win_stride
,
Size
(
0
,
0
),
scale
,
gr_threshold
-
2
);
double
accuracy
=
checkRectSimilarity
(
img
.
size
(),
ref_rst
,
found
);
cout
<<
"
\n
accuracy value: "
<<
accuracy
<<
endl
;
}
}
else
cpu_hog
.
detectMultiScale
(
img
,
found
,
hit_threshold
,
win_stride
,
Size
(
0
,
0
),
scale
,
gr_threshold
);
hogWorkEnd
();
...
...
@@ -457,3 +475,45 @@ inline string App::workFps() const
return
ss
.
str
();
}
double
App
::
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
{
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
);
final_test_result
=
1.0
-
(
double
)
result
/
(
double
)
cpu_area
;
}
return
final_test_result
;
}
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