MediaImageLabel.py 487 B

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