ok-script 0.0.16__tar.gz → 0.0.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ok-script-0.0.16 → ok-script-0.0.18}/PKG-INFO +1 -1
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/OK.py +1 -1
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/feature/Box.py +7 -6
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/debug/Screenshot.py +9 -4
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/TaskCard.py +1 -1
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/ocr/OCR.py +41 -5
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/task/ExecutorOperation.py +3 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok_script.egg-info/PKG-INFO +1 -1
- {ok-script-0.0.16 → ok-script-0.0.18}/setup.py +1 -1
- {ok-script-0.0.16 → ok-script-0.0.18}/README.md +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/BaseCaptureMethod.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/HwndWindow.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/adb/ADBCaptureMethod.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/adb/DeviceManager.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/adb/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/adb/bin/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/adb/targets.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/adb/vbox.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/windows/WindowsGraphicsCaptureMethod.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/windows/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/windows/d3d11.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/windows/utils.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/capture/windows/window.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/color/Color.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/color/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/config/Config.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/config/InfoDict.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/config/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/feature/Feature.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/feature/FeatureSet.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/feature/FindFeature.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/feature/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/App.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/Communicate.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/MainWindow.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/TabTitles.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/about/AboutTab.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/about/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/common/OKIcon.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/common/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/common/config.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/common/style_sheet.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/debug/AspectRatioWidget.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/debug/DebugTab.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/debug/FrameWidget.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/debug/InfoWidget.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/debug/LoggerWidget.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/debug/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/i18n/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/i18n/path.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/i18n/update.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/icon/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/icon/icon.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/overlay/OverlayWindow.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/overlay/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/qss/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/resources.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/settings/SettingTab.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/settings/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/start/SelectCaptureListView.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/start/SelectHwndWindow.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/start/StartCard.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/start/StartTab.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/start/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/ConfigItemFactory.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/ConfigLabelAndWidget.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/LabelAndDoubleSpinBox.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/LabelAndLineEdit.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/LabelAndList.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/LabelAndSpinBox.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/LabelAndSwitchButton.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/LabelAndWidget.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/ModifyListDialog.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/ModifyListItem.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/OneTimeTaskTab.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/StartButton.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/TaskOpButton.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/TooltipTableWidget.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/TriggerTaskTab.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/tasks/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/util/Alert.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/util/InitWorker.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/util/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/widget/Card.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/widget/FramelessDialog.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/widget/ListTableWidgetItem.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/widget/NumericTableWidgetItem.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/widget/StatusBar.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/widget/Tab.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/widget/TabWidget.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/widget/UpdateConfigWidgetItem.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/widget/YesNonWidgetItem.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/gui/widget/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/interaction/ADBInteraction.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/interaction/BaseInteraction.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/interaction/Win32Interaction.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/interaction/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/logging/Logger.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/logging/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/ocr/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/predict/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/predict/predict.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Foundation/Collections.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Foundation/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Globalization/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Graphics/Capture/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Graphics/DirectX/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Graphics/Imaging/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Graphics/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Media/Ocr/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Media/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Security/Cryptography/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Security/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Storage/Streams/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Storage/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/delegate.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/export.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/idldsl.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/inspectable.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/roapi.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/types.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/winstring.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/save/BlackBarProcessor.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/save/PostProcessor.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/save/SaveByInterval.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/save/SaveByKeyPress.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/save/SaveMethodBase.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/save/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/scene/FeatureScene.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/scene/Scene.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/scene/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/stats/StreamStats.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/stats/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/task/BaseTask.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/task/OneTimeTask.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/task/TaskExecutor.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/task/TriggerTask.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/task/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/util/__init__.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/util/json.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/util/list.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/util/path.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/util/thread.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/util/win32_process.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok/util/yaml.py +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok_script.egg-info/SOURCES.txt +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok_script.egg-info/dependency_links.txt +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok_script.egg-info/requires.txt +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/ok_script.egg-info/top_level.txt +0 -0
- {ok-script-0.0.16 → ok-script-0.0.18}/setup.cfg +0 -0
|
@@ -82,7 +82,7 @@ class OK:
|
|
|
82
82
|
def do_init(self):
|
|
83
83
|
logger.info(f"initializing {self.__class__.__name__}, config: {self.config}")
|
|
84
84
|
if self.config.get('ocr'):
|
|
85
|
-
from
|
|
85
|
+
from rapidocr_openvino import RapidOCR
|
|
86
86
|
self.ocr = RapidOCR()
|
|
87
87
|
|
|
88
88
|
config_logger(self.config)
|
|
@@ -91,14 +91,14 @@ class Box:
|
|
|
91
91
|
return self.x + self.width / 2, self.y + self.height / 2
|
|
92
92
|
|
|
93
93
|
def find_closest_box(self, direction: str, boxes: list, condition=None):
|
|
94
|
-
|
|
94
|
+
orig_x, orig_y, orig_w, orig_h = self.x, self.y, self.width, self.height
|
|
95
95
|
|
|
96
96
|
def distance_criteria(box):
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
box_x, box_y, box_w, box_h = box.x, box.y, box.width, box.height
|
|
98
|
+
|
|
99
|
+
dx = max(orig_x - (box_x + box_w), box_x - (orig_x + orig_w), 0)
|
|
100
|
+
dy = max(orig_y - (box_y + box_h), box_y - (orig_y + orig_h), 0)
|
|
99
101
|
|
|
100
|
-
dx = box_center_x - orig_center_x
|
|
101
|
-
dy = box_center_y - orig_center_y
|
|
102
102
|
distance = math.sqrt(dx ** 2 + dy ** 2)
|
|
103
103
|
if box == self:
|
|
104
104
|
distance = float('inf')
|
|
@@ -110,6 +110,8 @@ class Box:
|
|
|
110
110
|
pass
|
|
111
111
|
elif direction == 'right' and box.x - (self.x + self.width / 2) >= 0:
|
|
112
112
|
pass
|
|
113
|
+
elif direction == 'all':
|
|
114
|
+
pass
|
|
113
115
|
else:
|
|
114
116
|
distance = float('inf')
|
|
115
117
|
return check_condition(box, distance)
|
|
@@ -121,7 +123,6 @@ class Box:
|
|
|
121
123
|
return float('inf')
|
|
122
124
|
|
|
123
125
|
filtered_boxes = sorted(boxes, key=distance_criteria)
|
|
124
|
-
# Removed debug print statement for cleanliness
|
|
125
126
|
|
|
126
127
|
for box in filtered_boxes:
|
|
127
128
|
if distance_criteria(box) != float('inf'):
|
|
@@ -13,7 +13,7 @@ import ok.gui
|
|
|
13
13
|
from ok.feature.Box import Box
|
|
14
14
|
from ok.gui.Communicate import communicate
|
|
15
15
|
from ok.logging.Logger import get_logger
|
|
16
|
-
from ok.util.path import get_path_relative_to_exe, find_first_existing_file, clear_folder
|
|
16
|
+
from ok.util.path import get_path_relative_to_exe, find_first_existing_file, clear_folder, sanitize_filename
|
|
17
17
|
|
|
18
18
|
logger = get_logger(__name__)
|
|
19
19
|
|
|
@@ -130,10 +130,15 @@ class Screenshot(QObject):
|
|
|
130
130
|
|
|
131
131
|
# Convert to string with milliseconds
|
|
132
132
|
time_string = now.strftime("%H_%M_%S_%f")
|
|
133
|
+
file_name = time_string
|
|
133
134
|
if name:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
name = sanitize_filename(name)
|
|
136
|
+
file_name = f"{time_string}_{name}"
|
|
137
|
+
file = os.path.join(folder, f"{file_name}.png")
|
|
138
|
+
try:
|
|
139
|
+
pil_image.save(file)
|
|
140
|
+
except OSError:
|
|
141
|
+
pil_image.save(os.path.join(folder, f"{time_string}.png"))
|
|
137
142
|
|
|
138
143
|
def stop(self):
|
|
139
144
|
if self.task_queue is not None:
|
|
@@ -116,7 +116,7 @@ class TaskButtons(QWidget):
|
|
|
116
116
|
self.start_button.setText(self.tr("Resume"))
|
|
117
117
|
self.start_button.show()
|
|
118
118
|
self.pause_button.hide()
|
|
119
|
-
self.stop_button.
|
|
119
|
+
self.stop_button.show()
|
|
120
120
|
elif self.task.running:
|
|
121
121
|
self.start_button.hide()
|
|
122
122
|
self.stop_button.show()
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import time
|
|
2
2
|
|
|
3
|
+
import cv2
|
|
4
|
+
|
|
3
5
|
from ok.feature.Box import Box, sort_boxes, find_boxes_by_name
|
|
4
6
|
from ok.gui.Communicate import communicate
|
|
5
7
|
from ok.logging.Logger import get_logger
|
|
@@ -9,22 +11,31 @@ logger = get_logger(__name__)
|
|
|
9
11
|
|
|
10
12
|
class OCR:
|
|
11
13
|
executor = None
|
|
12
|
-
|
|
14
|
+
ocr_default_threshold = 0.5
|
|
15
|
+
ocr_target_height = 0
|
|
13
16
|
|
|
14
|
-
def ocr(self, box: Box = None, match=None, threshold=0):
|
|
17
|
+
def ocr(self, box: Box = None, match=None, threshold=0, frame=None, target_height=0):
|
|
15
18
|
if self.paused:
|
|
16
19
|
self.sleep(1)
|
|
17
20
|
if threshold == 0:
|
|
18
|
-
threshold = self.
|
|
21
|
+
threshold = self.ocr_default_threshold
|
|
22
|
+
if target_height == 0:
|
|
23
|
+
target_height = self.ocr_target_height
|
|
19
24
|
start = time.time()
|
|
20
|
-
|
|
25
|
+
if frame is not None:
|
|
26
|
+
image = frame
|
|
27
|
+
else:
|
|
28
|
+
image = self.frame
|
|
21
29
|
if image is None:
|
|
22
30
|
raise Exception("ocr no frame")
|
|
23
31
|
else:
|
|
32
|
+
original_height = image.shape[0]
|
|
24
33
|
if box is not None:
|
|
25
34
|
x, y, w, h = box.x, box.y, box.width, box.height
|
|
26
35
|
image = image[y:y + h, x:x + w]
|
|
27
36
|
|
|
37
|
+
image, scale_factor = resize_image(image, original_height, target_height)
|
|
38
|
+
|
|
28
39
|
result, _ = self.executor.ocr(image, use_det=True, use_cls=False, use_rec=True)
|
|
29
40
|
detected_boxes = []
|
|
30
41
|
# Process the results and create Box objects
|
|
@@ -37,18 +48,43 @@ class OCR:
|
|
|
37
48
|
detected_box = Box(int(pos[0][0]), int(pos[0][1]), int(pos[2][0] - pos[0][0]),
|
|
38
49
|
int(pos[2][1] - pos[0][1]),
|
|
39
50
|
confidence, text)
|
|
51
|
+
scale_box(detected_box, scale_factor)
|
|
40
52
|
if box is not None:
|
|
41
53
|
detected_box.x += box.x
|
|
42
54
|
detected_box.y += box.y
|
|
43
55
|
detected_boxes.append(detected_box)
|
|
44
56
|
if match is not None:
|
|
45
57
|
detected_boxes = find_boxes_by_name(detected_boxes, match)
|
|
58
|
+
|
|
46
59
|
communicate.emit_draw_box("ocr", detected_boxes, "red")
|
|
47
60
|
communicate.emit_draw_box("ocr_zone", box, "blue")
|
|
48
|
-
logger.debug(
|
|
61
|
+
logger.debug(
|
|
62
|
+
f"ocr_zone {box} found result: {len(detected_boxes)}) time: {(time.time() - start):.2f} scale_factor: {scale_factor:.2f}")
|
|
49
63
|
return sort_boxes(detected_boxes)
|
|
50
64
|
|
|
51
65
|
def find_text(self, text, box: Box = None, confidence=0):
|
|
52
66
|
for result in self.ocr(box, confidence):
|
|
53
67
|
if result.name == text:
|
|
54
68
|
return result
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def resize_image(image, original_height, target_height):
|
|
72
|
+
scale_factor = 1
|
|
73
|
+
if target_height > 0 and original_height >= 2 * target_height:
|
|
74
|
+
image_height, image_width = image.shape[:2]
|
|
75
|
+
times = int(original_height / target_height)
|
|
76
|
+
scale_factor = 1 / times
|
|
77
|
+
# Calculate the new width to maintain the aspect ratio
|
|
78
|
+
new_width = round(image_width * scale_factor)
|
|
79
|
+
new_height = round(image_height * scale_factor)
|
|
80
|
+
# Resize the image
|
|
81
|
+
image = cv2.resize(image, (new_width, new_height))
|
|
82
|
+
return image, scale_factor
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def scale_box(box, scale_factor):
|
|
86
|
+
if scale_factor != 1:
|
|
87
|
+
box.x = round(box.x / scale_factor)
|
|
88
|
+
box.y = round(box.y / scale_factor)
|
|
89
|
+
box.width = round(box.width / scale_factor)
|
|
90
|
+
box.height = round(box.height / scale_factor)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ok-script-0.0.16 → ok-script-0.0.18}/ok/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|