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
2b52bb09
Commit
2b52bb09
authored
Oct 20, 2014
by
Chuanbo Weng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update hog.cpp
Update according to vbystricky's comments
parent
7452eef6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
20 deletions
+6
-20
hog.cpp
samples/tapi/hog.cpp
+6
-20
No files found.
samples/tapi/hog.cpp
View file @
2b52bb09
...
...
@@ -44,8 +44,6 @@ private:
//Args args;
bool
running
;
bool
make_gray
;
bool
use_ocl
;
bool
ocl_switch
;
double
scale
;
double
resize_scale
;
int
win_width
;
...
...
@@ -136,9 +134,6 @@ App::App(CommandLineParser& cmd)
gamma_corr
=
true
;
write_once
=
false
;
use_ocl
=
ocl
::
useOpenCL
();
ocl_switch
=
true
;
cout
<<
"Group threshold: "
<<
gr_threshold
<<
endl
;
cout
<<
"Levels number: "
<<
nlevels
<<
endl
;
cout
<<
"Win width: "
<<
win_width
<<
endl
;
...
...
@@ -160,6 +155,7 @@ void App::run()
HOGDescriptor
hog
(
win_size
,
Size
(
16
,
16
),
Size
(
8
,
8
),
Size
(
8
,
8
),
9
,
1
,
-
1
,
HOGDescriptor
::
L2Hys
,
0.2
,
gamma_corr
,
cv
::
HOGDescriptor
::
DEFAULT_NLEVELS
);
hog
.
setSVMDetector
(
HOGDescriptor
::
getDaimlerPeopleDetector
()
);
while
(
running
)
{
...
...
@@ -191,17 +187,13 @@ void App::run()
throw
runtime_error
(
string
(
"can't open image file: "
+
img_source
));
}
UMat
img_aux
,
img
;
Mat
img_to_show
;
// Iterate over all frames
while
(
running
&&
!
frame
.
empty
())
{
workBegin
();
if
(
ocl_switch
){
hog
.
setSVMDetector
(
HOGDescriptor
::
getDaimlerPeopleDetector
()
);
ocl_switch
=
false
;
}
UMat
img_aux
,
img
;
// Change format of the image
if
(
make_gray
)
cvtColor
(
frame
,
img_aux
,
COLOR_BGR2GRAY
);
...
...
@@ -221,12 +213,8 @@ void App::run()
// Perform HOG classification
hogWorkBegin
();
if
(
use_ocl
)
hog
.
detectMultiScale
(
img
,
found
,
hit_threshold
,
win_stride
,
Size
(
0
,
0
),
scale
,
gr_threshold
);
else
hog
.
detectMultiScale
(
img
.
getMat
(
ACCESS_READ
),
found
,
hit_threshold
,
win_stride
,
Size
(
0
,
0
),
scale
,
gr_threshold
);
hog
.
detectMultiScale
(
img
,
found
,
hit_threshold
,
win_stride
,
Size
(
0
,
0
),
scale
,
gr_threshold
);
hogWorkEnd
();
...
...
@@ -237,7 +225,7 @@ void App::run()
rectangle
(
img_to_show
,
r
.
tl
(),
r
.
br
(),
Scalar
(
0
,
255
,
0
),
3
);
}
putText
(
img_to_show
,
use_ocl
?
"Mode: OpenCL"
:
"Mode: CPU"
,
Point
(
5
,
25
),
FONT_HERSHEY_SIMPLEX
,
1.
,
Scalar
(
255
,
100
,
0
),
2
);
putText
(
img_to_show
,
ocl
::
useOpenCL
()
?
"Mode: OpenCL"
:
"Mode: CPU"
,
Point
(
5
,
25
),
FONT_HERSHEY_SIMPLEX
,
1.
,
Scalar
(
255
,
100
,
0
),
2
);
putText
(
img_to_show
,
"FPS (HOG only): "
+
hogWorkFps
(),
Point
(
5
,
65
),
FONT_HERSHEY_SIMPLEX
,
1.
,
Scalar
(
255
,
100
,
0
),
2
);
putText
(
img_to_show
,
"FPS (total): "
+
workFps
(),
Point
(
5
,
105
),
FONT_HERSHEY_SIMPLEX
,
1.
,
Scalar
(
255
,
100
,
0
),
2
);
imshow
(
"opencv_hog"
,
img_to_show
);
...
...
@@ -284,9 +272,7 @@ void App::handleKey(char key)
case
'm'
:
case
'M'
:
ocl
::
setUseOpenCL
(
!
cv
::
ocl
::
useOpenCL
());
ocl_switch
=
true
;
use_ocl
=
ocl
::
useOpenCL
();
cout
<<
"Switched to "
<<
(
use_ocl
?
"OpenCL enabled"
:
"CPU"
)
<<
" mode
\n
"
;
cout
<<
"Switched to "
<<
(
ocl
::
useOpenCL
()
?
"OpenCL enabled"
:
"CPU"
)
<<
" mode
\n
"
;
break
;
case
'g'
:
case
'G'
:
...
...
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