mirror of
https://github.com/283375/arcaea-offline-ocr.git
synced 2025-07-01 20:36:27 +00:00
refactor: XYWHRect
and b30 ocr
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
from typing import List, Optional
|
||||
from typing import List
|
||||
|
||||
from ....crop import crop_xywh
|
||||
from ....types import Mat, XYWHRect
|
||||
from ....utils import apply_factor, construct_int_xywh_rect
|
||||
from ....utils import apply_factor
|
||||
|
||||
|
||||
class ChieriBotV4ComponentRois:
|
||||
def __init__(self, factor: Optional[float] = 1.0):
|
||||
def __init__(self, factor: float = 1.0):
|
||||
self.__factor = factor
|
||||
|
||||
@property
|
||||
@ -19,11 +19,11 @@ class ChieriBotV4ComponentRois:
|
||||
|
||||
@property
|
||||
def top_font_color_detect(self):
|
||||
return apply_factor((35, 10, 120, 100), self.factor)
|
||||
return apply_factor(XYWHRect(35, 10, 120, 100), self.factor)
|
||||
|
||||
@property
|
||||
def bottom_font_color_detect(self):
|
||||
return apply_factor((30, 125, 175, 110), self.factor)
|
||||
return apply_factor(XYWHRect(30, 125, 175, 110), self.factor)
|
||||
|
||||
@property
|
||||
def bg_point(self):
|
||||
@ -31,31 +31,31 @@ class ChieriBotV4ComponentRois:
|
||||
|
||||
@property
|
||||
def rating_class_rect(self):
|
||||
return apply_factor((21, 40, 7, 20), self.factor)
|
||||
return apply_factor(XYWHRect(21, 40, 7, 20), self.factor)
|
||||
|
||||
@property
|
||||
def title_rect(self):
|
||||
return apply_factor((35, 10, 430, 50), self.factor)
|
||||
return apply_factor(XYWHRect(35, 10, 430, 50), self.factor)
|
||||
|
||||
@property
|
||||
def jacket_rect(self):
|
||||
return apply_factor((263, 0, 239, 239), self.factor)
|
||||
return apply_factor(XYWHRect(263, 0, 239, 239), self.factor)
|
||||
|
||||
@property
|
||||
def score_rect(self):
|
||||
return apply_factor((30, 60, 270, 55), self.factor)
|
||||
return apply_factor(XYWHRect(30, 60, 270, 55), self.factor)
|
||||
|
||||
@property
|
||||
def pfl_rect(self):
|
||||
return apply_factor((50, 125, 80, 100), self.factor)
|
||||
return apply_factor(XYWHRect(50, 125, 80, 100), self.factor)
|
||||
|
||||
@property
|
||||
def date_rect(self):
|
||||
return apply_factor((205, 200, 225, 25), self.factor)
|
||||
return apply_factor(XYWHRect(205, 200, 225, 25), self.factor)
|
||||
|
||||
|
||||
class ChieriBotV4Rois:
|
||||
def __init__(self, factor: Optional[float] = 1.0):
|
||||
def __init__(self, factor: float = 1.0):
|
||||
self.__factor = factor
|
||||
self.__component_rois = ChieriBotV4ComponentRois(factor)
|
||||
|
||||
@ -100,9 +100,7 @@ class ChieriBotV4Rois:
|
||||
def horizontal_items(self):
|
||||
return 3
|
||||
|
||||
@property
|
||||
def vertical_items(self):
|
||||
return 10
|
||||
vertical_items = 10
|
||||
|
||||
@property
|
||||
def b33_vertical_gap(self):
|
||||
@ -112,16 +110,17 @@ class ChieriBotV4Rois:
|
||||
first_rect = XYWHRect(x=self.left, y=self.top, w=self.width, h=self.height)
|
||||
results = []
|
||||
|
||||
last_rect = first_rect
|
||||
for vi in range(self.vertical_items):
|
||||
rect = XYWHRect(*first_rect)
|
||||
rect += (0, (self.vertical_gap + self.height) * vi, 0, 0)
|
||||
for hi in range(self.horizontal_items):
|
||||
if hi > 0:
|
||||
rect += ((self.width + self.horizontal_gap), 0, 0, 0)
|
||||
int_rect = construct_int_xywh_rect(rect)
|
||||
results.append(crop_xywh(img_bgr, int_rect))
|
||||
results.append(crop_xywh(img_bgr, rect.rounded()))
|
||||
last_rect = rect
|
||||
|
||||
rect += (
|
||||
last_rect += (
|
||||
-(self.width + self.horizontal_gap) * 2,
|
||||
self.height + self.b33_vertical_gap,
|
||||
0,
|
||||
@ -129,8 +128,7 @@ class ChieriBotV4Rois:
|
||||
)
|
||||
for hi in range(self.horizontal_items):
|
||||
if hi > 0:
|
||||
rect += ((self.width + self.horizontal_gap), 0, 0, 0)
|
||||
int_rect = construct_int_xywh_rect(rect)
|
||||
results.append(crop_xywh(img_bgr, int_rect))
|
||||
last_rect += ((self.width + self.horizontal_gap), 0, 0, 0)
|
||||
results.append(crop_xywh(img_bgr, last_rect.rounded()))
|
||||
|
||||
return results
|
||||
|
Reference in New Issue
Block a user