mirror of
https://github.com/283375/arcaea-offline-ocr.git
synced 2025-04-22 15:00:18 +00:00
Compare commits
No commits in common. "580744b641db2fe068176f25b99c8020a6ae80c0" and "151b1fd6d866077253d7c32ead3c17c1d771a25c" have entirely different histories.
580744b641
...
151b1fd6d8
@ -1,2 +0,0 @@
|
|||||||
from .common import Extractor
|
|
||||||
from .sizes import *
|
|
@ -1,45 +1,5 @@
|
|||||||
import cv2
|
|
||||||
|
|
||||||
from ..crop import crop_xywh
|
|
||||||
from .sizes.common import Sizes
|
from .sizes.common import Sizes
|
||||||
|
|
||||||
|
|
||||||
class Extractor:
|
class Extractor:
|
||||||
def __init__(self, img: cv2.Mat, sizes: Sizes):
|
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))
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from .auto import *
|
|
@ -1,3 +0,0 @@
|
|||||||
from .common import AutoSizes
|
|
||||||
from .t1 import AutoSizesT1
|
|
||||||
from .t2 import AutoSizesT2
|
|
@ -1,7 +0,0 @@
|
|||||||
from ..common import Sizes
|
|
||||||
|
|
||||||
|
|
||||||
class AutoSizes(Sizes):
|
|
||||||
def __init__(self, w: int, h: int):
|
|
||||||
self.w = w
|
|
||||||
self.h = h
|
|
@ -1,123 +0,0 @@
|
|||||||
from .common import AutoSizes
|
|
||||||
|
|
||||||
|
|
||||||
class AutoSizesT1(AutoSizes):
|
|
||||||
@property
|
|
||||||
def factor(self):
|
|
||||||
return (
|
|
||||||
((self.w / 16) * 9) / 720 if (self.w / self.h) < (16 / 9) else self.h / 720
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def w_mid(self):
|
|
||||||
return self.w / 2
|
|
||||||
|
|
||||||
@property
|
|
||||||
def h_mid(self):
|
|
||||||
return self.h / 2
|
|
||||||
|
|
||||||
@property
|
|
||||||
def top_bar(self):
|
|
||||||
return (0, 0, self.w, 50 * self.factor)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def layout_area_h_mid(self):
|
|
||||||
return self.h / 2 + self.top_bar[3]
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pfl_left_from_w_mid(self):
|
|
||||||
return 5 * self.factor
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pfl_x(self):
|
|
||||||
return self.w_mid + self.pfl_left_from_w_mid
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pfl_w(self):
|
|
||||||
return 76 * self.factor
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pfl_h(self):
|
|
||||||
return 26 * self.factor
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pure(self):
|
|
||||||
return (
|
|
||||||
self.pfl_x,
|
|
||||||
self.layout_area_h_mid + 110 * self.factor,
|
|
||||||
self.pfl_w,
|
|
||||||
self.pfl_h,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def far(self):
|
|
||||||
return (
|
|
||||||
self.pfl_x,
|
|
||||||
self.pure[1] + self.pure[3] + 12 * self.factor,
|
|
||||||
self.pfl_w,
|
|
||||||
self.pfl_h,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def lost(self):
|
|
||||||
return (
|
|
||||||
self.pfl_x,
|
|
||||||
self.far[1] + self.far[3] + 10 * self.factor,
|
|
||||||
self.pfl_w,
|
|
||||||
self.pfl_h,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def score(self):
|
|
||||||
w = 280 * self.factor
|
|
||||||
h = 45 * self.factor
|
|
||||||
return (
|
|
||||||
self.w_mid - w / 2,
|
|
||||||
self.layout_area_h_mid - 75 * self.factor - h,
|
|
||||||
w,
|
|
||||||
h,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def rating_class(self):
|
|
||||||
return (
|
|
||||||
self.w_mid - 610 * self.factor,
|
|
||||||
self.layout_area_h_mid - 180 * self.factor,
|
|
||||||
265 * self.factor,
|
|
||||||
35 * self.factor,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_recall(self):
|
|
||||||
return (
|
|
||||||
self.w_mid - 465 * self.factor,
|
|
||||||
self.layout_area_h_mid - 215 * self.factor,
|
|
||||||
150 * self.factor,
|
|
||||||
35 * self.factor,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def jacket(self):
|
|
||||||
return (
|
|
||||||
self.w_mid - 610 * self.factor,
|
|
||||||
self.layout_area_h_mid - 143 * self.factor,
|
|
||||||
375 * self.factor,
|
|
||||||
375 * self.factor,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def clear_status(self):
|
|
||||||
w = 550 * self.factor
|
|
||||||
h = 60 * self.factor
|
|
||||||
return (
|
|
||||||
self.w_mid - w / 2,
|
|
||||||
self.layout_area_h_mid - 155 * self.factor - h,
|
|
||||||
w,
|
|
||||||
h,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def partner_icon(self):
|
|
||||||
w = 90 * self.factor
|
|
||||||
h = 75 * self.factor
|
|
||||||
return (self.w_mid - w / 2, 0, w, h)
|
|
@ -1,125 +0,0 @@
|
|||||||
from .common import AutoSizes
|
|
||||||
|
|
||||||
|
|
||||||
class AutoSizesT2(AutoSizes):
|
|
||||||
@property
|
|
||||||
def factor(self):
|
|
||||||
return (
|
|
||||||
((self.w / 16) * 9) / 1080
|
|
||||||
if (self.w / self.h) < (16 / 9)
|
|
||||||
else self.h / 1080
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def w_mid(self):
|
|
||||||
return self.w / 2
|
|
||||||
|
|
||||||
@property
|
|
||||||
def h_mid(self):
|
|
||||||
return self.h / 2
|
|
||||||
|
|
||||||
@property
|
|
||||||
def top_bar(self):
|
|
||||||
return (0, 0, self.w, 75 * self.factor)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def layout_area_h_mid(self):
|
|
||||||
return self.h / 2 + self.top_bar[3]
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pfl_mid_from_w_mid(self):
|
|
||||||
return 60 * self.factor
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pfl_x(self):
|
|
||||||
return self.w_mid + 10 * self.factor
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pfl_w(self):
|
|
||||||
return 100 * self.factor
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pfl_h(self):
|
|
||||||
return 24 * self.factor
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pure(self):
|
|
||||||
return (
|
|
||||||
self.pfl_x,
|
|
||||||
self.layout_area_h_mid + 175 * self.factor,
|
|
||||||
self.pfl_w,
|
|
||||||
self.pfl_h,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def far(self):
|
|
||||||
return (
|
|
||||||
self.pfl_x,
|
|
||||||
self.pure[1] + self.pure[3] + 30 * self.factor,
|
|
||||||
self.pfl_w,
|
|
||||||
self.pfl_h,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def lost(self):
|
|
||||||
return (
|
|
||||||
self.pfl_x,
|
|
||||||
self.far[1] + self.far[3] + 35 * self.factor,
|
|
||||||
self.pfl_w,
|
|
||||||
self.pfl_h,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def score(self):
|
|
||||||
w = 420 * self.factor
|
|
||||||
h = 70 * self.factor
|
|
||||||
return (
|
|
||||||
self.w_mid - w / 2,
|
|
||||||
self.layout_area_h_mid - 110 * self.factor - h,
|
|
||||||
w,
|
|
||||||
h,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def rating_class(self):
|
|
||||||
return (
|
|
||||||
max(0, self.w_mid - 965 * self.factor),
|
|
||||||
self.layout_area_h_mid - 330 * self.factor,
|
|
||||||
350 * self.factor,
|
|
||||||
110 * self.factor,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_recall(self):
|
|
||||||
return (
|
|
||||||
self.w_mid - 625 * self.factor,
|
|
||||||
self.layout_area_h_mid - 275 * self.factor,
|
|
||||||
150 * self.factor,
|
|
||||||
50 * self.factor,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def jacket(self):
|
|
||||||
return (
|
|
||||||
self.w_mid - 915 * self.factor,
|
|
||||||
self.layout_area_h_mid - 215 * self.factor,
|
|
||||||
565 * self.factor,
|
|
||||||
565 * self.factor,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def clear_status(self):
|
|
||||||
w = 825 * self.factor
|
|
||||||
h = 90 * self.factor
|
|
||||||
return (
|
|
||||||
self.w_mid - w / 2,
|
|
||||||
self.layout_area_h_mid - 235 * self.factor - h,
|
|
||||||
w,
|
|
||||||
h,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def partner_icon(self):
|
|
||||||
w = 135 * self.factor
|
|
||||||
h = 110 * self.factor
|
|
||||||
return (self.w_mid - w / 2, 0, w, h)
|
|
Loading…
x
Reference in New Issue
Block a user