refactor: extractor

This commit is contained in:
283375 2023-09-29 21:40:09 +08:00
parent da42699ac8
commit 580744b641
Signed by: 283375
SSH Key Fingerprint: SHA256:UcX0qg6ZOSDOeieKPGokA5h7soykG61nz2uxuQgVLSk
2 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,2 @@
from .common import Extractor
from .sizes import *

View File

@ -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))