mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-07-01 12:26:26 +00:00
wip: arcaea-offline==0.2.0
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import logging
|
||||
|
||||
from arcaea_offline.database import Database
|
||||
from arcaea_offline.models import Chart, Score
|
||||
from arcaea_offline.models import Score
|
||||
from arcaea_offline_ocr.b30.chieri.v4.ocr import ChieriBotV4Ocr
|
||||
from arcaea_offline_ocr.b30.shared import B30OcrResultItem
|
||||
from PySide6.QtGui import QImage
|
||||
@ -27,25 +27,26 @@ class ChieriV4OcrRunnable(OcrRunnable):
|
||||
self.signals.finished.emit()
|
||||
|
||||
|
||||
def b30ResultToScoreInsert(_, qImage: QImage, result: B30OcrResultItem):
|
||||
def b30ResultToScore(_: None, qImage: QImage, result: B30OcrResultItem):
|
||||
if not result.song_id and not result.title:
|
||||
raise ValueError("no title or song_id")
|
||||
|
||||
db = Database()
|
||||
if not result.song_id:
|
||||
song_id = db.fuzzy_search_song_id(result.title)[0][0]
|
||||
raise NotImplementedError("Not supported yet.")
|
||||
else:
|
||||
song_id = result.song_id
|
||||
|
||||
chart = Chart.from_db_row(db.get_chart(song_id, result.rating_class))
|
||||
score = ScoreInsert(
|
||||
chart = db.get_chart(song_id, result.rating_class)
|
||||
score = Score(
|
||||
song_id=song_id,
|
||||
rating_class=result.rating_class,
|
||||
score=result.score,
|
||||
time=1485014400,
|
||||
date=None,
|
||||
pure=result.pure,
|
||||
far=result.far,
|
||||
lost=result.lost,
|
||||
comment="B30 OCR",
|
||||
)
|
||||
|
||||
return (chart, score)
|
||||
|
@ -6,7 +6,7 @@ from arcaea_offline.database import Database
|
||||
from arcaea_offline.models import Chart, Score
|
||||
from arcaea_offline_ocr.device.shared import DeviceOcrResult
|
||||
from arcaea_offline_ocr.device.v2.ocr import DeviceV2Ocr
|
||||
from arcaea_offline_ocr.device.v2.rois import DeviceV2Rois
|
||||
from arcaea_offline_ocr.device.v2.rois import DeviceV2AutoRois, DeviceV2Rois
|
||||
from arcaea_offline_ocr.utils import imread_unicode
|
||||
from PySide6.QtCore import QDateTime, QFileInfo
|
||||
|
||||
@ -37,6 +37,25 @@ class TabDeviceV2OcrRunnable(OcrRunnable):
|
||||
self.signals.finished.emit()
|
||||
|
||||
|
||||
class TabDeviceV2AutoRoisOcrRunnable(OcrRunnable):
|
||||
def __init__(self, imagePath, knnModel, siftDb):
|
||||
super().__init__()
|
||||
self.imagePath = imagePath
|
||||
self.knnModel = knnModel
|
||||
self.siftDb = siftDb
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
rois = DeviceV2AutoRois(imread_unicode(self.imagePath))
|
||||
ocr = DeviceV2Ocr(self.knnModel, self.siftDb)
|
||||
result = ocr.ocr(rois)
|
||||
self.signals.resultReady.emit(result)
|
||||
except Exception:
|
||||
logger.exception(f"DeviceV2AutoRois ocr {self.imagePath} error")
|
||||
finally:
|
||||
self.signals.finished.emit()
|
||||
|
||||
|
||||
def getImageDate(imagePath: str) -> QDateTime:
|
||||
datetime = None
|
||||
with contextlib.suppress(Exception):
|
||||
@ -63,9 +82,7 @@ class ScoreConverter:
|
||||
lost=result.lost,
|
||||
date=getImageDate(imagePath).toSecsSinceEpoch(),
|
||||
max_recall=result.max_recall,
|
||||
r10_clear_type=None,
|
||||
comment=f"OCR {QFileInfo(imagePath).fileName()}",
|
||||
)
|
||||
print(f"OCR {QFileInfo(imagePath).fileName()}")
|
||||
chart = db.get_chart(score.song_id, score.rating_class)
|
||||
return (chart, score)
|
||||
|
Reference in New Issue
Block a user