in python/example_code/rekognition/rekognition_objects.py [0:0]
def to_dict(self):
"""
Renders some of the face data to a dict.
:return: A dict that contains the face data.
"""
rendering = {}
if self.bounding_box is not None:
rendering['bounding_box'] = self.bounding_box
if self.age_range is not None:
rendering['age'] = f'{self.age_range[0]} - {self.age_range[1]}'
if self.gender is not None:
rendering['gender'] = self.gender
if self.emotions:
rendering['emotions'] = self.emotions
if self.face_id is not None:
rendering['face_id'] = self.face_id
if self.image_id is not None:
rendering['image_id'] = self.image_id
if self.timestamp is not None:
rendering['timestamp'] = self.timestamp
has = []
if self.smile:
has.append('smile')
if self.eyeglasses:
has.append('eyeglasses')
if self.sunglasses:
has.append('sunglasses')
if self.beard:
has.append('beard')
if self.mustache:
has.append('mustache')
if self.eyes_open:
has.append('open eyes')
if self.mouth_open:
has.append('open mouth')
if has:
rendering['has'] = has
return rendering