Coverage for src/bob/bio/face/annotator/Base.py: 80%
10 statements
« prev ^ index » next coverage.py v7.6.0, created at 2024-07-13 00:04 +0200
« prev ^ index » next coverage.py v7.6.0, created at 2024-07-13 00:04 +0200
1import bob.bio.base.annotator
3from bob.bio.base.annotator.FailSafe import translate_kwargs
6class Base(bob.bio.base.annotator.Annotator):
7 """Base class for all face annotators"""
9 def annotations(self, image):
10 """Returns annotations for all faces in the image.
12 Parameters
13 ----------
14 image : numpy.ndarray
15 An RGB image in Bob format.
17 Returns
18 -------
19 list
20 A list of annotations. Annotations are dictionaries that contain the
21 following possible keys: ``topleft``, ``bottomright``, ``reye``, ``leye``
22 """
23 raise NotImplementedError()
25 def annotate(self, sample, **kwargs):
26 """Annotates an image and returns annotations in a dictionary. All
27 annotator should return at least the ``topleft`` and ``bottomright``
28 coordinates. Some currently known annotation points such as ``reye``
29 and ``leye`` are formalized in
30 :any:`bob.bio.face.preprocessor.FaceCrop`.
32 Parameters
33 ----------
34 sample : numpy.ndarray
35 The image should be a Bob format (#Channels, Height, Width) RGB
36 image.
37 **kwargs
38 The extra arguments that may be passed.
39 """
40 raise NotImplementedError()
42 def transform(self, samples, **kwargs):
43 """Annotates an image and returns annotations in a dictionary.
45 All annotator should add at least the ``topleft`` and ``bottomright``
46 coordinates. Some currently known annotation points such as ``reye``
47 and ``leye`` are formalized in
48 :any:`bob.bio.face.preprocessor.FaceCrop`.
50 Parameters
51 ----------
52 sample : Sample
53 The image int the sample object should be a Bob format
54 (#Channels, Height, Width) RGB image.
55 **kwargs
56 Extra arguments that may be passed.
57 """
58 kwargs = translate_kwargs(kwargs, len(samples))
59 return [
60 self.annotate(sample, **kw) for sample, kw in zip(samples, kwargs)
61 ]