mirror of
https://github.com/283375/arcaea-offline-ocr.git
synced 2025-07-03 05:16:28 +00:00
refactor: module structure
This commit is contained in:
49
src/arcaea_offline_ocr/device/rois/extractor/common.py
Normal file
49
src/arcaea_offline_ocr/device/rois/extractor/common.py
Normal file
@ -0,0 +1,49 @@
|
||||
import cv2
|
||||
|
||||
from ....crop import crop_xywh
|
||||
from ..definition.common import DeviceRois
|
||||
|
||||
|
||||
class DeviceRoisExtractor:
|
||||
def __init__(self, img: cv2.Mat, sizes: DeviceRois):
|
||||
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 jacket(self):
|
||||
return crop_xywh(self.img, self.__construct_int_rect(self.sizes.jacket))
|
||||
|
||||
@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))
|
Reference in New Issue
Block a user