finished easyocr and pipeline

This commit is contained in:
Boki 2026-02-12 11:24:31 -05:00
parent 735b6f7157
commit cf5d944fd1
8 changed files with 252 additions and 51 deletions

View file

@ -67,7 +67,9 @@ export interface TemplateMatchResult {
confidence: number;
}
export type OcrEngine = 'tesseract' | 'easyocr';
export type OcrEngine = 'tesseract' | 'easyocr' | 'paddleocr';
export type OcrPreprocess = 'none' | 'bgsub' | 'tophat';
interface DaemonRequest {
cmd: string;
@ -79,6 +81,7 @@ interface DaemonRequest {
minCellSize?: number;
maxCellSize?: number;
engine?: string;
preprocess?: string;
}
interface DaemonResponse {
@ -133,10 +136,11 @@ export class OcrDaemon {
// ── Public API ──────────────────────────────────────────────────────────
async ocr(region?: Region, engine?: OcrEngine): Promise<OcrResponse> {
async ocr(region?: Region, engine?: OcrEngine, preprocess?: OcrPreprocess): Promise<OcrResponse> {
const req: DaemonRequest = { cmd: 'ocr' };
if (region) req.region = region;
if (engine && engine !== 'tesseract') req.engine = engine;
if (preprocess && preprocess !== 'none') req.preprocess = preprocess;
// Python engines need longer timeout for first model load + download
const timeout = (engine && engine !== 'tesseract') ? 120_000 : CAPTURE_TIMEOUT;
const resp = await this.sendWithRetry(req, timeout);
@ -182,11 +186,12 @@ export class OcrDaemon {
await this.sendWithRetry({ cmd: 'snapshot' }, REQUEST_TIMEOUT);
}
async diffOcr(savePath?: string, region?: Region, engine?: OcrEngine): Promise<DiffOcrResponse> {
async diffOcr(savePath?: string, region?: Region, engine?: OcrEngine, preprocess?: OcrPreprocess): Promise<DiffOcrResponse> {
const req: DaemonRequest = { cmd: 'diff-ocr' };
if (savePath) req.path = savePath;
if (region) req.region = region;
if (engine && engine !== 'tesseract') req.engine = engine;
if (preprocess) req.preprocess = preprocess;
const timeout = (engine && engine !== 'tesseract') ? 120_000 : CAPTURE_TIMEOUT;
const resp = await this.sendWithRetry(req, timeout);
return {