diff --git a/src/dashboard/DashboardServer.ts b/src/dashboard/DashboardServer.ts
index 39f2c27..2bf573c 100644
--- a/src/dashboard/DashboardServer.ts
+++ b/src/dashboard/DashboardServer.ts
@@ -8,7 +8,7 @@ import { logger } from '../util/logger.js';
import { sleep } from '../util/sleep.js';
import type { BotController } from './BotController.js';
import type { ScreenReader } from '../game/ScreenReader.js';
-import type { OcrEngine } from '../game/OcrDaemon.js';
+import type { OcrEngine, OcrPreprocess } from '../game/OcrDaemon.js';
import { GRID_LAYOUTS } from '../game/GridReader.js';
import type { GameController } from '../game/GameController.js';
@@ -131,8 +131,8 @@ export class DashboardServer {
this.app.post('/api/debug/ocr-engine', (req, res) => {
if (!this.debug) { res.status(503).json({ error: 'Debug not available' }); return; }
const { engine } = req.body as { engine: string };
- if (!['tesseract', 'easyocr'].includes(engine)) {
- res.status(400).json({ error: 'Invalid engine. Must be tesseract or easyocr.' });
+ if (!['tesseract', 'easyocr', 'paddleocr'].includes(engine)) {
+ res.status(400).json({ error: 'Invalid engine. Must be tesseract, easyocr, or paddleocr.' });
return;
}
this.debug.screenReader.debugOcrEngine = engine as OcrEngine;
@@ -140,6 +140,24 @@ export class DashboardServer {
res.json({ ok: true });
});
+ // OCR preprocess selection
+ this.app.get('/api/debug/ocr-preprocess', (_req, res) => {
+ if (!this.debug) { res.status(503).json({ error: 'Debug not available' }); return; }
+ res.json({ ok: true, preprocess: this.debug.screenReader.debugPreprocess });
+ });
+
+ this.app.post('/api/debug/ocr-preprocess', (req, res) => {
+ if (!this.debug) { res.status(503).json({ error: 'Debug not available' }); return; }
+ const { preprocess } = req.body as { preprocess: string };
+ if (!['none', 'bgsub', 'tophat'].includes(preprocess)) {
+ res.status(400).json({ error: 'Invalid preprocess. Must be none, bgsub, or tophat.' });
+ return;
+ }
+ this.debug.screenReader.debugPreprocess = preprocess as OcrPreprocess;
+ this.broadcastLog('info', `OCR preprocess set to: ${preprocess}`);
+ res.json({ ok: true });
+ });
+
this.app.post('/api/debug/ocr', async (_req, res) => {
if (!this.debug) { res.status(503).json({ error: 'Debug not available' }); return; }
try {
diff --git a/src/dashboard/index.html b/src/dashboard/index.html
index 986992f..5babde6 100644
--- a/src/dashboard/index.html
+++ b/src/dashboard/index.html
@@ -455,6 +455,12 @@
+
@@ -1004,8 +1010,27 @@
} catch {}
}
+ async function setOcrPreprocess(preprocess) {
+ await fetch('/api/debug/ocr-preprocess', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ preprocess }),
+ });
+ }
+
+ async function loadOcrPreprocess() {
+ try {
+ const res = await fetch('/api/debug/ocr-preprocess');
+ const data = await res.json();
+ if (data.ok && data.preprocess) {
+ document.getElementById('ocrPreprocessSelect').value = data.preprocess;
+ }
+ } catch {}
+ }
+
connect();
loadOcrEngine();
+ loadOcrPreprocess();