Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
d53a37e7
Commit
d53a37e7
authored
Dec 21, 2011
by
Davis King
Browse files
Added another member function which enables you to get the detection
strengths from the object_detector.
parent
ca6bd2ca
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
dlib/image_processing/object_detector.h
dlib/image_processing/object_detector.h
+56
-0
dlib/image_processing/object_detector_abstract.h
dlib/image_processing/object_detector_abstract.h
+23
-0
No files found.
dlib/image_processing/object_detector.h
View file @
d53a37e7
...
...
@@ -45,6 +45,14 @@ namespace dlib
const
image_type
&
img
)
const
;
template
<
typename
image_type
>
void
operator
()
(
const
image_type
&
img
,
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>&
final_dets
)
const
;
template
<
typename
T
,
typename
U
>
friend
void
serialize
(
const
object_detector
<
T
,
U
>&
item
,
...
...
@@ -72,6 +80,19 @@ namespace dlib
return
false
;
}
bool
overlaps_any_box
(
const
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>&
rects
,
const
dlib
::
rectangle
&
rect
)
const
{
for
(
unsigned
long
i
=
0
;
i
<
rects
.
size
();
++
i
)
{
if
(
boxes_overlap
(
rects
[
i
].
second
,
rect
))
return
true
;
}
return
false
;
}
overlap_tester_type
boxes_overlap
;
matrix
<
double
,
0
,
1
>
w
;
mutable
image_scanner_type
scanner
;
...
...
@@ -221,6 +242,41 @@ namespace dlib
return
final_dets
;
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_scanner_type
,
typename
overlap_tester_type
>
template
<
typename
image_type
>
void
object_detector
<
image_scanner_type
,
overlap_tester_type
>::
operator
()
(
const
image_type
&
img
,
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>&
final_dets
)
const
{
final_dets
.
clear
();
if
(
w
.
size
()
!=
0
)
{
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>
dets
;
const
double
thresh
=
w
(
scanner
.
get_num_dimensions
());
scanner
.
load
(
img
);
scanner
.
detect
(
w
,
dets
,
thresh
);
for
(
unsigned
long
i
=
0
;
i
<
dets
.
size
();
++
i
)
{
if
(
overlaps_any_box
(
final_dets
,
dets
[
i
].
second
))
continue
;
dets
[
i
].
first
-=
thresh
;
final_dets
.
push_back
(
dets
[
i
]);
}
}
}
// ----------------------------------------------------------------------------------------
}
...
...
dlib/image_processing/object_detector_abstract.h
View file @
d53a37e7
...
...
@@ -99,6 +99,29 @@ namespace dlib
element 1 the next best, and so on.
!*/
template
<
typename
image_type
>
void
operator
()
(
const
image_type
&
img
,
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>&
dets
)
const
;
/*!
requires
- img == an object which can be accepted by image_scanner_type::load()
ensures
- performs object detection on the given image and stores the
detected objects into #dets. In particular, we will have that:
- #dets is sorted such that the highest confidence detections
come first. E.g. element 0 is the best detection, element 1
the next best, and so on.
- #dets.size() == the number of detected objects.
- #dets[i].first gives the "detection confidence", of the i-th
detection. This is the detection value output by the scanner
minus the threshold, therefore this is a value > 0.
- #dets[i].second == the bounding box for the i-th detection.
!*/
};
// ----------------------------------------------------------------------------------------
...
...
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