added test cases

This commit is contained in:
Boki 2026-02-12 13:08:19 -05:00
parent c1892230b7
commit 93e2234c4e
9 changed files with 320 additions and 141 deletions

View file

@ -71,6 +71,18 @@ export type OcrEngine = 'tesseract' | 'easyocr' | 'paddleocr';
export type OcrPreprocess = 'none' | 'bgsub' | 'tophat';
export interface DiffOcrParams {
diffThresh?: number;
maxGap?: number;
trimCutoff?: number;
kernelSize?: number;
upscale?: number;
dimPercentile?: number;
textThresh?: number;
softThreshold?: boolean;
useBackgroundSub?: boolean;
}
interface DaemonRequest {
cmd: string;
region?: Region;
@ -82,6 +94,7 @@ interface DaemonRequest {
maxCellSize?: number;
engine?: string;
preprocess?: string;
params?: DiffOcrParams;
}
interface DaemonResponse {
@ -186,12 +199,13 @@ export class OcrDaemon {
await this.sendWithRetry({ cmd: 'snapshot' }, REQUEST_TIMEOUT);
}
async diffOcr(savePath?: string, region?: Region, engine?: OcrEngine, preprocess?: OcrPreprocess): Promise<DiffOcrResponse> {
async diffOcr(savePath?: string, region?: Region, engine?: OcrEngine, preprocess?: OcrPreprocess, params?: DiffOcrParams): 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;
if (params && Object.keys(params).length > 0) req.params = params;
const timeout = (engine && engine !== 'tesseract') ? 120_000 : CAPTURE_TIMEOUT;
const resp = await this.sendWithRetry(req, timeout);
return {