MediaImageLabel.py 584 B

12345678910111213141516171819202122
  1. from pycs.database.Result import Result
  2. #pylint: disable=too-few-public-methods
  3. class MediaImageLabel:
  4. """
  5. An image label with an optional frame index for videos.
  6. """
  7. def __init__(self, result: Result):
  8. self.label = result.label
  9. self.frame = None
  10. if result.data is not None and 'frame' in result.data:
  11. self.frame = result.data['frame']
  12. def serialize(self) -> dict:
  13. """
  14. serialize all object properties to a dict
  15. :return: dict
  16. """
  17. return dict({'type': 'image-label'}, **self.__dict__)