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
916ba4c0
Commit
916ba4c0
authored
Oct 11, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor preprocessing
parent
fa62e2b7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
31 deletions
+50
-31
softcascade.cpp
modules/gpu/src/softcascade.cpp
+50
-31
No files found.
modules/gpu/src/softcascade.cpp
View file @
916ba4c0
...
...
@@ -183,13 +183,47 @@ struct cv::gpu::SoftCascade::Filds
{
cudaMemset
(
plane
.
data
,
0
,
plane
.
step
*
plane
.
rows
);
int
fw
=
Filds
::
FRAME_WIDTH
;
int
fh
=
Filds
::
FRAME_HEIGHT
;
static
const
int
fw
=
Filds
::
FRAME_WIDTH
;
static
const
int
fh
=
Filds
::
FRAME_HEIGHT
;
GpuMat
gray
(
plane
,
cv
::
Rect
(
0
,
fh
*
Filds
::
HOG_LUV_BINS
,
fw
,
fh
));
cv
::
gpu
::
cvtColor
(
colored
,
gray
,
CV_BGR2GRAY
);
createHogBins
(
gray
);
createLuvBins
(
colored
);
integrate
();
}
private
:
void
calcLevels
(
const
std
::
vector
<
device
::
icf
::
Octave
>&
octs
,
int
frameW
,
int
frameH
,
int
nscales
);
typedef
std
::
vector
<
device
::
icf
::
Octave
>::
const_iterator
octIt_t
;
int
fitOctave
(
const
std
::
vector
<
device
::
icf
::
Octave
>&
octs
,
const
float
&
logFactor
)
const
{
float
minAbsLog
=
FLT_MAX
;
int
res
=
0
;
for
(
int
oct
=
0
;
oct
<
(
int
)
octs
.
size
();
++
oct
)
{
const
device
::
icf
::
Octave
&
octave
=
octs
[
oct
];
float
logOctave
=
::
log
(
octave
.
scale
);
float
logAbsScale
=
::
fabs
(
logFactor
-
logOctave
);
if
(
logAbsScale
<
minAbsLog
)
{
res
=
oct
;
minAbsLog
=
logAbsScale
;
}
}
return
res
;
}
void
createHogBins
(
const
cv
::
gpu
::
GpuMat
&
gray
)
{
static
const
int
fw
=
Filds
::
FRAME_WIDTH
;
static
const
int
fh
=
Filds
::
FRAME_HEIGHT
;
//create hog
GpuMat
dfdx
(
fplane
,
cv
::
Rect
(
0
,
0
,
fw
,
fh
));
GpuMat
dfdy
(
fplane
,
cv
::
Rect
(
0
,
fh
,
fw
,
fh
));
...
...
@@ -213,7 +247,14 @@ struct cv::gpu::SoftCascade::Filds
GpuMat
cmag
(
plane
,
cv
::
Rect
(
0
,
fh
*
Filds
::
HOG_BINS
,
fw
,
fh
));
nmag
.
convertTo
(
cmag
,
CV_8UC1
);
// create luv
device
::
icf
::
fillBins
(
plane
,
nang
,
fw
,
fh
,
Filds
::
HOG_BINS
);
}
void
createLuvBins
(
const
cv
::
gpu
::
GpuMat
&
colored
)
{
static
const
int
fw
=
Filds
::
FRAME_WIDTH
;
static
const
int
fh
=
Filds
::
FRAME_HEIGHT
;
cv
::
gpu
::
cvtColor
(
colored
,
luv
,
CV_BGR2Luv
);
std
::
vector
<
GpuMat
>
splited
;
...
...
@@ -223,8 +264,12 @@ struct cv::gpu::SoftCascade::Filds
}
cv
::
gpu
::
split
(
luv
,
splited
);
}
device
::
icf
::
fillBins
(
plane
,
nang
,
fw
,
fh
,
Filds
::
HOG_BINS
);
void
integrate
()
{
int
fw
=
Filds
::
FRAME_WIDTH
;
int
fh
=
Filds
::
FRAME_HEIGHT
;
GpuMat
channels
(
plane
,
cv
::
Rect
(
0
,
0
,
fw
,
fh
*
Filds
::
HOG_LUV_BINS
));
cv
::
gpu
::
resize
(
channels
,
shrunk
,
cv
::
Size
(),
0.25
,
0.25
,
CV_INTER_AREA
);
...
...
@@ -239,30 +284,6 @@ struct cv::gpu::SoftCascade::Filds
cv
::
gpu
::
integralBuffered
(
channel
,
sum
,
integralBuffer
);
}
}
private
:
void
calcLevels
(
const
std
::
vector
<
device
::
icf
::
Octave
>&
octs
,
int
frameW
,
int
frameH
,
int
nscales
);
typedef
std
::
vector
<
device
::
icf
::
Octave
>::
const_iterator
octIt_t
;
int
fitOctave
(
const
std
::
vector
<
device
::
icf
::
Octave
>&
octs
,
const
float
&
logFactor
)
const
{
float
minAbsLog
=
FLT_MAX
;
int
res
=
0
;
for
(
int
oct
=
0
;
oct
<
(
int
)
octs
.
size
();
++
oct
)
{
const
device
::
icf
::
Octave
&
octave
=
octs
[
oct
];
float
logOctave
=
::
log
(
octave
.
scale
);
float
logAbsScale
=
::
fabs
(
logFactor
-
logOctave
);
if
(
logAbsScale
<
minAbsLog
)
{
res
=
oct
;
minAbsLog
=
logAbsScale
;
}
}
return
res
;
}
};
bool
cv
::
gpu
::
SoftCascade
::
Filds
::
fill
(
const
FileNode
&
root
,
const
float
mins
,
const
float
maxs
)
...
...
@@ -572,5 +593,4 @@ cv::Size cv::gpu::SoftCascade::getRoiSize() const
return
cv
::
Size
(
Filds
::
FRAME_WIDTH
/
4
,
Filds
::
FRAME_HEIGHT
/
4
);
}
#endif
\ 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