diff --git a/ui/designer/tabs/tabOcr/tabOcr_Device.ui b/ui/designer/tabs/tabOcr/tabOcr_Device.ui
index 09be870..c7c81a0 100644
--- a/ui/designer/tabs/tabOcr/tabOcr_Device.ui
+++ b/ui/designer/tabs/tabOcr/tabOcr_Device.ui
@@ -27,6 +27,13 @@
deviceSelector.title
+ -
+
+
+ deviceSelector.useAutoFactor
+
+
+
-
diff --git a/ui/designer/tabs/tabOcr/tabOcr_Device_ui.py b/ui/designer/tabs/tabOcr/tabOcr_Device_ui.py
index 7c4f81c..e6d51cf 100644
--- a/ui/designer/tabs/tabOcr/tabOcr_Device_ui.py
+++ b/ui/designer/tabs/tabOcr/tabOcr_Device_ui.py
@@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'tabOcr_Device.ui'
##
-## Created by: Qt User Interface Compiler version 6.5.1
+## Created by: Qt User Interface Compiler version 6.5.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
@@ -15,8 +15,9 @@ from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
-from PySide6.QtWidgets import (QApplication, QGroupBox, QHBoxLayout, QPushButton,
- QSizePolicy, QStackedWidget, QVBoxLayout, QWidget)
+from PySide6.QtWidgets import (QApplication, QCheckBox, QGroupBox, QHBoxLayout,
+ QPushButton, QSizePolicy, QStackedWidget, QVBoxLayout,
+ QWidget)
from ui.implements.components.devicesComboBox import DevicesComboBox
from ui.implements.components.fileSelector import FileSelector
@@ -39,6 +40,11 @@ class Ui_TabOcr_Device(object):
self.groupBox.setObjectName(u"groupBox")
self.verticalLayout = QVBoxLayout(self.groupBox)
self.verticalLayout.setObjectName(u"verticalLayout")
+ self.deviceUseAutoFactorCheckBox = QCheckBox(self.groupBox)
+ self.deviceUseAutoFactorCheckBox.setObjectName(u"deviceUseAutoFactorCheckBox")
+
+ self.verticalLayout.addWidget(self.deviceUseAutoFactorCheckBox)
+
self.deviceFileSelector = FileSelector(self.groupBox)
self.deviceFileSelector.setObjectName(u"deviceFileSelector")
@@ -140,6 +146,7 @@ class Ui_TabOcr_Device(object):
def retranslateUi(self, TabOcr_Device):
self.openWizardButton.setText(QCoreApplication.translate("TabOcr_Device", u"openWizardButton", None))
self.groupBox.setTitle(QCoreApplication.translate("TabOcr_Device", u"deviceSelector.title", None))
+ self.deviceUseAutoFactorCheckBox.setText(QCoreApplication.translate("TabOcr_Device", u"deviceSelector.useAutoFactor", None))
self.groupBox_6.setTitle(QCoreApplication.translate("TabOcr_Device", u"knnModelSelector.title", None))
self.groupBox_4.setTitle(QCoreApplication.translate("TabOcr_Device", u"tesseractSelector.title", None))
self.groupBox_5.setTitle(QCoreApplication.translate("TabOcr_Device", u"siftDatabaseSelector.title", None))
diff --git a/ui/implements/tabs/tabOcr/tabOcr_Device.py b/ui/implements/tabs/tabOcr/tabOcr_Device.py
index 356c659..52a4aad 100644
--- a/ui/implements/tabs/tabOcr/tabOcr_Device.py
+++ b/ui/implements/tabs/tabOcr/tabOcr_Device.py
@@ -6,13 +6,17 @@ import cv2
from arcaea_offline_ocr.device.v1.definition import DeviceV1
from arcaea_offline_ocr.device.v2.definition import DeviceV2
from arcaea_offline_ocr.sift_db import SIFTDatabase
-from PySide6.QtCore import Slot
+from PySide6.QtCore import Qt, Slot
from PySide6.QtWidgets import QFileDialog, QWidget
from ui.designer.tabs.tabOcr.tabOcr_Device_ui import Ui_TabOcr_Device
from ui.extends.components.ocrQueue import OcrQueueModel
from ui.extends.shared.settings import Settings
-from ui.extends.tabs.tabOcr.tabOcr_Device import ScoreConverter, TabDeviceV2OcrRunnable
+from ui.extends.tabs.tabOcr.tabOcr_Device import (
+ ScoreConverter,
+ TabDeviceV2AutoRoisOcrRunnable,
+ TabDeviceV2OcrRunnable,
+)
logger = logging.getLogger(__name__)
@@ -23,10 +27,6 @@ class TabOcr_Device(Ui_TabOcr_Device, QWidget):
self.setupUi(self)
self.openWizardButton.setEnabled(False)
- self.deviceComboBox.currentIndexChanged.connect(
- self.changeDeviceDepStackedWidget
- )
-
self.deviceFileSelector.filesSelected.connect(self.deviceFileSelected)
self.knnModelSelector.filesSelected.connect(self.knnModelFileSelected)
self.tesseractFileSelector.filesSelected.connect(
@@ -52,6 +52,22 @@ class TabOcr_Device(Ui_TabOcr_Device, QWidget):
# wizard.open()
pass
+ @Slot()
+ def on_deviceUseAutoFactorCheckBox_stateChanged(self):
+ checkState = self.deviceUseAutoFactorCheckBox.checkState()
+ if checkState == Qt.CheckState.Checked:
+ self.deviceDependenciesStackedWidget.setCurrentIndex(1)
+ self.deviceComboBox.setCurrentIndex(-1)
+ self.deviceFileSelector.setEnabled(False)
+ self.deviceComboBox.setEnabled(False)
+ else:
+ self.deviceFileSelector.setEnabled(True)
+ self.deviceComboBox.setEnabled(True)
+
+ @Slot()
+ def on_deviceComboBox_currentIndexChanged(self):
+ self.changeDeviceDepStackedWidget()
+
def changeDeviceDepStackedWidget(self):
device = self.deviceComboBox.currentData()
if isinstance(device, (DeviceV1, DeviceV2)):
@@ -92,12 +108,19 @@ class TabOcr_Device(Ui_TabOcr_Device, QWidget):
for row in range(self.ocrQueueModel.rowCount()):
index = self.ocrQueueModel.index(row, 0)
imagePath = index.data(OcrQueueModel.ImagePathRole)
- runnable = TabDeviceV2OcrRunnable(
- imagePath,
- self.deviceComboBox.currentData(),
- self.knnModel,
- self.siftDatabase,
- )
+ if self.deviceUseAutoFactorCheckBox.checkState() == Qt.CheckState.Checked:
+ runnable = TabDeviceV2AutoRoisOcrRunnable(
+ imagePath,
+ self.knnModel,
+ self.siftDatabase,
+ )
+ else:
+ runnable = TabDeviceV2OcrRunnable(
+ imagePath,
+ self.deviceComboBox.currentData(),
+ self.knnModel,
+ self.siftDatabase,
+ )
self.ocrQueueModel.setData(index, runnable, OcrQueueModel.OcrRunnableRole)
self.ocrQueueModel.setData(
index,