惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
博客园 - 司徒正美
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
D
Docker
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
腾讯CDC
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
I
InfoQ
雷峰网
雷峰网
The Cloudflare Blog
美团技术团队
Engineering at Meta
Engineering at Meta

又见苍岚

COLMAP PatchMatch Stereo 算法详解 事件驱动的状态机框架:从理论到工程实践 Git 在国内网络环境下无法 Push 的排查与修复 —— 配置 Clash 代理 分段五次多项式插值原理详解 路径插值方法深度对比研究 Claude Code 使用指南 OpenClaw 记忆管理与技能创建指南 CBS(Conflict-Based Search)算法详解 A* 算法及其变种详解 OpenClaw 配置多 Agents Windows Powershell 无法加载文件,因为在此系统上禁止运行脚本问题的解决方案 MaxClaw 安装流程 大模型 AI 名词介绍 AList 网盘聚合工具简介 Protobuf 简介与测试 Claude Code 简介以及 GLM 4.7 模型接入 Github 歌词下载工具 163MusicLyrics Python __getattr__ 懒加载 Python TypedDict 机器人仿真平台 Gazebo 安装记录 机器人仿真平台 Gazebo 简介 多机器人路径规划问题(Multi-Agent Path Finding, MAPF)简介 Python exifread 读取修改过的 jpeg 信息错误问题修复 3D 坐标系变换的理解 3D 旋转矩阵基本概念 MongoDB Compass 介绍 Python 环境管理工具 uv Flutter 开发指南 Snipaste 安装下载与黑屏问题解决方案 全局路径规划算法记录
Fluid -46- 基于 Simpletex API 构建公式识别页面
Yiwei Zhang · 2025-04-26 · via 又见苍岚
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>图片公式识别系统</title>
<!-- 引入 KaTeX 数学公式渲染 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css">
<style>
:root {
--primary-color: #2196F3;
--success-color: #4CAF50;
--error-color: #f44336;
--border-radius: 8px;
}

body {
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
max-width: 800px;
margin: 2rem auto;
padding: 0 1rem;
line-height: 1.6;
color: #333;
}

.container {
background: #fff;
padding: 2rem;
border-radius: var(--border-radius);
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

#dropzone {
border: 2px dashed #ccc;
border-radius: var(--border-radius);
padding: 3rem 1rem;
text-align: center;
transition: all 0.3s ease;
background: #f8f9fa;
cursor: pointer;
position: relative;
min-height: 200px;
display: flex;
align-items: center;
justify-content: center;
}

#dropzone:hover,
#dropzone.dragover {
border-color: var(--primary-color);
background: rgba(33, 150, 243, 0.05);
}

.upload-icon {
font-size: 3rem;
color: var(--primary-color);
margin-bottom: 1rem;
}

.result-card {
margin-top: 2rem;
padding: 1.5rem;
border-radius: var(--border-radius);
background: #f8f9fa;
display: none;
}

.result-title {
margin: 0 0 1rem;
color: var(--primary-color);
font-size: 1.2rem;
}

.latex-output {
font-size: 1.4rem;
padding: 1rem;
background: white;
border-radius: 4px;
text-align: center;
overflow-x: auto;
}

.confidence {
margin-top: 1rem;
color: #666;
font-size: 0.9rem;
}
.called-today {
margin-top: 1rem;
color: #666;
font-size: 0.9rem;
}
.loading {
display: none;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.9);
align-items: center;
justify-content: center;
flex-direction: column;
}

.spinner {
width: 40px;
height: 40px;
border: 4px solid #f3f3f3;
border-top: 4px solid var(--primary-color);
border-radius: 50%;
animation: spin 1s linear infinite;
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

.error-message {
color: var(--error-color);
padding: 1rem;
margin-top: 1rem;
border-radius: 4px;
background: #ffe6e6;
display: none;
}

.latex-source-card {
margin-top: 1.5rem;
border: 1px solid #e0e0e0;
border-radius: 8px;
overflow: hidden;
}

.source-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px;
background: #f5f5f5;
border-bottom: 1px solid #e0e0e0;
}

.latex-raw {
padding: 1rem;
margin: 0;
background: white;
font-family: 'Courier New', monospace;
white-space: pre-wrap;
word-break: break-all;
max-height: 200px;
overflow-y: auto;
}

.copy-button {
background: var(--primary-color);
color: white;
border: none;
padding: 6px 12px;
border-radius: 4px;
cursor: pointer;
transition: background 0.2s;
}

.copy-button:hover {
background: #1976d2;
}

