diff --git a/src/arcaea_offline_ocr/extractor/__init__.py b/src/arcaea_offline_ocr/extractor/__init__.py index e69de29..c288e7f 100644 --- a/src/arcaea_offline_ocr/extractor/__init__.py +++ b/src/arcaea_offline_ocr/extractor/__init__.py @@ -0,0 +1,2 @@ +from .common import Extractor +from .sizes import * diff --git a/src/arcaea_offline_ocr/extractor/common.py b/src/arcaea_offline_ocr/extractor/common.py index 64d5e49..f723aff 100644 --- a/src/arcaea_offline_ocr/extractor/common.py +++ b/src/arcaea_offline_ocr/extractor/common.py @@ -1,5 +1,45 @@ +import cv2 + +from ..crop import crop_xywh from .sizes.common import Sizes class Extractor: - sizes: Sizes + def __init__(self, img: cv2.Mat, sizes: Sizes): + self.img = img + self.sizes = sizes + + def __construct_int_rect(self, rect): + return tuple(round(r) for r in rect) + + @property + def pure(self): + return crop_xywh(self.img, self.__construct_int_rect(self.sizes.pure)) + + @property + def far(self): + return crop_xywh(self.img, self.__construct_int_rect(self.sizes.far)) + + @property + def lost(self): + return crop_xywh(self.img, self.__construct_int_rect(self.sizes.lost)) + + @property + def score(self): + return crop_xywh(self.img, self.__construct_int_rect(self.sizes.score)) + + @property + def rating_class(self): + return crop_xywh(self.img, self.__construct_int_rect(self.sizes.rating_class)) + + @property + def max_recall(self): + return crop_xywh(self.img, self.__construct_int_rect(self.sizes.max_recall)) + + @property + def clear_status(self): + return crop_xywh(self.img, self.__construct_int_rect(self.sizes.clear_status)) + + @property + def partner_icon(self): + return crop_xywh(self.img, self.__construct_int_rect(self.sizes.partner_icon))