Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
f2139b50
Commit
f2139b50
authored
Nov 19, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed code a bit so that the scan_fhog_pyramid can avoid constructing
the fhog_filterbank each time the detector executes.
parent
f57e4cf5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
14 deletions
+75
-14
object_detector.h
dlib/image_processing/object_detector.h
+49
-14
scan_fhog_pyramid.h
dlib/image_processing/scan_fhog_pyramid.h
+26
-0
No files found.
dlib/image_processing/object_detector.h
View file @
f2139b50
...
...
@@ -12,6 +12,38 @@
namespace
dlib
{
// ----------------------------------------------------------------------------------------
template
<
typename
image_scanner_type
>
struct
processed_weight_vector
{
processed_weight_vector
(){}
typedef
typename
image_scanner_type
::
feature_vector_type
feature_vector_type
;
void
init
(
const
image_scanner_type
&
)
/*!
requires
- w has already been assigned its value. Note that the point of this
function is to allow an image scanner to overload the
processed_weight_vector template and provide some different kind of
object as the output of get_detect_argument(). For example, the
scan_fhog_pyramid object uses an overload that causes
get_detect_argument() to return the special fhog_filterbank object
instead of a feature_vector_type. This avoids needing to construct the
fhog_filterbank during each call to detect and therefore speeds up
detection.
!*/
{}
// return the first argument to image_scanner_type::detect()
const
feature_vector_type
&
get_detect_argument
()
const
{
return
w
;
}
feature_vector_type
w
;
};
// ----------------------------------------------------------------------------------------
template
<
...
...
@@ -36,7 +68,7 @@ namespace dlib
);
const
feature_vector_type
&
get_w
(
)
const
{
return
w
;
}
)
const
{
return
w
.
w
;
}
const
test_box_overlap
&
get_overlap_tester
(
)
const
;
...
...
@@ -124,7 +156,7 @@ namespace dlib
}
test_box_overlap
boxes_overlap
;
feature_vector_type
w
;
processed_weight_vector
<
image_scanner_type
>
w
;
image_scanner_type
scanner
;
};
...
...
@@ -142,7 +174,7 @@ namespace dlib
T
scanner
;
scanner
.
copy_configuration
(
item
.
scanner
);
serialize
(
scanner
,
out
);
serialize
(
item
.
w
,
out
);
serialize
(
item
.
w
.
w
,
out
);
serialize
(
item
.
boxes_overlap
,
out
);
}
...
...
@@ -160,7 +192,8 @@ namespace dlib
throw
serialization_error
(
"Unexpected version encountered while deserializing a dlib::object_detector object."
);
deserialize
(
item
.
scanner
,
in
);
deserialize
(
item
.
w
,
in
);
deserialize
(
item
.
w
.
w
,
in
);
item
.
w
.
init
(
item
.
scanner
);
deserialize
(
item
.
boxes_overlap
,
in
);
}
...
...
@@ -205,8 +238,7 @@ namespace dlib
const
test_box_overlap
&
overlap_tester
,
const
feature_vector_type
&
w_
)
:
boxes_overlap
(
overlap_tester
),
w
(
w_
)
boxes_overlap
(
overlap_tester
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
scanner_
.
get_num_detection_templates
()
>
0
&&
...
...
@@ -220,6 +252,8 @@ namespace dlib
);
scanner
.
copy_configuration
(
scanner_
);
w
.
w
=
w_
;
w
.
init
(
scanner
);
}
// ----------------------------------------------------------------------------------------
...
...
@@ -238,6 +272,7 @@ namespace dlib
boxes_overlap
=
item
.
boxes_overlap
;
w
=
item
.
w
;
scanner
.
copy_configuration
(
item
.
scanner
);
w
.
init
(
scanner
);
return
*
this
;
}
...
...
@@ -256,13 +291,13 @@ namespace dlib
)
{
std
::
vector
<
rectangle
>
final_dets
;
if
(
w
.
size
()
!=
0
)
if
(
w
.
w
.
size
()
!=
0
)
{
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>
dets
;
const
double
thresh
=
w
(
scanner
.
get_num_dimensions
());
const
double
thresh
=
w
.
w
(
scanner
.
get_num_dimensions
());
scanner
.
load
(
img
);
scanner
.
detect
(
w
,
dets
,
thresh
+
adjust_threshold
);
scanner
.
detect
(
w
.
get_detect_argument
()
,
dets
,
thresh
+
adjust_threshold
);
for
(
unsigned
long
i
=
0
;
i
<
dets
.
size
();
++
i
)
{
...
...
@@ -292,13 +327,13 @@ namespace dlib
)
{
final_dets
.
clear
();
if
(
w
.
size
()
!=
0
)
if
(
w
.
w
.
size
()
!=
0
)
{
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>
dets
;
const
double
thresh
=
w
(
scanner
.
get_num_dimensions
());
const
double
thresh
=
w
.
w
(
scanner
.
get_num_dimensions
());
scanner
.
load
(
img
);
scanner
.
detect
(
w
,
dets
,
thresh
+
adjust_threshold
);
scanner
.
detect
(
w
.
get_detect_argument
()
,
dets
,
thresh
+
adjust_threshold
);
for
(
unsigned
long
i
=
0
;
i
<
dets
.
size
();
++
i
)
{
...
...
@@ -336,7 +371,7 @@ namespace dlib
for
(
unsigned
long
i
=
0
;
i
<
temp_dets
.
size
();
++
i
)
{
final_dets
.
push_back
(
std
::
make_pair
(
temp_dets
[
i
].
first
,
scanner
.
get_full_object_detection
(
temp_dets
[
i
].
second
,
w
)));
scanner
.
get_full_object_detection
(
temp_dets
[
i
].
second
,
w
.
w
)));
}
}
...
...
@@ -364,7 +399,7 @@ namespace dlib
// convert all the rectangle detections into full_object_detections.
for
(
unsigned
long
i
=
0
;
i
<
temp_dets
.
size
();
++
i
)
{
final_dets
.
push_back
(
scanner
.
get_full_object_detection
(
temp_dets
[
i
].
second
,
w
));
final_dets
.
push_back
(
scanner
.
get_full_object_detection
(
temp_dets
[
i
].
second
,
w
.
w
));
}
}
...
...
dlib/image_processing/scan_fhog_pyramid.h
View file @
f2139b50
...
...
@@ -926,6 +926,32 @@ namespace dlib
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
Pyramid_type
>
struct
processed_weight_vector
<
scan_fhog_pyramid
<
Pyramid_type
>
>
{
processed_weight_vector
(){}
typedef
matrix
<
double
,
0
,
1
>
feature_vector_type
;
typedef
typename
scan_fhog_pyramid
<
Pyramid_type
>::
fhog_filterbank
fhog_filterbank
;
void
init
(
const
scan_fhog_pyramid
<
Pyramid_type
>&
scanner
)
{
fb
=
scanner
.
build_fhog_filterbank
(
w
);
}
const
fhog_filterbank
&
get_detect_argument
()
const
{
return
fb
;
}
feature_vector_type
w
;
fhog_filterbank
fb
;
};
// ----------------------------------------------------------------------------------------
}
...
...
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