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
72e2b8b3
Commit
72e2b8b3
authored
Nov 14, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove size constraints of input frame
parent
08910e81
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
44 deletions
+55
-44
isf-sc.cu
modules/gpu/src/cuda/isf-sc.cu
+2
-2
softcascade.cpp
modules/gpu/src/softcascade.cpp
+53
-42
No files found.
modules/gpu/src/cuda/isf-sc.cu
View file @
72e2b8b3
...
...
@@ -256,8 +256,8 @@ template<typename Policy>
void CascadeInvoker<Policy>::operator()(const PtrStepSzb& roi, const PtrStepSzi& hogluv,
PtrStepSz<uchar4> objects, PtrStepSzi counter, const int downscales, const int scale, const cudaStream_t& stream) const
{
int fw =
160
;
int fh =
120
;
int fw =
roi.rows
;
int fh =
roi.cols
;
dim3 grid(fw, fh / Policy::STA_Y, (scale == -1) ? downscales : 1);
...
...
modules/gpu/src/softcascade.cpp
View file @
72e2b8b3
...
...
@@ -240,15 +240,26 @@ struct cv::gpu::SCascade::Fields
cv
::
Mat
hleaves
(
cv
::
Mat
(
vleaves
).
reshape
(
1
,
1
));
CV_Assert
(
!
hleaves
.
empty
());
Fields
*
fields
=
new
Fields
(
mins
,
maxs
,
totals
,
origWidth
,
origHeight
,
shrinkage
,
0
,
hoctaves
,
hstages
,
hnodes
,
hleaves
);
fields
->
voctaves
=
voctaves
;
fields
->
createLevels
(
FRAME_HEIGHT
,
FRAME_WIDTH
);
return
fields
;
}
int
createLevels
(
const
int
fh
,
const
int
fw
)
{
using
namespace
device
::
icf
;
std
::
vector
<
Level
>
vlevels
;
float
logFactor
=
(
::
log
(
max
s
)
-
::
log
(
mins
))
/
(
totals
-
1
);
float
logFactor
=
(
::
log
(
max
Scale
)
-
::
log
(
minScale
))
/
(
totals
-
1
);
float
scale
=
min
s
;
int
d
ownscale
s
=
0
;
float
scale
=
min
Scale
;
int
d
c
s
=
0
;
for
(
int
sc
=
0
;
sc
<
totals
;
++
sc
)
{
int
width
=
::
std
::
max
(
0.0
f
,
FRAME_WIDTH
-
(
orig
Width
*
scale
));
int
height
=
::
std
::
max
(
0.0
f
,
FRAME_HEIGHT
-
(
orig
Height
*
scale
));
int
width
=
::
std
::
max
(
0.0
f
,
fw
-
(
origObj
Width
*
scale
));
int
height
=
::
std
::
max
(
0.0
f
,
fh
-
(
origObj
Height
*
scale
));
float
logScale
=
::
log
(
scale
);
int
fit
=
fitOctave
(
voctaves
,
logScale
);
...
...
@@ -260,44 +271,44 @@ struct cv::gpu::SCascade::Fields
else
{
vlevels
.
push_back
(
level
);
if
(
voctaves
[
fit
].
scale
<
1
)
++
d
ownscale
s
;
if
(
voctaves
[
fit
].
scale
<
1
)
++
d
c
s
;
}
if
(
::
fabs
(
scale
-
max
s
)
<
FLT_EPSILON
)
break
;
scale
=
::
std
::
min
(
max
s
,
::
expf
(
::
log
(
scale
)
+
logFactor
));
if
(
::
fabs
(
scale
-
max
Scale
)
<
FLT_EPSILON
)
break
;
scale
=
::
std
::
min
(
max
Scale
,
::
expf
(
::
log
(
scale
)
+
logFactor
));
}
cv
::
Mat
hlevels
(
1
,
vlevels
.
size
()
*
sizeof
(
Level
),
CV_8UC1
,
(
uchar
*
)
&
(
vlevels
[
0
])
);
cv
::
Mat
hlevels
=
cv
::
Mat
(
1
,
vlevels
.
size
()
*
sizeof
(
Level
),
CV_8UC1
,
(
uchar
*
)
&
(
vlevels
[
0
])
);
CV_Assert
(
!
hlevels
.
empty
());
Fields
*
fields
=
new
Fields
(
mins
,
maxs
,
origWidth
,
origHeight
,
shrinkage
,
downscales
,
hoctaves
,
hstages
,
hnodes
,
hleaves
,
hlevels
);
return
fields
;
levels
.
upload
(
hlevels
);
downscales
=
dcs
;
return
dcs
;
}
Fields
(
const
float
mins
,
const
float
maxs
,
const
int
ow
,
const
int
oh
,
const
int
shr
,
const
int
ds
,
cv
::
Mat
hoctaves
,
cv
::
Mat
hstages
,
cv
::
Mat
hnodes
,
cv
::
Mat
hleaves
,
cv
::
Mat
hlevels
)
:
minScale
(
mins
),
maxScale
(
maxs
),
origObjWidth
(
ow
),
origObjHeight
(
oh
),
shrinkage
(
shr
),
downscales
(
ds
)
bool
update
(
int
fh
,
int
fw
,
int
shr
)
{
plane
.
create
(
FRAME_HEIGHT
*
(
HOG_LUV_BINS
+
1
),
FRAME_WIDTH
,
CV_8UC1
);
fplane
.
create
(
FRAME_HEIGHT
*
6
,
FRAME_WIDTH
,
CV_32FC1
);
luv
.
create
(
FRAME_HEIGHT
,
FRAME_WIDTH
,
CV_8UC3
);
if
(
fh
==
luv
.
rows
&&
fh
==
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
);
shrunk
.
create
(
FRAME_HEIGHT
/
shr
*
HOG_LUV_BINS
,
FRAME_WIDTH
/
shr
,
CV_8UC1
);
shrunk
.
create
(
fh
/
shr
*
HOG_LUV_BINS
,
fw
/
shr
,
CV_8UC1
);
integralBuffer
.
create
(
shrunk
.
rows
,
shrunk
.
cols
,
CV_32SC1
);
hogluv
.
create
((
FRAME_HEIGHT
/
shr
)
*
HOG_LUV_BINS
+
1
,
FRAME_WIDTH
/
shr
+
1
,
CV_32SC1
);
hogluv
.
create
((
fh
/
shr
)
*
HOG_LUV_BINS
+
1
,
fw
/
shr
+
1
,
CV_32SC1
);
hogluv
.
setTo
(
cv
::
Scalar
::
all
(
0
));
return
true
;
}
detCounter
.
create
(
sizeof
(
Detection
)
/
sizeof
(
int
),
1
,
CV_32SC1
);
Fields
(
const
float
mins
,
const
float
maxs
,
const
int
tts
,
const
int
ow
,
const
int
oh
,
const
int
shr
,
const
int
ds
,
cv
::
Mat
hoctaves
,
cv
::
Mat
hstages
,
cv
::
Mat
hnodes
,
cv
::
Mat
hleaves
)
:
minScale
(
mins
),
maxScale
(
maxs
),
totals
(
tts
),
origObjWidth
(
ow
),
origObjHeight
(
oh
),
shrinkage
(
shr
),
downscales
(
ds
)
{
update
(
FRAME_HEIGHT
,
FRAME_WIDTH
,
shr
);
octaves
.
upload
(
hoctaves
);
stages
.
upload
(
hstages
);
nodes
.
upload
(
hnodes
);
leaves
.
upload
(
hleaves
);
levels
.
upload
(
hlevels
);
}
void
detect
(
int
scale
,
const
cv
::
gpu
::
GpuMat
&
roi
,
const
cv
::
gpu
::
GpuMat
&
count
,
cv
::
gpu
::
GpuMat
&
objects
,
const
cudaStream_t
&
stream
)
const
...
...
@@ -316,8 +327,8 @@ struct cv::gpu::SCascade::Fields
else
cudaMemset
(
plane
.
data
,
0
,
plane
.
step
*
plane
.
rows
);
static
const
int
fw
=
Fields
::
FRAME_WIDTH
;
static
const
int
fh
=
Fields
::
FRAME_HEIGHT
;
const
int
fw
=
colored
.
cols
;
const
int
fh
=
colored
.
rows
;
GpuMat
gray
(
plane
,
cv
::
Rect
(
0
,
fh
*
Fields
::
HOG_LUV_BINS
,
fw
,
fh
));
cv
::
gpu
::
cvtColor
(
colored
,
gray
,
CV_BGR2GRAY
,
s
);
...
...
@@ -325,7 +336,7 @@ struct cv::gpu::SCascade::Fields
createLuvBins
(
colored
,
s
);
integrate
(
s
);
integrate
(
fh
,
fw
,
s
);
}
private
:
...
...
@@ -352,8 +363,8 @@ private:
void
createHogBins
(
const
cv
::
gpu
::
GpuMat
&
gray
,
Stream
&
s
)
{
static
const
int
fw
=
Fields
::
FRAME_WIDTH
;
static
const
int
fh
=
Fields
::
FRAME_HEIGHT
;
static
const
int
fw
=
gray
.
cols
;
static
const
int
fh
=
gray
.
rows
;
GpuMat
dfdx
(
fplane
,
cv
::
Rect
(
0
,
0
,
fw
,
fh
));
GpuMat
dfdy
(
fplane
,
cv
::
Rect
(
0
,
fh
,
fw
,
fh
));
...
...
@@ -386,8 +397,8 @@ private:
void
createLuvBins
(
const
cv
::
gpu
::
GpuMat
&
colored
,
Stream
&
s
)
{
static
const
int
fw
=
Fields
::
FRAME_WIDTH
;
static
const
int
fh
=
Fields
::
FRAME_HEIGHT
;
static
const
int
fw
=
colored
.
cols
;
static
const
int
fh
=
colored
.
rows
;
cv
::
gpu
::
cvtColor
(
colored
,
luv
,
CV_BGR2Luv
,
s
);
...
...
@@ -400,11 +411,8 @@ private:
cv
::
gpu
::
split
(
luv
,
splited
,
s
);
}
void
integrate
(
Stream
&
s
)
void
integrate
(
const
int
fh
,
const
int
fw
,
Stream
&
s
)
{
int
fw
=
Fields
::
FRAME_WIDTH
;
int
fh
=
Fields
::
FRAME_HEIGHT
;
GpuMat
channels
(
plane
,
cv
::
Rect
(
0
,
0
,
fw
,
fh
*
Fields
::
HOG_LUV_BINS
));
cv
::
gpu
::
resize
(
channels
,
shrunk
,
cv
::
Size
(),
0.25
,
0.25
,
CV_INTER_AREA
,
s
);
...
...
@@ -423,6 +431,8 @@ public:
float
minScale
;
float
maxScale
;
int
totals
;
int
origObjWidth
;
int
origObjHeight
;
...
...
@@ -447,8 +457,6 @@ public:
// 161x121x10
GpuMat
hogluv
;
GpuMat
detCounter
;
// Cascade from xml
GpuMat
octaves
;
GpuMat
stages
;
...
...
@@ -458,6 +466,8 @@ public:
GpuMat
sobelBuf
;
std
::
vector
<
device
::
icf
::
Octave
>
voctaves
;
DeviceInfo
info
;
enum
{
BOOST
=
0
};
...
...
@@ -488,6 +498,7 @@ void cv::gpu::SCascade::detect(InputArray image, InputArray _rois, OutputArray _
CV_Assert
(
fields
);
const
GpuMat
colored
=
image
.
getGpuMat
();
// only color images are supperted
CV_Assert
(
colored
.
type
()
==
CV_8UC3
||
colored
.
type
()
==
CV_32SC1
);
...
...
@@ -496,8 +507,8 @@ void cv::gpu::SCascade::detect(InputArray image, InputArray _rois, OutputArray _
if
(
colored
.
type
()
==
CV_8UC3
)
{
// only this window size allowed
CV_Assert
(
colored
.
cols
==
Fields
::
FRAME_WIDTH
&&
colored
.
rows
==
Fields
::
FRAME_HEIGHT
);
if
(
!
flds
.
update
(
colored
.
rows
,
colored
.
cols
,
flds
.
shrinkage
))
flds
.
createLevels
(
colored
.
rows
,
colored
.
cols
);
flds
.
preprocess
(
colored
,
s
);
}
else
...
...
@@ -525,7 +536,7 @@ void cv::gpu::SCascade::detect(InputArray image, InputArray _rois, OutputArray _
if
(
colored
.
type
()
==
CV_8UC3
)
{
// only this window size allowed
CV_Assert
(
colored
.
cols
==
Fields
::
FRAME_WIDTH
&&
colored
.
rows
==
Fields
::
FRAME_HEIGHT
);
//
CV_Assert(colored.cols == Fields::FRAME_WIDTH && colored.rows == Fields::FRAME_HEIGHT);
flds
.
preprocess
(
colored
,
s
);
}
else
...
...
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