fix: Log empty OCR results to help debug TextDetector availability

- Cascade OCR now saves a log entry even when no text is detected
- Logs ocrMethod as 'text_detector' or 'not_supported' for debugging
- Helps identify when browsers block the TextDetector API
This commit is contained in:
2026-01-18 20:57:41 +01:00
parent 9ba0825bcd
commit d109dfad0e

View File

@@ -246,6 +246,23 @@ export async function runCascadeOCR(imageBlob: Blob): Promise<CascadeOCRResult>
if (!rawText.trim()) {
console.log('[CascadeOCR] No text detected');
// Still save to DB for debugging (shows TextDetector availability)
const processingTimeMs = performance.now() - startTime;
try {
await saveOcrLog({
rawText: '',
detectedTexts: [],
confidence: 0,
deviceInfo: navigator.userAgent,
ocrMethod: 'TextDetector' in window ? 'text_detector' : 'not_supported',
processingTimeMs: Math.round(processingTimeMs),
});
console.log('[CascadeOCR] Empty result logged to DB');
} catch (err) {
console.warn('[CascadeOCR] Failed to log empty result:', err);
}
return {
success: false,
distillery: null,
@@ -261,6 +278,7 @@ export async function runCascadeOCR(imageBlob: Blob): Promise<CascadeOCRResult>
};
}
// Step 2: Extract hard facts via RegEx
const hardFacts = extractHardFacts(rawText);