{"record":{"id":"7ad564d666f24665","repo":"SubtitleEdit/subtitleedit","slug":"binaryocr-database-not-found-dbpath-use-ocr","errorCode":null,"errorMessage":"BinaryOCR database not found: {dbPath}. Use --ocr-db to point to a .db file (typically %AppData%\\Subtitle Edit\\OCR\\Latin.db or similar).","messagePattern":"BinaryOCR database not found: (.+?)\\. Use --ocr-db to point to a \\.db file \\(typically %AppData%\\\\Subtitle Edit\\\\OCR\\\\Latin\\.db or similar\\)\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/seconv/Core/BinaryOcrOcrEngine.cs","lineNumber":25,"sourceCode":"/// In-process OCR via Subtitle Edit's BinaryOCR matcher. Requires a <c>.db</c>\n/// database file (typically shipped with SE under <c>%AppData%\\Subtitle Edit\\OCR\\</c>;\n/// pass the path via <c>--ocr-db</c>). BinaryOCR uses fast bitmap-hash matching and\n/// is a useful alternative to nOCR — different accuracy profile, similar speed.\n/// </summary>\ninternal sealed class BinaryOcrOcrEngine : IOcrEngine\n{\n    public string Name => \"binaryocr\";\n\n    private readonly BinaryOcrDb _db;\n    private readonly BinaryOcrMatcher _matcher;\n    private const int PixelsAreSpaceDefault = 12;\n    private const double MaxErrorPercent = 0.5;\n\n    public BinaryOcrOcrEngine(string dbPath)\n    {\n        if (!File.Exists(dbPath))\n        {\n            throw new FileNotFoundException(\n                $\"BinaryOCR database not found: {dbPath}. Use --ocr-db to point to a .db file \" +\n                \"(typically %AppData%\\\\Subtitle Edit\\\\OCR\\\\Latin.db or similar).\", dbPath);\n        }\n        _db = new BinaryOcrDb(dbPath, loadCompareImages: true);\n        if (_db.AllCompareImages.Count == 0)\n        {\n            throw new InvalidOperationException($\"BinaryOCR database is empty: {dbPath}\");\n        }\n        _matcher = new BinaryOcrMatcher\n        {\n            IsLatinDb = Path.GetFileNameWithoutExtension(dbPath).Contains(\"Latin\", StringComparison.OrdinalIgnoreCase),\n        };\n    }\n\n    public string Recognize(SKBitmap bitmap)\n    {\n        if (bitmap is null || bitmap.Width == 0 || bitmap.Height == 0)\n        {","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/seconv/Core/BinaryOcrOcrEngine.cs#L7-L43","documentation":"FileNotFoundException from the BinaryOcrOcrEngine constructor: the dbPath argument does not point to an existing file. The message names the path and suggests using --ocr-db to point at a .db (typically %AppData%\\Subtitle Edit\\OCR\\Latin.db).","triggerScenarios":"Constructing BinaryOcrOcrEngine with a dbPath whose file does not exist; default OCR-db lookup returned a path that was never populated.","commonSituations":"First-time use before any BinaryOCR db was created in the SE GUI; moved SE to a new machine; user pointed --ocr-db at the wrong file.","solutions":["Run Binary/OCR in the SE GUI once to generate Latin.db, then point --ocr-db at it.","Pass --ocr-db:<absolute path to .db> explicitly.","Confirm the path resolves under the current user profile (the %AppData% placeholder must be expanded)."],"exampleFix":"// before\nif (!File.Exists(dbPath))\n    throw new FileNotFoundException($\"BinaryOCR database not found: {dbPath}. ...\", dbPath);\n\n// after\nvar resolved = Environment.ExpandEnvironmentVariables(dbPath);\nif (!File.Exists(resolved))\n    throw new FileNotFoundException($\"BinaryOCR database not found: '{resolved}'. Use --ocr-db:<path.db>.\", resolved);","handlingStrategy":"validation","validationCode":"var resolved = Environment.ExpandEnvironmentVariables(dbPath);\nif (!File.Exists(resolved))\n    throw new FileNotFoundException($\"BinaryOCR db not found: '{resolved}'. Pass --ocr-db:<path.db>.\", resolved);","typeGuard":"static bool IsExistingOcrDb(string path) => File.Exists(Environment.ExpandEnvironmentVariables(path));","tryCatchPattern":"null","preventionTips":["Expand %AppData% in user-supplied paths before checking existence.","Default the OCR-db path to the standard SE location and only override via --ocr-db.","Generate the db in the SE GUI once on first install."],"tags":["ocr","binary-ocr","file-not-found","configuration","cli"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}