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
c3e4a52f
Commit
c3e4a52f
authored
Nov 14, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
soft cascade sample
parent
ee4f003e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
1 deletion
+110
-1
softcascade.cpp
modules/gpu/src/softcascade.cpp
+3
-1
softcascade.cpp
samples/gpu/softcascade.cpp
+107
-0
No files found.
modules/gpu/src/softcascade.cpp
View file @
c3e4a52f
...
...
@@ -287,7 +287,8 @@ struct cv::gpu::SCascade::Fields
bool
update
(
int
fh
,
int
fw
,
int
shr
)
{
if
(
fh
==
luv
.
rows
&&
fh
==
luv
.
cols
)
return
false
;
if
((
fh
==
luv
.
rows
)
&&
(
fw
==
luv
.
cols
))
return
false
;
plane
.
create
(
fh
*
(
HOG_LUV_BINS
+
1
),
fw
,
CV_8UC1
);
fplane
.
create
(
fh
*
HOG_BINS
,
fw
,
CV_32FC1
);
luv
.
create
(
fh
,
fw
,
CV_8UC3
);
...
...
@@ -297,6 +298,7 @@ struct cv::gpu::SCascade::Fields
hogluv
.
create
((
fh
/
shr
)
*
HOG_LUV_BINS
+
1
,
fw
/
shr
+
1
,
CV_32SC1
);
hogluv
.
setTo
(
cv
::
Scalar
::
all
(
0
));
return
true
;
}
...
...
samples/gpu/softcascade.cpp
0 → 100644
View file @
c3e4a52f
#include <opencv2/gpu/gpu.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
int
main
(
int
argc
,
char
**
argv
)
{
const
std
::
string
keys
=
"{help h usage ? | | print this message }"
"{cascade c | | path to configuration xml }"
"{frames f | | path to configuration xml }"
"{min_scale |0.4f | path to configuration xml }"
"{max_scale |5.0f | path to configuration xml }"
"{total_scales |55 | path to configuration xml }"
"{device d |0 | path to configuration xml }"
;
cv
::
CommandLineParser
parser
(
argc
,
argv
,
keys
);
parser
.
about
(
"Soft cascade training application."
);
if
(
parser
.
has
(
"help"
))
{
parser
.
printMessage
();
return
0
;
}
if
(
!
parser
.
check
())
{
parser
.
printErrors
();
return
1
;
}
cv
::
gpu
::
setDevice
(
parser
.
get
<
int
>
(
"device"
));
std
::
string
cascadePath
=
parser
.
get
<
std
::
string
>
(
"cascade"
);
cv
::
FileStorage
fs
(
cascadePath
,
cv
::
FileStorage
::
READ
);
if
(
!
fs
.
isOpened
())
{
std
::
cout
<<
"Soft Cascade file "
<<
cascadePath
<<
" can't be opened."
<<
std
::
endl
<<
std
::
flush
;
return
1
;
}
std
::
cout
<<
"Read cascade from file "
<<
cascadePath
<<
std
::
endl
;
float
minScale
=
parser
.
get
<
float
>
(
"min_scale"
);
float
maxScale
=
parser
.
get
<
float
>
(
"max_scale"
);
int
scales
=
parser
.
get
<
int
>
(
"total_scales"
);
using
cv
::
gpu
::
SCascade
;
SCascade
cascade
(
minScale
,
maxScale
,
scales
);
if
(
!
cascade
.
load
(
fs
.
getFirstTopLevelNode
()))
{
std
::
cout
<<
"Soft Cascade can't be parsed."
<<
std
::
endl
<<
std
::
flush
;
return
1
;
}
std
::
string
frames
=
parser
.
get
<
std
::
string
>
(
"frames"
);
cv
::
VideoCapture
capture
(
frames
);
if
(
!
capture
.
isOpened
())
{
std
::
cout
<<
"Frame source "
<<
frames
<<
" can't be opened."
<<
std
::
endl
<<
std
::
flush
;
return
1
;
}
cv
::
gpu
::
GpuMat
objects
(
1
,
sizeof
(
SCascade
::
Detection
)
*
10000
,
CV_8UC1
);
cv
::
gpu
::
printShortCudaDeviceInfo
(
parser
.
get
<
int
>
(
"device"
));
for
(;;)
{
cv
::
Mat
frame
;
if
(
!
capture
.
read
(
frame
))
{
std
::
cout
<<
"Nothing to read. "
<<
std
::
endl
<<
std
::
flush
;
return
0
;
}
cv
::
gpu
::
GpuMat
dframe
(
frame
),
roi
(
frame
.
rows
,
frame
.
cols
,
CV_8UC1
),
trois
;
roi
.
setTo
(
cv
::
Scalar
::
all
(
1
));
cascade
.
genRoi
(
roi
,
trois
);
cascade
.
detect
(
dframe
,
trois
,
objects
);
cv
::
Mat
dt
(
objects
);
typedef
cv
::
gpu
::
SCascade
::
Detection
Detection
;
Detection
*
dts
=
((
Detection
*
)
dt
.
data
)
+
1
;
int
*
count
=
dt
.
ptr
<
int
>
(
0
);
std
::
cout
<<
*
count
<<
std
::
endl
;
cv
::
Mat
result
;
frame
.
copyTo
(
result
);
for
(
int
i
=
0
;
i
<
*
count
;
++
i
)
{
Detection
d
=
dts
[
i
];
cv
::
rectangle
(
result
,
cv
::
Rect
(
d
.
x
,
d
.
y
,
d
.
w
,
d
.
h
),
cv
::
Scalar
(
255
,
0
,
0
,
255
),
1
);
}
std
::
cout
<<
"working..."
<<
std
::
endl
;
cv
::
imshow
(
"Soft Cascade demo"
,
result
);
cv
::
waitKey
(
10
);
}
return
0
;
}
\ No newline at end of file
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