Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.face
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.bio.face
Commits
2fc780a4
Commit
2fc780a4
authored
7 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
move annotation normalization to bob.bio.video
parent
ec5da726
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!41
Add annotators
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/bio/face/annotator/__init__.py
+0
-61
0 additions, 61 deletions
bob/bio/face/annotator/__init__.py
with
0 additions
and
61 deletions
bob/bio/face/annotator/__init__.py
+
0
−
61
View file @
2fc780a4
from
.Base
import
Base
from
bob.ip.facedetect
import
bounding_box_from_annotation
def
bounding_box_to_annotations
(
bbx
):
...
...
@@ -7,63 +6,3 @@ def bounding_box_to_annotations(bbx):
landmarks
[
'
topleft
'
]
=
bbx
.
topleft_f
landmarks
[
'
bottomright
'
]
=
bbx
.
bottomright_f
return
landmarks
def
normalize_annotations
(
annotations
,
validator
,
max_age
=-
1
):
"""
Normalizes the annotations of one video sequence. It fills the
annotations for frames from previous ones if the annotation for the current
frame is not valid.
Parameters
----------
annotations : dict
A dict of dict where the keys to the first dict are frame indices as
strings (starting from 0). The inside dicts contain annotations for
that frame.
validator : callable
Takes a dict (annotations) and returns True if the annotations are
valid. This can be check based on minimal face size for example.
max_age : :obj:`int`, optional
An integer indicating for a how many frames a detected face is valid if
no detection occurs after such frame. A value of -1 == forever
Yields
------
dict
The corrected annotations of frames.
"""
# the annotations for the current frame
current
=
{}
age
=
0
for
k
,
annot
in
annotations
.
items
():
if
validator
(
annot
):
current
=
annot
age
=
0
elif
max_age
<
0
or
age
<
max_age
:
age
+=
1
else
:
# no detections and age is larger than maximum allowed
current
=
{}
yield
current
def
min_face_size_validator
(
annotations
,
min_face_size
=
32
):
"""
Validates annotations based on face
'
s minimal size.
Parameters
----------
annotations : dict
The annotations in dictionary format.
min_face_size : int, optional
The minimal size of a face.
Returns
-------
bool
True, if the face is large enough.
"""
bbx
=
bounding_box_from_annotation
(
**
annotations
)
if
bbx
.
size
<
32
:
return
False
return
True
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment