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
15240203
Commit
15240203
authored
Aug 22, 2014
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added image shape prediction code. It works well, just need to fill out the
spec and add asserts.
parent
5de87932
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
257 additions
and
0 deletions
+257
-0
image_processing.h
dlib/image_processing.h
+1
-0
render_face_detections.h
dlib/image_processing/render_face_detections.h
+58
-0
render_face_detections_abstract.h
dlib/image_processing/render_face_detections_abstract.h
+33
-0
shape_predictor.h
dlib/image_processing/shape_predictor.h
+0
-0
shape_predictor_abstract.h
dlib/image_processing/shape_predictor_abstract.h
+165
-0
No files found.
dlib/image_processing.h
View file @
15240203
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#include "image_processing/scan_image_custom.h"
#include "image_processing/scan_image_custom.h"
#include "image_processing/remove_unobtainable_rectangles.h"
#include "image_processing/remove_unobtainable_rectangles.h"
#include "image_processing/scan_fhog_pyramid.h"
#include "image_processing/scan_fhog_pyramid.h"
#include "image_processing/shape_predictor.h"
#endif // DLIB_IMAGE_PROCESSInG_H_h_
#endif // DLIB_IMAGE_PROCESSInG_H_h_
...
...
dlib/image_processing/render_face_detections.h
0 → 100644
View file @
15240203
// Copyright (C) 2014 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_RENDER_FACE_DeTECTIONS_H_
#define DLIB_RENDER_FACE_DeTECTIONS_H_
#include "full_object_detection.h"
#include "../gui_widgets.h"
#include "render_face_detections_abstract.h"
#include <vector>
namespace
dlib
{
inline
std
::
vector
<
image_window
::
overlay_line
>
render_face_detections
(
const
std
::
vector
<
full_object_detection
>&
dets
,
const
rgb_pixel
color
=
rgb_pixel
(
0
,
255
,
0
)
)
{
std
::
vector
<
image_window
::
overlay_line
>
lines
;
for
(
unsigned
long
i
=
0
;
i
<
dets
.
size
();
++
i
)
{
const
full_object_detection
&
d
=
dets
[
i
];
for
(
unsigned
long
i
=
1
;
i
<=
16
;
++
i
)
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
i
),
d
.
part
(
i
-
1
),
color
));
for
(
unsigned
long
i
=
28
;
i
<=
30
;
++
i
)
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
i
),
d
.
part
(
i
-
1
),
color
));
for
(
unsigned
long
i
=
18
;
i
<=
21
;
++
i
)
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
i
),
d
.
part
(
i
-
1
),
color
));
for
(
unsigned
long
i
=
23
;
i
<=
26
;
++
i
)
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
i
),
d
.
part
(
i
-
1
),
color
));
for
(
unsigned
long
i
=
31
;
i
<=
35
;
++
i
)
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
i
),
d
.
part
(
i
-
1
),
color
));
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
30
),
d
.
part
(
35
),
color
));
for
(
unsigned
long
i
=
37
;
i
<=
41
;
++
i
)
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
i
),
d
.
part
(
i
-
1
),
color
));
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
36
),
d
.
part
(
41
),
color
));
for
(
unsigned
long
i
=
43
;
i
<=
47
;
++
i
)
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
i
),
d
.
part
(
i
-
1
),
color
));
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
42
),
d
.
part
(
47
),
color
));
for
(
unsigned
long
i
=
49
;
i
<=
59
;
++
i
)
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
i
),
d
.
part
(
i
-
1
),
color
));
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
48
),
d
.
part
(
59
),
color
));
for
(
unsigned
long
i
=
61
;
i
<=
67
;
++
i
)
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
i
),
d
.
part
(
i
-
1
),
color
));
lines
.
push_back
(
image_window
::
overlay_line
(
d
.
part
(
60
),
d
.
part
(
67
),
color
));
}
return
lines
;
}
}
#endif // DLIB_RENDER_FACE_DeTECTIONS_H_
dlib/image_processing/render_face_detections_abstract.h
0 → 100644
View file @
15240203
// Copyright (C) 2014 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_RENDER_FACE_DeTECTIONS_ABSTRACT_H_
#ifdef DLIB_RENDER_FACE_DeTECTIONS_ABSTRACT_H_
#include "full_object_detection_abstract.h"
#include "../gui_widgets.h"
namespace
dlib
{
inline
std
::
vector
<
image_window
::
overlay_line
>
render_face_detections
(
const
std
::
vector
<
full_object_detection
>&
dets
,
const
rgb_pixel
color
=
rgb_pixel
(
0
,
255
,
0
)
);
/*!
requires
- for all valid i:
- dets[i].num_parts() == 68
ensures
- Interprets the given objects as face detections with parts annotated using
the iBUG face landmark scheme. We then return a set of overlay lines that
will draw the objects onto the screen in a way that properly draws the
outline of the face features defined by the part locations.
- returns a vector with dets.size() elements, each containing the lines
necessary to render a face detection from dets.
!*/
}
#endif // DLIB_RENDER_FACE_DeTECTIONS_ABSTRACT_H_
dlib/image_processing/shape_predictor.h
0 → 100644
View file @
15240203
This diff is collapsed.
Click to expand it.
dlib/image_processing/shape_predictor_abstract.h
0 → 100644
View file @
15240203
// Copyright (C) 2014 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_SHAPE_PREDICToR_ABSTRACT_H_
#ifdef DLIB_SHAPE_PREDICToR_ABSTRACT_H_
#include "full_object_detection_abstract.h"
#include "../matrix.h"
#include "../geometry.h"
#include "../pixel.h"
namespace
dlib
{
// ----------------------------------------------------------------------------------------
class
shape_predictor
{
/*!
!*/
public
:
shape_predictor
(
);
/*!
!*/
unsigned
long
num_parts
(
)
const
;
/*!
ensures
- returns the number of points in the shape
!*/
template
<
typename
image_type
>
full_object_detection
operator
()(
const
image_type
&
img
,
const
rectangle
&
rect
)
const
;
/*!
requires
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
ensures
- runs the tree regressor on the detection rect inside img and returns a
full_object_detection DET such that:
- DET.get_rect() == rect
- DET.num_parts() == num_parts()
!*/
};
void
serialize
(
const
shape_predictor
&
item
,
std
::
ostream
&
out
);
void
deserialize
(
shape_predictor
&
item
,
std
::
istream
&
in
);
/*!
provides serialization support
!*/
// ----------------------------------------------------------------------------------------
class
shape_predictor_trainer
{
/*!
This thing really only works with unsigned char or rgb_pixel images (since we assume the threshold
should be in the range [-128,128]).
!*/
public
:
unsigned
long
cascade_depth
(
)
const
{
return
10
;
}
unsigned
long
tree_depth
(
)
const
{
return
2
;
}
unsigned
long
num_trees_per_cascade_level
(
)
const
{
return
500
;
}
double
get_nu
(
)
const
{
return
0
.
1
;
}
// the regularizer
std
::
string
random_seed
(
)
const
{
return
"dlib rules"
;
}
unsigned
long
oversampling_amount
(
)
const
{
return
20
;
}
// feature sampling parameters
unsigned
long
feature_pool_size
(
)
const
{
return
400
;
}
// this must be > 1
double
get_lambda
(
)
const
{
return
0
.
1
;
}
unsigned
long
get_num_test_splits
(
)
const
{
return
20
;
}
double
get_feature_pool_region_padding
(
)
const
{
return
0
;
}
template
<
typename
image_array
>
shape_predictor
train
(
const
image_array
&
images
,
const
std
::
vector
<
std
::
vector
<
full_object_detection
>
>&
objects
)
const
;
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
image_array
>
double
test_shape_predictor
(
const
shape_predictor
&
sp
,
const
image_array
&
images
,
const
std
::
vector
<
std
::
vector
<
full_object_detection
>
>&
objects
,
const
std
::
vector
<
std
::
vector
<
double
>
>&
scales
);
/*!
requires
- images.size() == objects.size()
- for all valid i and j:
- objects[i][j].num_parts() == sp.num_parts()
- if (scales.size() != 0) then
- There must be a scale value for each full_object_detection in objects.
That is, it must be the case that:
- scales.size() == objects.size()
- for all valid i:
- scales[i].size() == objects[i].size()
ensures
- Tests the given shape_predictor by running it on each of the given objects and
checking how well it recovers the part positions. In particular, for all
valid i and j we perform:
sp(images[i], objects[i][j].get_rect())
and compare the result with the truth part positions in objects[i][j]. We
then return the average distance between a predicted part location and its
true position. This value is then returned.
- if (scales.size() != 0) then
- Each time we compute the distance between a predicted part location and
its true location in objects[i][j] we divide the distance by
scales[i][j]. Therefore, if you want the reported error to be the
average pixel distance then give an empty scales vector, but if you want
the returned value to be something else like the average distance
normalized by some feature of the objects (e.g. the interocular distance)
then you an supply those normalizing values via scales.
!*/
template
<
typename
image_array
>
double
test_shape_predictor
(
const
shape_predictor
&
sp
,
const
image_array
&
images
,
const
std
::
vector
<
std
::
vector
<
full_object_detection
>
>&
objects
);
/*!
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_SHAPE_PREDICToR_ABSTRACT_H_
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