diff --git a/src/index.d.ts b/src/index.d.ts index 7bebf77..f2cba0d 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -74,11 +74,11 @@ declare namespace Tesseract { data: DetectData } interface DetectData { - tesseract_script_id: number - script: string - script_confidence: number - orientation_degrees: number - orientation_confidence: number + tesseract_script_id: number | null + script: string | null + script_confidence: number | null + orientation_degrees: number | null + orientation_confidence: number | null } interface Rectangle { left: number diff --git a/src/worker-script/index.js b/src/worker-script/index.js index 60e9c64..ff0a732 100644 --- a/src/worker-script/index.js +++ b/src/worker-script/index.js @@ -356,9 +356,15 @@ const detect = async ({ payload: { image } }, res) => { const results = new TessModule.OSResults(); if (!api.DetectOS(results)) { - api.End(); TessModule._free(ptr); - res.reject('Failed to detect OS'); + + res.resolve({ + tesseract_script_id: null, + script: null, + script_confidence: null, + orientation_degrees: null, + orientation_confidence: null, + }); } else { const best = results.best_result; const oid = best.orientation_id;