ascript 1.3.27__py3-none-win_amd64.whl
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.
- ascript/__init__.py +8 -0
- ascript/hooks/__init__.py +0 -0
- ascript/hooks/hook-ascript.py +2 -0
- ascript/windows/__init__.py +29 -0
- ascript/windows/daos/__init__.py +0 -0
- ascript/windows/daos/screen.py +143 -0
- ascript/windows/hardware/__init__.py +5 -0
- ascript/windows/hardware/keyboard.py +279 -0
- ascript/windows/hardware/logitech_driver.py +179 -0
- ascript/windows/hardware/mouse.py +308 -0
- ascript/windows/license/__init__.py +16 -0
- ascript/windows/license/achttp.cp310-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp311-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp312-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp313-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp314-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp38-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp39-win_amd64.pyd +0 -0
- ascript/windows/media/__init__.py +0 -0
- ascript/windows/resources/__init__.py +0 -0
- ascript/windows/resources/libs/logitech/x64/LogitechGkeyEnginesWrapper.dll +0 -0
- ascript/windows/resources/libs/logitech/x86/LogitechGkeyEnginesWrapper.dll +0 -0
- ascript/windows/resources/templates/__init__.py +0 -0
- ascript/windows/resources/templates/__init__py.win.template +51 -0
- ascript/windows/resources/templates/build.as.win.template +14 -0
- ascript/windows/resources/templates/build.py +71 -0
- ascript/windows/resources/templates/logo_windows.ico +0 -0
- ascript/windows/resources/templates/windows/main.py +50 -0
- ascript/windows/resources/templates/windows/pyproject.toml +44 -0
- ascript/windows/resources/templates/windows/res/img/logo.ico +0 -0
- ascript/windows/screen/__init__.py +13 -0
- ascript/windows/screen/as_cv.py +382 -0
- ascript/windows/screen/canny.py +128 -0
- ascript/windows/screen/code_scanner.py +72 -0
- ascript/windows/screen/color_algorithms.py +277 -0
- ascript/windows/screen/find_colors.py +251 -0
- ascript/windows/screen/find_images.py +217 -0
- ascript/windows/screen/ocr/__init__.py +4 -0
- ascript/windows/screen/ocr/ocr.py +223 -0
- ascript/windows/screen/ocr/rapidocr_hook.py +301 -0
- ascript/windows/screen/ocrx.py +169 -0
- ascript/windows/screen/screen_core.py +139 -0
- ascript/windows/store/__init__.py +21 -0
- ascript/windows/system/__init__.py +8 -0
- ascript/windows/system/device.py +355 -0
- ascript/windows/system/easy_print.py +115 -0
- ascript/windows/system/env.py +492 -0
- ascript/windows/system/exception/__init__.py +1 -0
- ascript/windows/system/key_value.py +145 -0
- ascript/windows/system/pip.py +175 -0
- ascript/windows/system/r.py +165 -0
- ascript/windows/system/runtime.py +62 -0
- ascript/windows/tools/__init__.py +27 -0
- ascript/windows/tools/__main__.py +21 -0
- ascript/windows/tools/action.json +33 -0
- ascript/windows/tools/action.py +168 -0
- ascript/windows/tools/colors_tool.py +391 -0
- ascript/windows/tools/config.py +26 -0
- ascript/windows/tools/dumptool.py +18 -0
- ascript/windows/tools/eel_api.py +495 -0
- ascript/windows/tools/gpplug/__init__.py +0 -0
- ascript/windows/tools/gpplug/plug.py +70 -0
- ascript/windows/tools/mouse_catch.py +168 -0
- ascript/windows/tools/plug_manager.py +38 -0
- ascript/windows/tools/tool_api.py +906 -0
- ascript/windows/tools/tool_window.py +56 -0
- ascript/windows/tools/uia_worker.py +365 -0
- ascript/windows/tools/web/app_store_window.html +481 -0
- ascript/windows/tools/web/colors.html +532 -0
- ascript/windows/tools/web/css/screen.css +1342 -0
- ascript/windows/tools/web/css/viewtree.css +357 -0
- ascript/windows/tools/web/flot_control.html +195 -0
- ascript/windows/tools/web/img/ico/favicon.png +0 -0
- ascript/windows/tools/web/img/ico/paintpalette.png +0 -0
- ascript/windows/tools/web/img/svg/find_colors.svg +1 -0
- ascript/windows/tools/web/img/svg/find_images.svg +1 -0
- ascript/windows/tools/web/img/svg/illustration-6.svg +89 -0
- ascript/windows/tools/web/img/svg/img_default.svg +1 -0
- ascript/windows/tools/web/img/svg/ocr.svg +1 -0
- ascript/windows/tools/web/js/screen/colors.js +466 -0
- ascript/windows/tools/web/js/screen/gp_plug.js +108 -0
- ascript/windows/tools/web/js/screen/image_mouse.js +464 -0
- ascript/windows/tools/web/js/screen/img_view.js +558 -0
- ascript/windows/tools/web/js/screen/plug.js +246 -0
- ascript/windows/tools/web/js/screen/screen.js +690 -0
- ascript/windows/tools/web/js/screen/screen_api.js +778 -0
- ascript/windows/tools/web/js/screen/screen_maker.js +10 -0
- ascript/windows/tools/web/js/utils/map.js +73 -0
- ascript/windows/tools/web/js/utils/upload.js +157 -0
- ascript/windows/tools/web/js/viewtree/niv_js.js +27 -0
- ascript/windows/tools/web/js/viewtree/vtree.js +1510 -0
- ascript/windows/tools/web/libs/bootstrap/css/bootstrap.min.css +6 -0
- ascript/windows/tools/web/libs/bootstrap/js/bootstrap.bundle.min.js +7 -0
- ascript/windows/tools/web/libs/bootstrap-icons/0-circle.svg +4 -0
- ascript/windows/tools/web/libs/bootstrap-icons/0-square.svg +4 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.css +2078 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.json +2052 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.min.css +5 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.scss +2090 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/fonts/bootstrap-icons.woff +0 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/fonts/bootstrap-icons.woff2 +0 -0
- ascript/windows/tools/web/libs/feather-icons/dist/feather.min.js +13 -0
- ascript/windows/tools/web/libs/feather-icons/dist/icons.json +1 -0
- ascript/windows/tools/web/libs/jquery/core.js +399 -0
- ascript/windows/tools/web/libs/jquery/jquery.js +10598 -0
- ascript/windows/tools/web/libs/jquery/jquery.min.js +4 -0
- ascript/windows/tools/web/libs/jquery/jquery.min.js.zip +0 -0
- ascript/windows/tools/web/libs/jquery/jquery.slim.js +8495 -0
- ascript/windows/tools/web/libs/jquery/jquery.slim.min.js +2 -0
- ascript/windows/tools/web/libs/jquery-menu/jquery.contextMenu.js +2134 -0
- ascript/windows/tools/web/libs/jquery-menu/jquery.contextMenu.min.css +16 -0
- ascript/windows/tools/web/libs/jquery-zTree/css/zTreeStyle.css +97 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/1_close.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/1_open.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/2.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/3.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/4.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/5.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/6.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/7.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/8.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/9.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/line_conn.gif +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/loading.gif +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/tree-node-btn.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/zTreeStandard.gif +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/zTreeStandard.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/js/jquery.ztree.all.min.js +3 -0
- ascript/windows/tools/web/libs/treeview/css/jquery.treeview.css +79 -0
- ascript/windows/tools/web/libs/treeview/img/file.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/ico_loading.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/icon4.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/icon5.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/icon6.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/py.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-black-line.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-black.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-default-line.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-default.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-famfamfam-line.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-famfamfam.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-gray-line.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-gray.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-red-line.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-red.gif +0 -0
- ascript/windows/tools/web/libs/treeview/js/jquery.treeview.edit.js +37 -0
- ascript/windows/tools/web/libs/treeview/js/jquery.treeview.js +250 -0
- ascript/windows/tools/web/license_window.html +255 -0
- ascript/windows/tools/web/plugs/a.html +653 -0
- ascript/windows/tools/web/plugs/demo.html +52 -0
- ascript/windows/tools/web/plugs/find_colors.html +629 -0
- ascript/windows/tools/web/plugs/find_images.html +699 -0
- ascript/windows/tools/web/plugs/rapidocr.html +954 -0
- ascript/windows/tools/web/vtree.html +496 -0
- ascript/windows/tools/webview/assets/index-HymBPl-I.css +1 -0
- ascript/windows/tools/webview/assets/index-PqA_m8tL.js +17 -0
- ascript/windows/tools/webview/index.html +13 -0
- ascript/windows/ui/__init__.py +6 -0
- ascript/windows/ui/app_store_window.py +272 -0
- ascript/windows/ui/draw_window.py +231 -0
- ascript/windows/ui/flot_test.py +297 -0
- ascript/windows/ui/flot_window.py +488 -0
- ascript/windows/ui/license_window.py +111 -0
- ascript/windows/ui/web_window.py +466 -0
- ascript/windows/utils/__init__.py +0 -0
- ascript/windows/utils/node_utils.py +20 -0
- ascript/windows/utils/screen_utils.py +280 -0
- ascript/windows/window/Selector.py +1015 -0
- ascript/windows/window/Window.py +747 -0
- ascript/windows/window/__init__.py +5 -0
- ascript/windows/window/launcher.py +213 -0
- ascript/windows/window/uia_runtime.py +26 -0
- ascript-1.3.27.dist-info/METADATA +41 -0
- ascript-1.3.27.dist-info/RECORD +177 -0
- ascript-1.3.27.dist-info/WHEEL +5 -0
- ascript-1.3.27.dist-info/entry_points.txt +2 -0
- ascript-1.3.27.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<title>RapidOCR Visual Tool</title>
|
|
7
|
+
<link href="../libs/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
|
8
|
+
<link href="../libs/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
|
|
9
|
+
|
|
10
|
+
<style>
|
|
11
|
+
:root {
|
|
12
|
+
--editor-bg: #1e1e1e;
|
|
13
|
+
--panel-bg: #252526;
|
|
14
|
+
--border-color: #333333;
|
|
15
|
+
--accent-color: #007acc;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
html,
|
|
19
|
+
body {
|
|
20
|
+
height: 100%;
|
|
21
|
+
margin: 0;
|
|
22
|
+
background: var(--editor-bg);
|
|
23
|
+
color: #ccc;
|
|
24
|
+
font-size: 13px;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.main-layout {
|
|
29
|
+
display: flex;
|
|
30
|
+
height: 100vh;
|
|
31
|
+
width: 100vw;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* ---------- 左侧面板 ---------- */
|
|
35
|
+
.settings-panel {
|
|
36
|
+
width: 320px;
|
|
37
|
+
background: var(--panel-bg);
|
|
38
|
+
border-right: 1px solid var(--border-color);
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
padding: 12px;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.section-title {
|
|
46
|
+
color: var(--accent-color);
|
|
47
|
+
font-size: 10px;
|
|
48
|
+
font-weight: bold;
|
|
49
|
+
margin: 14px 0 8px;
|
|
50
|
+
border-bottom: 1px solid #333;
|
|
51
|
+
text-transform: uppercase;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.form-label {
|
|
55
|
+
font-size: 11px;
|
|
56
|
+
color: #888;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.form-select {
|
|
60
|
+
background: #3c3c3c;
|
|
61
|
+
border: 1px solid #3c3c3c;
|
|
62
|
+
color: #eee;
|
|
63
|
+
font-size: 11px;
|
|
64
|
+
height: 26px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* ---------- 结果列表 ---------- */
|
|
68
|
+
.results-wrapper {
|
|
69
|
+
margin-top: 10px;
|
|
70
|
+
border: 1px solid #333;
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
height: 100%;
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.results-header {
|
|
78
|
+
padding: 6px 8px;
|
|
79
|
+
font-size: 11px;
|
|
80
|
+
background: #1b1b1b;
|
|
81
|
+
border-bottom: 1px solid #333;
|
|
82
|
+
display: flex;
|
|
83
|
+
justify-content: space-between;
|
|
84
|
+
align-items: center;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.results-list {
|
|
88
|
+
flex: 1;
|
|
89
|
+
overflow-y: auto;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.ocr-item {
|
|
93
|
+
padding: 6px;
|
|
94
|
+
font-size: 11px;
|
|
95
|
+
display: flex;
|
|
96
|
+
gap: 6px;
|
|
97
|
+
border-bottom: 1px solid #333;
|
|
98
|
+
cursor: pointer;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ocr-item:hover {
|
|
102
|
+
background: #2a2a2a;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* ---------- 工作区 ---------- */
|
|
106
|
+
.workspace {
|
|
107
|
+
flex: 1;
|
|
108
|
+
display: flex;
|
|
109
|
+
flex-direction: column;
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.canvas-area {
|
|
114
|
+
flex: 1;
|
|
115
|
+
background: #111;
|
|
116
|
+
overflow: auto;
|
|
117
|
+
/* 允许滚动 */
|
|
118
|
+
display: flex;
|
|
119
|
+
justify-content: flex-start;
|
|
120
|
+
/* 左上角对齐 */
|
|
121
|
+
align-items: flex-start;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.img-viewport {
|
|
125
|
+
width: 100%;
|
|
126
|
+
height: 100%;
|
|
127
|
+
display: flex;
|
|
128
|
+
justify-content: center;
|
|
129
|
+
align-items: center;
|
|
130
|
+
background: #111;
|
|
131
|
+
overflow: hidden; /* 不显示滚动条 */
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.img-viewport img {
|
|
135
|
+
max-width: 100%;
|
|
136
|
+
max-height: 100%;
|
|
137
|
+
display: block;
|
|
138
|
+
cursor: pointer; /* 鼠标悬浮显示可点击 */
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
.code-console {
|
|
144
|
+
height: 35%;
|
|
145
|
+
background: #000;
|
|
146
|
+
border-top: 1px solid #333;
|
|
147
|
+
display: flex;
|
|
148
|
+
flex-direction: column;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.code-display {
|
|
152
|
+
flex: 1;
|
|
153
|
+
padding: 10px;
|
|
154
|
+
font-family: Consolas, monospace;
|
|
155
|
+
font-size: 11px;
|
|
156
|
+
color: #9cdcfe;
|
|
157
|
+
overflow: auto;
|
|
158
|
+
white-space: pre;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/* ---------- 初始化遮罩 ---------- */
|
|
162
|
+
#init-overlay {
|
|
163
|
+
position: fixed;
|
|
164
|
+
inset: 0;
|
|
165
|
+
background: rgba(30, 30, 30, 0.98);
|
|
166
|
+
z-index: 9999;
|
|
167
|
+
display: flex;
|
|
168
|
+
flex-direction: column;
|
|
169
|
+
align-items: center;
|
|
170
|
+
justify-content: center;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
#log-container {
|
|
174
|
+
width: 420px;
|
|
175
|
+
height: 160px;
|
|
176
|
+
background: #000;
|
|
177
|
+
color: #0f0;
|
|
178
|
+
font-family: monospace;
|
|
179
|
+
font-size: 11px;
|
|
180
|
+
padding: 8px;
|
|
181
|
+
border: 1px solid #444;
|
|
182
|
+
overflow-y: auto;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* results-list 和 log-container 滚动条 */
|
|
186
|
+
.results-list::-webkit-scrollbar,
|
|
187
|
+
#log-container::-webkit-scrollbar {
|
|
188
|
+
width: 8px;
|
|
189
|
+
height: 8px;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.results-list::-webkit-scrollbar-track,
|
|
193
|
+
#log-container::-webkit-scrollbar-track {
|
|
194
|
+
background: #1b1b1b;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.results-list::-webkit-scrollbar-thumb,
|
|
198
|
+
#log-container::-webkit-scrollbar-thumb {
|
|
199
|
+
background-color: rgba(100, 100, 100, 0.6);
|
|
200
|
+
border-radius: 4px;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.results-list::-webkit-scrollbar-thumb:hover,
|
|
204
|
+
#log-container::-webkit-scrollbar-thumb:hover {
|
|
205
|
+
background-color: rgba(150, 150, 150, 0.8);
|
|
206
|
+
}
|
|
207
|
+
</style>
|
|
208
|
+
</head>
|
|
209
|
+
|
|
210
|
+
<body>
|
|
211
|
+
|
|
212
|
+
<div id="init-overlay">
|
|
213
|
+
<div class="spinner-border text-primary mb-2"></div>
|
|
214
|
+
<h6 id="init-text">RapidOCR 运行环境检查...</h6>
|
|
215
|
+
<div id="log-container">
|
|
216
|
+
<div>> 等待 Python 响应...</div>
|
|
217
|
+
</div>
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
<div class="main-layout">
|
|
221
|
+
|
|
222
|
+
<!-- 左侧 -->
|
|
223
|
+
<div class="settings-panel">
|
|
224
|
+
|
|
225
|
+
<!-- 引擎 / Det / Rec 面板保持原样 -->
|
|
226
|
+
<div class="section-title" style="margin-top:0">引擎配置</div>
|
|
227
|
+
|
|
228
|
+
<label class="form-label">推理引擎</label>
|
|
229
|
+
<select class="form-select mb-2" id="global-engine">
|
|
230
|
+
<option value="ONNXRUNTIME" selected>ONNXRuntime</option>
|
|
231
|
+
<option value="OPENVINO">OpenVINO</option>
|
|
232
|
+
<option value="PADDLE">Paddle</option>
|
|
233
|
+
</select>
|
|
234
|
+
|
|
235
|
+
<div class="section-title">Det / Cls</div>
|
|
236
|
+
<div class="row g-2 mb-2">
|
|
237
|
+
<div class="col-6">
|
|
238
|
+
<label class="form-label">版本</label>
|
|
239
|
+
<select class="form-select" id="det-cls-ver">
|
|
240
|
+
<option value="PPOCRV4" selected>PP-OCRv4</option>
|
|
241
|
+
<option value="PPOCRV5">PP-OCRv5</option>
|
|
242
|
+
</select>
|
|
243
|
+
</div>
|
|
244
|
+
<div class="col-6">
|
|
245
|
+
<label class="form-label">方向分类</label>
|
|
246
|
+
<select class="form-select" id="cls-enabled">
|
|
247
|
+
<option value="True" selected>开启</option>
|
|
248
|
+
<option value="False">关闭</option>
|
|
249
|
+
</select>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
|
|
253
|
+
<div class="section-title">Rec</div>
|
|
254
|
+
<div class="row g-2 mb-2">
|
|
255
|
+
<div class="col-6">
|
|
256
|
+
<label class="form-label">版本</label>
|
|
257
|
+
<select class="form-select" id="rec-ver">
|
|
258
|
+
<option value="PPOCRV5" selected>PP-OCRv5</option>
|
|
259
|
+
<option value="PPOCRV4">PP-OCRv4</option>
|
|
260
|
+
</select>
|
|
261
|
+
</div>
|
|
262
|
+
<div class="col-6">
|
|
263
|
+
<label class="form-label">语言</label>
|
|
264
|
+
<select class="form-select" id="rec-lang">
|
|
265
|
+
<option value="CH" selected>中英日</option>
|
|
266
|
+
<option value="EN">英文</option>
|
|
267
|
+
</select>
|
|
268
|
+
</div>
|
|
269
|
+
</div>
|
|
270
|
+
|
|
271
|
+
<button class="btn btn-primary btn-sm mt-2" id="btn-run-ocr">
|
|
272
|
+
<i class="bi bi-cpu-fill"></i> 运行识别
|
|
273
|
+
</button>
|
|
274
|
+
|
|
275
|
+
<div class="results-wrapper mt-3">
|
|
276
|
+
<div class="results-header">
|
|
277
|
+
<span id="results-title">结果列表(0)</span>
|
|
278
|
+
<button class="btn btn-sm btn-link text-danger p-0" id="btn-clear-results" title="清空结果">
|
|
279
|
+
<i class="bi bi-trash"></i>
|
|
280
|
+
</button>
|
|
281
|
+
</div>
|
|
282
|
+
<div class="results-list" id="results-list"></div>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<!-- 工作区 -->
|
|
287
|
+
<div class="workspace">
|
|
288
|
+
<div class="canvas-area">
|
|
289
|
+
<div class="img-viewport">
|
|
290
|
+
<img id="preview-img" title="点击放大" src="../img/svg/img_default.svg" />
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
<div class="code-console">
|
|
296
|
+
<div class="p-2 border-bottom border-secondary d-flex justify-content-between">
|
|
297
|
+
<span style="font-size:10px;color:#888">PYTHON SCRIPT</span>
|
|
298
|
+
<button class="btn btn-sm btn-link text-white py-0" id="btn-copy-code">Copy</button>
|
|
299
|
+
</div>
|
|
300
|
+
<div class="code-display" id="python-code"></div>
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
304
|
+
|
|
305
|
+
<script src="../libs/jquery/jquery.min.js"></script>
|
|
306
|
+
|
|
307
|
+
<script>
|
|
308
|
+
function addLog(msg) {
|
|
309
|
+
$('#log-container').append(`<div>> ${msg}</div>`).scrollTop(999999);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
$(function () {
|
|
313
|
+
// 保留原来的功能
|
|
314
|
+
checkEnvironment();
|
|
315
|
+
$('select').on('change', genCode);
|
|
316
|
+
genCode();
|
|
317
|
+
|
|
318
|
+
$('#btn-copy-code').click(() => {
|
|
319
|
+
navigator.clipboard.writeText($('#python-code').text());
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
// 清空结果按钮
|
|
323
|
+
$('#btn-clear-results').click(() => {
|
|
324
|
+
$('#results-list').empty();
|
|
325
|
+
$('#results-title').text('结果列表(0)');
|
|
326
|
+
$('#preview-img').attr('src', '../img/svg/img_default.svg');
|
|
327
|
+
window.parent.gp.marks?.clear?.();
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// 注意:保留原 genTestCode 绑定
|
|
331
|
+
$("#btn-run-ocr").on('click', function () {
|
|
332
|
+
|
|
333
|
+
$("#btn-clear-results").click();
|
|
334
|
+
|
|
335
|
+
const btn = $(this);
|
|
336
|
+
btn.prop('disabled', true).html('<span class="spinner-border spinner-border-sm"></span> 识别中...');
|
|
337
|
+
const origText = '<i class="bi bi-cpu-fill"></i> 运行识别';
|
|
338
|
+
|
|
339
|
+
// 调用原来的 genTestCode
|
|
340
|
+
const promise = genTestCode();
|
|
341
|
+
|
|
342
|
+
promise.finally(() => {
|
|
343
|
+
btn.prop('disabled', false).html(origText);
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// 重写 renderOCRResults 只用于 UI/框/hover
|
|
349
|
+
function renderOCRResults(ocrData) {
|
|
350
|
+
const $list = $('#results-list').empty();
|
|
351
|
+
window.parent.marks?.clear?.();
|
|
352
|
+
|
|
353
|
+
const txts = ocrData.txts || [];
|
|
354
|
+
const boxes = ocrData.boxes || [];
|
|
355
|
+
const scores = ocrData.scores || [];
|
|
356
|
+
|
|
357
|
+
$('#results-title').text(`结果列表(${txts.length})`);
|
|
358
|
+
|
|
359
|
+
txts.forEach((text, i) => {
|
|
360
|
+
const label = i + 1;
|
|
361
|
+
const poly = boxes[i] || [];
|
|
362
|
+
|
|
363
|
+
// 计算矩形边界:左上角 (l,t), 右下角 (r,b)
|
|
364
|
+
let l = Infinity, t = Infinity, r = -Infinity, b = -Infinity;
|
|
365
|
+
poly.forEach(pt => {
|
|
366
|
+
const [x, y] = pt;
|
|
367
|
+
l = Math.min(l, Math.floor(x));
|
|
368
|
+
t = Math.min(t, Math.floor(y));
|
|
369
|
+
r = Math.max(r, Math.floor(x));
|
|
370
|
+
b = Math.max(b, Math.floor(y));
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
const score = scores[i] !== undefined ? (scores[i] * 100).toFixed(2) + '%' : '--';
|
|
374
|
+
|
|
375
|
+
// 绘制矩形
|
|
376
|
+
window.parent.gp.marks.add_rect(String(label), l, t, r, b);
|
|
377
|
+
|
|
378
|
+
const $item = $(`
|
|
379
|
+
<div class="ocr-item">
|
|
380
|
+
<span style="width:28px;text-align:right;color:#666;">${label}</span>
|
|
381
|
+
<span style="flex:1;color:#eee;word-break:break-all;">${text}</span>
|
|
382
|
+
<span style="width:50px;color:#6fbfff;text-align:right;">${score}</span>
|
|
383
|
+
</div>
|
|
384
|
+
`);
|
|
385
|
+
|
|
386
|
+
$item.on('mouseenter', () => window.parent.gp.marks?.high_light(String(label)));
|
|
387
|
+
$item.on('mouseleave', () => window.parent.gp.marks?.high_light_clear());
|
|
388
|
+
|
|
389
|
+
$list.append($item);
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
async function checkEnvironment() {
|
|
396
|
+
addLog("开始检查本地 Python 环境...");
|
|
397
|
+
|
|
398
|
+
// 使用清华源加速,避免用户“慌”
|
|
399
|
+
const checkCode = `
|
|
400
|
+
from ascript.windows.system import Pip
|
|
401
|
+
import eel
|
|
402
|
+
try:
|
|
403
|
+
print("Checking rapidocr...")
|
|
404
|
+
Pip.ensure('rapidocr')
|
|
405
|
+
print("Checking onnxruntime...")
|
|
406
|
+
Pip.ensure('onnxruntime')
|
|
407
|
+
_result = True
|
|
408
|
+
except Exception as e:
|
|
409
|
+
_result = str(e)
|
|
410
|
+
`;
|
|
411
|
+
|
|
412
|
+
try {
|
|
413
|
+
// 假设 window.parent.gp.call_python 是你的 Eel 接口
|
|
414
|
+
const res = await window.parent.gp.call_python(checkCode);
|
|
415
|
+
|
|
416
|
+
if (res === true) {
|
|
417
|
+
addLog("环境就绪,正在进入程序...");
|
|
418
|
+
setTimeout(() => $('#init-overlay').fadeOut(), 800);
|
|
419
|
+
} else {
|
|
420
|
+
addLog("<span style='color:red'>错误: " + res + "</span>");
|
|
421
|
+
$('#init-text').text("环境初始化失败").addClass("text-danger");
|
|
422
|
+
}
|
|
423
|
+
} catch (e) {
|
|
424
|
+
addLog("<span style='color:red'>通信异常: 无法调用 call_python</span>");
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async function genTestCode() {
|
|
429
|
+
const engine = $('#global-engine').val();
|
|
430
|
+
const detClsVer = $('#det-cls-ver').val();
|
|
431
|
+
const recVer = $('#rec-ver').val();
|
|
432
|
+
const recLang = $('#rec-lang').val();
|
|
433
|
+
const clsEnabled = $('#cls-enabled').val() === "True";
|
|
434
|
+
|
|
435
|
+
// RapidOCR 官方默认值
|
|
436
|
+
const defaults = {
|
|
437
|
+
engine: "ONNXRUNTIME",
|
|
438
|
+
detVer: "PPOCRV4",
|
|
439
|
+
recVer: "PPOCRV5",
|
|
440
|
+
recLang: "CH",
|
|
441
|
+
clsEnabled: true
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
let params = [];
|
|
445
|
+
|
|
446
|
+
// angle cls
|
|
447
|
+
if (clsEnabled !== defaults.clsEnabled) {
|
|
448
|
+
params.push(`"Global.use_angle_cls": ${clsEnabled?"True":"False"}`);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// engine(Det / Rec / Cls 同步)
|
|
452
|
+
if (engine !== defaults.engine) {
|
|
453
|
+
params.push(`"Det.engine_type": EngineType.${engine}`);
|
|
454
|
+
params.push(`"Rec.engine_type": EngineType.${engine}`);
|
|
455
|
+
params.push(`"Cls.engine_type": EngineType.${engine}`);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// Det / Cls OCR 版本
|
|
459
|
+
if (detClsVer !== defaults.detVer) {
|
|
460
|
+
params.push(`"Det.ocr_version": OCRVersion.${detClsVer}`);
|
|
461
|
+
params.push(`"Cls.ocr_version": OCRVersion.${detClsVer}`);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// Rec OCR 版本
|
|
465
|
+
if (recVer !== defaults.recVer) {
|
|
466
|
+
params.push(`"Rec.ocr_version": OCRVersion.${recVer}`);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Rec 语言
|
|
470
|
+
if (recLang !== defaults.recLang) {
|
|
471
|
+
params.push(`"Rec.lang_type": LangRec.${recLang}`);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// 生成 Python 代码
|
|
475
|
+
let pythonCode = `from rapidocr import RapidOCR`;
|
|
476
|
+
|
|
477
|
+
if (params.length > 0) {
|
|
478
|
+
pythonCode += `, EngineType, LangRec, OCRVersion\n\n`;
|
|
479
|
+
pythonCode += `engine = RapidOCR(\n params={\n`;
|
|
480
|
+
pythonCode += params.map(p => ` ${p},`).join('\n');
|
|
481
|
+
pythonCode += `\n }\n)\n`;
|
|
482
|
+
} else {
|
|
483
|
+
pythonCode += `\n\nengine = RapidOCR()\n`;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
pythonCode += `
|
|
487
|
+
import cv2,base64
|
|
488
|
+
img_path = r"${window.parent.gp.image.path}"
|
|
489
|
+
result = engine(img_path)
|
|
490
|
+
|
|
491
|
+
success, buffer = cv2.imencode('.jpg', result.vis())
|
|
492
|
+
img_base64 = base64.b64encode(buffer).decode('utf-8')
|
|
493
|
+
_result =(result,f"data:image/jpeg;base64,{img_base64}")
|
|
494
|
+
`;
|
|
495
|
+
ocr_result = await window.parent.gp.call_python(pythonCode);
|
|
496
|
+
|
|
497
|
+
const ocrData = ocr_result[0];
|
|
498
|
+
const imgBase64 = ocr_result[1];
|
|
499
|
+
|
|
500
|
+
// 显示图片
|
|
501
|
+
$('#preview-img').attr('src', imgBase64);
|
|
502
|
+
|
|
503
|
+
// 渲染识别结果列表
|
|
504
|
+
renderOCRResults(ocrData);
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function genCode() {
|
|
510
|
+
const engine = $('#global-engine').val();
|
|
511
|
+
const detClsVer = $('#det-cls-ver').val();
|
|
512
|
+
const recVer = $('#rec-ver').val();
|
|
513
|
+
const recLang = $('#rec-lang').val();
|
|
514
|
+
const clsEnabled = $('#cls-enabled').val() === "True";
|
|
515
|
+
|
|
516
|
+
const winTitle = window.parent?.gp?.window?.title;
|
|
517
|
+
const hasWindowTitle = !!(winTitle && winTitle.trim());
|
|
518
|
+
|
|
519
|
+
// RapidOCR 默认值
|
|
520
|
+
const defaults = {
|
|
521
|
+
engine: "ONNXRUNTIME",
|
|
522
|
+
detVer: "PPOCRV4",
|
|
523
|
+
recVer: "PPOCRV5",
|
|
524
|
+
recLang: "CH",
|
|
525
|
+
clsEnabled: true
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
let params = [];
|
|
529
|
+
let rapidImports = new Set(["RapidOCR"]);
|
|
530
|
+
let ascriptImport = "";
|
|
531
|
+
|
|
532
|
+
// ---------- 参数判断 ----------
|
|
533
|
+
if (clsEnabled !== defaults.clsEnabled) {
|
|
534
|
+
params.push(`"Global.use_angle_cls": ${clsEnabled?"True":"False"}`);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if (engine !== defaults.engine) {
|
|
538
|
+
rapidImports.add("EngineType");
|
|
539
|
+
params.push(`"Det.engine_type": EngineType.${engine}`);
|
|
540
|
+
params.push(`"Rec.engine_type": EngineType.${engine}`);
|
|
541
|
+
params.push(`"Cls.engine_type": EngineType.${engine}`);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if (detClsVer !== defaults.detVer) {
|
|
545
|
+
rapidImports.add("OCRVersion");
|
|
546
|
+
params.push(`"Det.ocr_version": OCRVersion.${detClsVer}`);
|
|
547
|
+
params.push(`"Cls.ocr_version": OCRVersion.${detClsVer}`);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (recVer !== defaults.recVer) {
|
|
551
|
+
rapidImports.add("OCRVersion");
|
|
552
|
+
params.push(`"Rec.ocr_version": OCRVersion.${recVer}`);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (recLang !== defaults.recLang) {
|
|
556
|
+
rapidImports.add("LangRec");
|
|
557
|
+
params.push(`"Rec.lang_type": LangRec.${recLang}`);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// ---------- ascript import ----------
|
|
561
|
+
if (hasWindowTitle) {
|
|
562
|
+
ascriptImport = `from ascript.windows.window import Window`;
|
|
563
|
+
} else {
|
|
564
|
+
ascriptImport = `from ascript.windows.screen import Screen`;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// ---------- 生成 import 区 ----------
|
|
568
|
+
let pythonCode = `from rapidocr import ${Array.from(rapidImports).join(", ")}\n`;
|
|
569
|
+
pythonCode += `${ascriptImport}\n\n`;
|
|
570
|
+
|
|
571
|
+
// ---------- engine ----------
|
|
572
|
+
if (params.length > 0) {
|
|
573
|
+
pythonCode += `engine = RapidOCR(\n params={\n`;
|
|
574
|
+
pythonCode += params.map(p => ` ${p},`).join('\n');
|
|
575
|
+
pythonCode += `\n }\n)\n\n`;
|
|
576
|
+
} else {
|
|
577
|
+
pythonCode += `engine = RapidOCR()\n\n`;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// ---------- 图像获取 ----------
|
|
581
|
+
if (hasWindowTitle) {
|
|
582
|
+
pythonCode += `img = Window.find("${winTitle.replace(/"/g, '\\"')}").capture()\n`;
|
|
583
|
+
} else {
|
|
584
|
+
pythonCode += `img = Screen.capture()\n`;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
pythonCode += `
|
|
588
|
+
result = engine(img)
|
|
589
|
+
print(result)
|
|
590
|
+
`;
|
|
591
|
+
|
|
592
|
+
$('#python-code').text(pythonCode.trim());
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
</script>
|
|
601
|
+
|
|
602
|
+
<script>
|
|
603
|
+
// 点击右侧图片打开新窗口预览
|
|
604
|
+
$('#preview-img').on('click', function () {
|
|
605
|
+
const src = $(this).attr('src');
|
|
606
|
+
if (!src) return;
|
|
607
|
+
|
|
608
|
+
// 打开新窗口
|
|
609
|
+
const win = window.open('', '_blank');
|
|
610
|
+
|
|
611
|
+
// 写入 HTML,只显示一张图片,最大边撑满窗口
|
|
612
|
+
const doc = win.document;
|
|
613
|
+
doc.open();
|
|
614
|
+
doc.write(`
|
|
615
|
+
<!DOCTYPE html>
|
|
616
|
+
<html>
|
|
617
|
+
<head>
|
|
618
|
+
<title>图片预览</title>
|
|
619
|
+
<style>
|
|
620
|
+
html, body {
|
|
621
|
+
margin: 0;
|
|
622
|
+
padding: 0;
|
|
623
|
+
width: 100%;
|
|
624
|
+
height: 100%;
|
|
625
|
+
background: #111;
|
|
626
|
+
display: flex;
|
|
627
|
+
justify-content: center;
|
|
628
|
+
align-items: center;
|
|
629
|
+
overflow: auto;
|
|
630
|
+
}
|
|
631
|
+
img {
|
|
632
|
+
max-width: 100%;
|
|
633
|
+
max-height: 100%;
|
|
634
|
+
}
|
|
635
|
+
</style>
|
|
636
|
+
</head>
|
|
637
|
+
<body>
|
|
638
|
+
<img src="${src}" alt="Preview">
|
|
639
|
+
</body>
|
|
640
|
+
</html>
|
|
641
|
+
`);
|
|
642
|
+
doc.close();
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
</script>
|
|
650
|
+
|
|
651
|
+
</body>
|
|
652
|
+
|
|
653
|
+
</html>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<title>Title</title>
|
|
7
|
+
<script>
|
|
8
|
+
(function () {
|
|
9
|
+
// 立即检测系统主题
|
|
10
|
+
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
11
|
+
const theme = isDark ? 'dark' : 'light';
|
|
12
|
+
|
|
13
|
+
// 在页面还没渲染 Body 之前,就给 html 加上主题属性
|
|
14
|
+
document.documentElement.setAttribute('data-bs-theme', theme);
|
|
15
|
+
|
|
16
|
+
// 预设背景色,防止内容加载延迟时的白底
|
|
17
|
+
document.documentElement.style.backgroundColor = isDark ? '#212529' : '#ffffff';
|
|
18
|
+
})();
|
|
19
|
+
</script>
|
|
20
|
+
<link href="../libs/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
|
21
|
+
<link href="../libs/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
|
|
22
|
+
|
|
23
|
+
</head>
|
|
24
|
+
|
|
25
|
+
<body>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<script src="../libs/jquery/jquery.min.js"></script>
|
|
29
|
+
<script src="../libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
$(document).ready(function () {
|
|
33
|
+
alert(window.parent.gp.image.path)
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
function on_image_loaded(data) {
|
|
37
|
+
alert(JSON.stringify(data,0,2));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function on_area_selected(data) {
|
|
41
|
+
// alert(JSON.stringify(data,0,2));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function on_color_picked(data) {
|
|
45
|
+
// alert(JSON.stringify(data,0,2));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
</body>
|
|
51
|
+
|
|
52
|
+
</html>
|