from pycs.database.Result import Result


#pylint: disable=too-few-public-methods
class MediaImageLabel:
    """
    An image label with an optional frame index for videos.
    """

    def __init__(self, result: Result):
        self.label = result.label
        self.frame = None
        if result.data is not None and 'frame' in result.data:
            self.frame = result.data['frame']

    def serialize(self) -> dict:
        """
        serialize all object properties to a dict

        :return: dict
        """
        return dict({'type': 'image-label'}, **self.__dict__)
