mirror of
https://github.com/283375/arcaea-offline-ocr.git
synced 2025-04-18 13:00:18 +00:00
chore!: split Sizes
This commit is contained in:
parent
8389586ccd
commit
65430a30b8
@ -1,183 +1,15 @@
|
|||||||
from typing import Tuple, Union
|
from typing import Union
|
||||||
|
|
||||||
from ...crop import crop_black_edges, crop_xywh
|
from ...crop import crop_black_edges, crop_xywh
|
||||||
from ...types import Mat, XYWHRect
|
from ...types import Mat, XYWHRect
|
||||||
from .definition import DeviceV2
|
from .definition import DeviceV2
|
||||||
|
from .sizes import Sizes, SizesV1
|
||||||
|
|
||||||
|
|
||||||
def to_int(num: Union[int, float]) -> int:
|
def to_int(num: Union[int, float]) -> int:
|
||||||
return round(num)
|
return round(num)
|
||||||
|
|
||||||
|
|
||||||
def apply_factor(num: Union[int, float], factor: float):
|
|
||||||
return num * factor
|
|
||||||
|
|
||||||
|
|
||||||
class Sizes:
|
|
||||||
def __init__(self, factor: float):
|
|
||||||
raise NotImplementedError()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def TOP_BAR_HEIGHT(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def SCORE_PANEL(self) -> Tuple[int, int]:
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def PFL_TOP_FROM_VMID(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def PFL_LEFT_FROM_HMID(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def PFL_WIDTH(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def PFL_FONT_PX(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def PURE_FAR_GAP(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def FAR_LOST_GAP(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def SCORE_BOTTOM_FROM_VMID(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def SCORE_FONT_PX(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def SCORE_WIDTH(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def JACKET_RIGHT_FROM_HOR_MID(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def JACKET_WIDTH(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def MR_RT_RIGHT_FROM_HMID(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def MR_RT_WIDTH(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def MR_RT_HEIGHT(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def TITLE_BOTTOM_FROM_VMID(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def TITLE_FONT_PX(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
|
||||||
def TITLE_WIDTH_RIGHT(self):
|
|
||||||
...
|
|
||||||
|
|
||||||
|
|
||||||
class SizesV1(Sizes):
|
|
||||||
def __init__(self, factor: float):
|
|
||||||
self.factor = factor
|
|
||||||
|
|
||||||
def apply_factor(self, num):
|
|
||||||
return apply_factor(num, self.factor)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def TOP_BAR_HEIGHT(self):
|
|
||||||
return self.apply_factor(50)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def SCORE_PANEL(self) -> Tuple[int, int]:
|
|
||||||
return tuple(self.apply_factor(num) for num in [485, 239])
|
|
||||||
|
|
||||||
@property
|
|
||||||
def PFL_TOP_FROM_VMID(self):
|
|
||||||
return self.apply_factor(135)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def PFL_LEFT_FROM_HMID(self):
|
|
||||||
return self.apply_factor(5)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def PFL_WIDTH(self):
|
|
||||||
return self.apply_factor(76)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def PFL_FONT_PX(self):
|
|
||||||
return self.apply_factor(26)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def PURE_FAR_GAP(self):
|
|
||||||
return self.apply_factor(12)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def FAR_LOST_GAP(self):
|
|
||||||
return self.apply_factor(10)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def SCORE_BOTTOM_FROM_VMID(self):
|
|
||||||
return self.apply_factor(-50)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def SCORE_FONT_PX(self):
|
|
||||||
return self.apply_factor(45)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def SCORE_WIDTH(self):
|
|
||||||
return self.apply_factor(280)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def JACKET_RIGHT_FROM_HOR_MID(self):
|
|
||||||
return self.apply_factor(-235)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def JACKET_WIDTH(self):
|
|
||||||
return self.apply_factor(375)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def MR_RT_RIGHT_FROM_HMID(self):
|
|
||||||
return self.apply_factor(-300)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def MR_RT_WIDTH(self):
|
|
||||||
return self.apply_factor(275)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def MR_RT_HEIGHT(self):
|
|
||||||
return self.apply_factor(75)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def TITLE_BOTTOM_FROM_VMID(self):
|
|
||||||
return self.apply_factor(-265)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def TITLE_FONT_PX(self):
|
|
||||||
return self.apply_factor(40)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def TITLE_WIDTH_RIGHT(self):
|
|
||||||
return self.apply_factor(275)
|
|
||||||
|
|
||||||
|
|
||||||
class DeviceV2Rois:
|
class DeviceV2Rois:
|
||||||
def __init__(self, device: DeviceV2, img: Mat):
|
def __init__(self, device: DeviceV2, img: Mat):
|
||||||
self.device = device
|
self.device = device
|
||||||
|
174
src/arcaea_offline_ocr/device/v2/sizes.py
Normal file
174
src/arcaea_offline_ocr/device/v2/sizes.py
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
from typing import Tuple, Union
|
||||||
|
|
||||||
|
|
||||||
|
def to_int(num: Union[int, float]) -> int:
|
||||||
|
return round(num)
|
||||||
|
|
||||||
|
|
||||||
|
def apply_factor(num: Union[int, float], factor: float):
|
||||||
|
return num * factor
|
||||||
|
|
||||||
|
|
||||||
|
class Sizes:
|
||||||
|
def __init__(self, factor: float):
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def TOP_BAR_HEIGHT(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def SCORE_PANEL(self) -> Tuple[int, int]:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PFL_TOP_FROM_VMID(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PFL_LEFT_FROM_HMID(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PFL_WIDTH(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PFL_FONT_PX(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PURE_FAR_GAP(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def FAR_LOST_GAP(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def SCORE_BOTTOM_FROM_VMID(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def SCORE_FONT_PX(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def SCORE_WIDTH(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def JACKET_RIGHT_FROM_HOR_MID(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def JACKET_WIDTH(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def MR_RT_RIGHT_FROM_HMID(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def MR_RT_WIDTH(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def MR_RT_HEIGHT(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def TITLE_BOTTOM_FROM_VMID(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def TITLE_FONT_PX(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def TITLE_WIDTH_RIGHT(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
class SizesV1(Sizes):
|
||||||
|
def __init__(self, factor: float):
|
||||||
|
self.factor = factor
|
||||||
|
|
||||||
|
def apply_factor(self, num):
|
||||||
|
return apply_factor(num, self.factor)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def TOP_BAR_HEIGHT(self):
|
||||||
|
return self.apply_factor(50)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def SCORE_PANEL(self) -> Tuple[int, int]:
|
||||||
|
return tuple(self.apply_factor(num) for num in [485, 239])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PFL_TOP_FROM_VMID(self):
|
||||||
|
return self.apply_factor(135)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PFL_LEFT_FROM_HMID(self):
|
||||||
|
return self.apply_factor(5)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PFL_WIDTH(self):
|
||||||
|
return self.apply_factor(76)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PFL_FONT_PX(self):
|
||||||
|
return self.apply_factor(26)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PURE_FAR_GAP(self):
|
||||||
|
return self.apply_factor(12)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def FAR_LOST_GAP(self):
|
||||||
|
return self.apply_factor(10)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def SCORE_BOTTOM_FROM_VMID(self):
|
||||||
|
return self.apply_factor(-50)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def SCORE_FONT_PX(self):
|
||||||
|
return self.apply_factor(45)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def SCORE_WIDTH(self):
|
||||||
|
return self.apply_factor(280)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def JACKET_RIGHT_FROM_HOR_MID(self):
|
||||||
|
return self.apply_factor(-235)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def JACKET_WIDTH(self):
|
||||||
|
return self.apply_factor(375)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def MR_RT_RIGHT_FROM_HMID(self):
|
||||||
|
return self.apply_factor(-300)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def MR_RT_WIDTH(self):
|
||||||
|
return self.apply_factor(275)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def MR_RT_HEIGHT(self):
|
||||||
|
return self.apply_factor(75)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def TITLE_BOTTOM_FROM_VMID(self):
|
||||||
|
return self.apply_factor(-265)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def TITLE_FONT_PX(self):
|
||||||
|
return self.apply_factor(40)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def TITLE_WIDTH_RIGHT(self):
|
||||||
|
return self.apply_factor(275)
|
Loading…
x
Reference in New Issue
Block a user