.copy-button.copied {
background: var(--success-color);
}
</style>
</head>
<body>
<div class="container">
<h1>图片公式识别系统</h1>

<div id="dropzone">
<div class="upload-icon">📷</div>
<div>
<p>直接粘贴图片(Ctrl+V)或点击选择文件</p>
<p class="text-muted">支持 PNG/JPG 格式,建议公式图片尺寸小于 2000px</p>
</div>
<div class="loading">
<div class="spinner"></div>
<p>正在识别中...</p>
</div>
</div>

<input type="file" id="fileInput" hidden accept="image/*">

<div class="result-card">
<h3 class="result-title">识别结果</h3>
<div class="latex-output"></div>
<div class="latex-source-card">
<div class="source-header">
<span>LaTeX 源代码</span>
<button class="copy-button" onclick="copyLatex()">
📋 复制
</button>
</div>
<pre class="latex-raw" id="latexRaw"></pre>
</div>
<div class="confidence">置信度: <span class="confidence-value"></span></div>
<div class="called-today">今日调用: <span class="called-today-value"></span></div>
</div>

<div class="error-message"></div>
</div>

<script src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js"></script>
<script>
const dropzone = document.getElementById('dropzone');
const fileInput = document.getElementById('fileInput');
const BASE_URL = 'https://your_link';

// 粘贴事件处理
document.addEventListener('paste', handleImage);

// 点击事件处理
dropzone.addEventListener('click', () => fileInput.click());

// 文件选择事件
fileInput.addEventListener('change', (e) => {
if (e.target.files[0]) handleImage(e.target.files[0]);
});

async function handleImage(event) {
let blob;
if (event instanceof ClipboardEvent) {
const items = event.clipboardData.items;
for (let item of items) {
if (item.type.startsWith('image')) {
blob = item.getAsFile();
break;
}
}
} else {
blob = event;
}

if (!blob) return;

showLoading(true);
clearError();

try {
const formData = new FormData();
formData.append('image', blob, 'pasted-image.png');

const response = await fetch(`${BASE_URL}/upload`, {
method: 'POST',
body: formData,
mode: 'cors'
});

if (!response.ok) throw new Error(`HTTP 错误! 状态码: ${response.status}`);
const { result, error } = await response.json();

if (error) throw new Error(error);
if (!result.latex) throw new Error('未能识别到公式');

showResult(result);
} catch (error) {
showError(error.message);
} finally {
showLoading(false);
}
}

function showResult({ latex, conf, call_num }) {
const resultCard = document.querySelector('.result-card');
const latexOutput = document.querySelector('.latex-output');
const confidenceValue = document.querySelector('.confidence-value');
const callnumValue = document.querySelector('.called-today-value');
const latexRaw = document.getElementById('latexRaw');

try {
// 渲染公式
katex.render(latex, latexOutput, {
throwOnError: false,
displayMode: true
});

// 显示原始代码(处理转义字符)
const cleanedLatex = latex.replace(/\\\\/g, '\\');
latexRaw.textContent = cleanedLatex;
latexRaw.dataset.raw = cleanedLatex; // 存储原始数据

} catch (e) {
latexOutput.textContent = latex;
}

confidenceValue.textContent = (conf * 100).toFixed(1) + '%';
callnumValue.textContent = call_num;
resultCard.style.display = 'block';
}

function showLoading(show) {
dropzone.querySelector('.loading').style.display = show ? 'flex' : 'none';
}

function showError(message) {
const errorEl = document.querySelector('.error-message');
errorEl.textContent = `错误: ${message}`;
errorEl.style.display = 'block';
}

function clearError() {
document.querySelector('.error-message').style.display = 'none';
}

function copyLatex() {
const button = document.querySelector('.copy-button');
const raw = document.getElementById('latexRaw').dataset.raw;

navigator.clipboard.writeText(raw).then(() => {
button.classList.add('copied');
button.textContent = '✅ 已复制';

setTimeout(() => {
button.classList.remove('copied');
button.textContent = '📋 复制';
}, 2000);
}).catch(err => {
console.error('复制失败:', err);
alert('自动复制失败,请手动选择文本复制');
});
}

// 新增双击复制功能
document.getElementById('latexRaw').addEventListener('dblclick', copyLatex);
</script>
</body>
</html>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[Unit]
Description = Service to support formular reco for www.zywvvd.com
After = network.target

[Service]
ExecStart = /home/vvd/anaconda3/bin/python app.py
WorkingDirectory = /home/vvd/programs/formular_reco
StandardOutput = inherit
StandardError = inherit
Restart = always
User = vvd

[Install]
WantedBy=multi-user.target