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
c470e15d
Commit
c470e15d
authored
Dec 11, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integrate speprocessing strategy
parent
d23a4f50
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
63 deletions
+44
-63
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+23
-24
perf_softcascade.cpp
modules/gpu/perf/perf_softcascade.cpp
+13
-23
gpu_init.cpp
modules/gpu/src/gpu_init.cpp
+1
-2
softcascade.cpp
modules/gpu/src/softcascade.cpp
+0
-0
test_softcascade.cpp
modules/gpu/test/test_softcascade.cpp
+7
-14
No files found.
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
c470e15d
...
...
@@ -1529,32 +1529,37 @@ public:
// ======================== GPU version for soft cascade ===================== //
// Implementation of soft (stageless) cascaded detector.
class
CV_EXPORTS
SCascade
:
public
Algorithm
class
CV_EXPORTS
ChannelsProcessor
{
public
:
enum
{
GENERIC
=
1
,
SEPARABLE
=
2
};
class
CV_EXPORTS
Preprocessor
enum
{
public
:
GENERIC
=
1
<<
4
,
SEPARABLE
=
2
<<
4
};
// Appends specified number of HOG first-order features integrals into given vector.
// Param frame is an input 3-channel bgr image.
// Param channels is a GPU matrix of integrals.
// Param channels is a GPU matrix of optionally shrinked channels
// Param stream is stream is a high-level CUDA stream abstraction used for asynchronous execution.
virtual
void
apply
(
InputArray
frame
,
OutputArray
channels
,
Stream
&
stream
=
Stream
::
Null
())
=
0
;
// Creates a specific preprocessor implementation.
// Param shrinkage is a resizing factor. Resize is applied before the computing integral sum
// Param bins is a number of HOG-like channels.
// Param method is a channel computing method
.
static
cv
::
Ptr
<
Preprocessor
>
create
(
const
int
shrinkage
,
const
int
bins
,
const
int
method
=
GENERIC
);
// Param flags is a channel computing extra flags
.
static
cv
::
Ptr
<
ChannelsProcessor
>
create
(
const
int
shrinkage
,
const
int
bins
,
const
int
flags
=
GENERIC
);
virtual
~
ChannelsProcessor
();
protected
:
Preprocessor
();
};
protected
:
ChannelsProcessor
();
};
// Implementation of soft (stageless) cascaded detector.
class
CV_EXPORTS
SCascade
:
public
Algorithm
{
public
:
// Representation of detectors result.
struct
CV_EXPORTS
Detection
...
...
@@ -1569,14 +1574,15 @@ public:
enum
{
PEDESTRIAN
=
0
};
};
enum
{
NO_REJECT
=
1
,
DOLLAR
=
2
,
/*PASCAL = 4,*/
DEFAULT
=
NO_REJECT
};
enum
{
NO_REJECT
=
1
,
DOLLAR
=
2
,
/*PASCAL = 4,*/
DEFAULT
=
NO_REJECT
,
NMS_MASK
=
0xF
};
// An empty cascade will be created.
// Param minScale is a minimum scale relative to the original size of the image on which cascade will be applyed.
// Param minScale is a maximum scale relative to the original size of the image on which cascade will be applyed.
// Param scales is a number of scales from minScale to maxScale.
// Param rejfactor is used for NMS.
SCascade
(
const
double
minScale
=
0.4
,
const
double
maxScale
=
5.
,
const
int
scales
=
55
,
const
int
rejCriteria
=
1
);
// Param flags is an extra tuning flags.
SCascade
(
const
double
minScale
=
0.4
,
const
double
maxScale
=
5.
,
const
int
scales
=
55
,
const
int
flags
=
NO_REJECT
||
ChannelsProcessor
::
GENERIC
);
virtual
~
SCascade
();
...
...
@@ -1598,13 +1604,6 @@ public:
// Param stream is stream is a high-level CUDA stream abstraction used for asynchronous execution
virtual
void
detect
(
InputArray
image
,
InputArray
rois
,
OutputArray
objects
,
Stream
&
stream
=
Stream
::
Null
())
const
;
// Convert ROI matrix into the suitable for detect method.
// Param roi is an input matrix of the same size as the image.
// There non zero value mean that detector should be executed in this point.
// Param mask is an output mask
// Param stream is stream is a high-level CUDA stream abstraction used for asynchronous execution
virtual
void
genRoi
(
InputArray
roi
,
OutputArray
mask
,
Stream
&
stream
=
Stream
::
Null
())
const
;
private
:
struct
Fields
;
...
...
@@ -1612,9 +1611,9 @@ private:
double
minScale
;
double
maxScale
;
int
scales
;
int
rejCriteria
;
int
flags
;
};
CV_EXPORTS
bool
initModule_gpu
(
void
);
...
...
modules/gpu/perf/perf_softcascade.cpp
View file @
c470e15d
...
...
@@ -71,15 +71,14 @@ RUN_GPU(SCascadeTest, detect)
ASSERT_TRUE
(
cascade
.
load
(
fs
.
getFirstTopLevelNode
()));
cv
::
gpu
::
GpuMat
objectBoxes
(
1
,
10000
*
sizeof
(
cv
::
gpu
::
SCascade
::
Detection
),
CV_8UC1
),
rois
(
colored
.
size
(),
CV_8UC1
)
,
trois
;
cv
::
gpu
::
GpuMat
objectBoxes
(
1
,
10000
*
sizeof
(
cv
::
gpu
::
SCascade
::
Detection
),
CV_8UC1
),
rois
(
colored
.
size
(),
CV_8UC1
);
rois
.
setTo
(
1
);
cascade
.
genRoi
(
rois
,
trois
);
cascade
.
detect
(
colored
,
t
rois
,
objectBoxes
);
cascade
.
detect
(
colored
,
rois
,
objectBoxes
);
TEST_CYCLE
()
{
cascade
.
detect
(
colored
,
t
rois
,
objectBoxes
);
cascade
.
detect
(
colored
,
rois
,
objectBoxes
);
}
SANITY_CHECK
(
sortDetections
(
objectBoxes
));
...
...
@@ -142,14 +141,11 @@ RUN_GPU(SCascadeTestRoi, detectInRoi)
sub
.
setTo
(
1
);
}
cv
::
gpu
::
GpuMat
trois
;
cascade
.
genRoi
(
rois
,
trois
);
cascade
.
detect
(
colored
,
trois
,
objectBoxes
);
cascade
.
detect
(
colored
,
rois
,
objectBoxes
);
TEST_CYCLE
()
{
cascade
.
detect
(
colored
,
t
rois
,
objectBoxes
);
cascade
.
detect
(
colored
,
rois
,
objectBoxes
);
}
SANITY_CHECK
(
sortDetections
(
objectBoxes
));
...
...
@@ -186,14 +182,11 @@ RUN_GPU(SCascadeTestRoi, detectEachRoi)
cv
::
gpu
::
GpuMat
sub
(
rois
,
r
);
sub
.
setTo
(
1
);
cv
::
gpu
::
GpuMat
trois
;
cascade
.
genRoi
(
rois
,
trois
);
cascade
.
detect
(
colored
,
trois
,
objectBoxes
);
cascade
.
detect
(
colored
,
rois
,
objectBoxes
);
TEST_CYCLE
()
{
cascade
.
detect
(
colored
,
t
rois
,
objectBoxes
);
cascade
.
detect
(
colored
,
rois
,
objectBoxes
);
}
SANITY_CHECK
(
sortDetections
(
objectBoxes
));
...
...
@@ -235,15 +228,14 @@ RUN_GPU(SCascadeTest, detectOnIntegral)
ASSERT_TRUE
(
cascade
.
load
(
fs
.
getFirstTopLevelNode
()));
cv
::
gpu
::
GpuMat
objectBoxes
(
1
,
10000
*
sizeof
(
cv
::
gpu
::
SCascade
::
Detection
),
CV_8UC1
),
rois
(
cv
::
Size
(
640
,
480
),
CV_8UC1
)
,
trois
;
cv
::
gpu
::
GpuMat
objectBoxes
(
1
,
10000
*
sizeof
(
cv
::
gpu
::
SCascade
::
Detection
),
CV_8UC1
),
rois
(
cv
::
Size
(
640
,
480
),
CV_8UC1
);
rois
.
setTo
(
1
);
cascade
.
genRoi
(
rois
,
trois
);
cascade
.
detect
(
hogluv
,
t
rois
,
objectBoxes
);
cascade
.
detect
(
hogluv
,
rois
,
objectBoxes
);
TEST_CYCLE
()
{
cascade
.
detect
(
hogluv
,
t
rois
,
objectBoxes
);
cascade
.
detect
(
hogluv
,
rois
,
objectBoxes
);
}
SANITY_CHECK
(
sortDetections
(
objectBoxes
));
...
...
@@ -270,18 +262,16 @@ RUN_GPU(SCascadeTest, detectStream)
ASSERT_TRUE
(
cascade
.
load
(
fs
.
getFirstTopLevelNode
()));
cv
::
gpu
::
GpuMat
objectBoxes
(
1
,
10000
*
sizeof
(
cv
::
gpu
::
SCascade
::
Detection
),
CV_8UC1
),
rois
(
colored
.
size
(),
CV_8UC1
)
,
trois
;
cv
::
gpu
::
GpuMat
objectBoxes
(
1
,
10000
*
sizeof
(
cv
::
gpu
::
SCascade
::
Detection
),
CV_8UC1
),
rois
(
colored
.
size
(),
CV_8UC1
);
rois
.
setTo
(
1
);
cv
::
gpu
::
Stream
s
;
cascade
.
genRoi
(
rois
,
trois
,
s
);
cascade
.
detect
(
colored
,
trois
,
objectBoxes
,
s
);
cascade
.
detect
(
colored
,
rois
,
objectBoxes
,
s
);
TEST_CYCLE
()
{
cascade
.
detect
(
colored
,
t
rois
,
objectBoxes
,
s
);
cascade
.
detect
(
colored
,
rois
,
objectBoxes
,
s
);
}
#ifdef HAVE_CUDA
...
...
modules/gpu/src/gpu_init.cpp
View file @
c470e15d
...
...
@@ -48,8 +48,7 @@ namespace cv { namespace gpu
CV_INIT_ALGORITHM
(
SCascade
,
"CascadeDetector.SCascade"
,
obj
.
info
()
->
addParam
(
obj
,
"minScale"
,
obj
.
minScale
);
obj
.
info
()
->
addParam
(
obj
,
"maxScale"
,
obj
.
maxScale
);
obj
.
info
()
->
addParam
(
obj
,
"scales"
,
obj
.
scales
);
obj
.
info
()
->
addParam
(
obj
,
"rejCriteria"
,
obj
.
rejCriteria
));
obj
.
info
()
->
addParam
(
obj
,
"scales"
,
obj
.
scales
));
bool
initModule_gpu
(
void
)
{
...
...
modules/gpu/src/softcascade.cpp
View file @
c470e15d
This diff is collapsed.
Click to expand it.
modules/gpu/test/test_softcascade.cpp
View file @
c470e15d
...
...
@@ -169,7 +169,7 @@ GPU_TEST_P(SCascadeTestRoi, detect,
ASSERT_TRUE
(
cascade
.
load
(
fs
.
getFirstTopLevelNode
()));
GpuMat
colored
(
coloredCpu
),
objectBoxes
(
1
,
16384
,
CV_8UC1
),
rois
(
colored
.
size
(),
CV_8UC1
)
,
trois
;
GpuMat
colored
(
coloredCpu
),
objectBoxes
(
1
,
16384
,
CV_8UC1
),
rois
(
colored
.
size
(),
CV_8UC1
);
rois
.
setTo
(
0
);
int
nroi
=
GET_PARAM
(
3
);
...
...
@@ -183,8 +183,8 @@ GPU_TEST_P(SCascadeTestRoi, detect,
cv
::
rectangle
(
result
,
r
,
cv
::
Scalar
(
0
,
0
,
255
,
255
),
1
);
}
objectBoxes
.
setTo
(
0
);
cascade
.
genRoi
(
rois
,
trois
);
cascade
.
detect
(
colored
,
t
rois
,
objectBoxes
);
cascade
.
detect
(
colored
,
rois
,
objectBoxes
);
cv
::
Mat
dt
(
objectBoxes
);
typedef
cv
::
gpu
::
SCascade
::
Detection
Detection
;
...
...
@@ -239,10 +239,8 @@ GPU_TEST_P(SCascadeTestAll, detect,
GpuMat
sub
(
rois
,
cv
::
Rect
(
rois
.
cols
/
4
,
rois
.
rows
/
4
,
rois
.
cols
/
2
,
rois
.
rows
/
2
));
sub
.
setTo
(
cv
::
Scalar
::
all
(
1
));
cv
::
gpu
::
GpuMat
trois
;
cascade
.
genRoi
(
rois
,
trois
);
objectBoxes
.
setTo
(
0
);
cascade
.
detect
(
colored
,
t
rois
,
objectBoxes
);
cascade
.
detect
(
colored
,
rois
,
objectBoxes
);
typedef
cv
::
gpu
::
SCascade
::
Detection
Detection
;
cv
::
Mat
detections
(
objectBoxes
);
...
...
@@ -279,10 +277,8 @@ GPU_TEST_P(SCascadeTestAll, detectOnIntegral,
GpuMat
objectBoxes
(
1
,
100000
,
CV_8UC1
),
rois
(
cv
::
Size
(
640
,
480
),
CV_8UC1
);
rois
.
setTo
(
1
);
cv
::
gpu
::
GpuMat
trois
;
cascade
.
genRoi
(
rois
,
trois
);
objectBoxes
.
setTo
(
0
);
cascade
.
detect
(
hogluv
,
t
rois
,
objectBoxes
);
cascade
.
detect
(
hogluv
,
rois
,
objectBoxes
);
typedef
cv
::
gpu
::
SCascade
::
Detection
Detection
;
cv
::
Mat
detections
(
objectBoxes
);
...
...
@@ -315,12 +311,9 @@ GPU_TEST_P(SCascadeTestAll, detectStream,
cv
::
gpu
::
Stream
s
;
cv
::
gpu
::
GpuMat
trois
;
cascade
.
genRoi
(
rois
,
trois
,
s
);
objectBoxes
.
setTo
(
0
);
cascade
.
detect
(
colored
,
trois
,
objectBoxes
,
s
);
cudaDeviceSynchronize
();
cascade
.
detect
(
colored
,
rois
,
objectBoxes
,
s
);
s
.
waitForCompletion
();
typedef
cv
::
gpu
::
SCascade
::
Detection
Detection
;
cv
::
Mat
detections
(
objectBoxes
);
...
...
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