You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error opening data file tessdata/eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
But I do have the environment variable set to the tessdata folder with eng.traineddaata.
It only works if I call it from my project root directory where tessdata folder is published into.
PS C:\Users\mdabr> blitz scan
Error opening data file tessdata/eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
Unhandled exception. Tesseract.TesseractException: Failed to initialise tesseract engine.. See https://github.com/charlesw/tesseract/wiki/Error-1 for details.
at Tesseract.TesseractEngine.Initialise(String datapath, String language, EngineMode engineMode, IEnumerable`1 configFiles, IDictionary`2 initialValues, Boolean setOnlyNonDebugVariables)
at Tesseract.TesseractEngine..ctor(String datapath, String language, EngineMode engineMode, IEnumerable`1 configFiles, IDictionary`2 initialOptions, Boolean setOnlyNonDebugVariables)
at Tesseract.TesseractEngine..ctor(String datapath, String language, EngineMode engineMode)
at Blitz.Program.RunScanMoronCommand(ScanMoronOptions opts) in D:\Development\Blitz\Blitz\Program.cs:line 156
at Blitz.Program.<>c.<Main>b__1_3(ScanMoronOptions opts) in D:\Development\Blitz\Blitz\Program.cs:line 27
at CommandLine.ParserResultExtensions.MapResult[T1,T2,T3,T4,T5,TResult](ParserResult`1 result, Func`2 parsedFunc1, Func`2 parsedFunc2, Func`2 parsedFunc3, Func`2 parsedFunc4, Func`2 parsedFunc5, Func`2 notParsedFunc)
at Blitz.Program.Main(String[] args) in D:\Development\Blitz\Blitz\Program.cs:line 16
The text was updated successfully, but these errors were encountered:
I will not close this issue since the error persists. However, for anyone experiencing similar problems, I have found a workaround.
This is simply done by programmatically creating the tessdata directory and downloading eng.traineddata to a known location in the user's file system on app initialisation.
Note that this is for a production environment and only needs to be done once. Consider disabling this check for local debugging.
1. Get a known path (e.g. AppData)
Create the tessdata directory there.
privateconststringAppDataFolderName="YourAppName";privateconststringTessdataFolderName="tessdata";/// <summary>/// Gets the path to Blitz's directory in the AppData folder./// </summary>/// <returns>The application directory path.</returns>publicstringGetAppDataFolderPath(){varappDataPath=Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);returnPath.Combine(appDataPath,AppDataFolderName);}/// <summary>/// Gets the path to Blitz's tessdata directory./// </summary>/// <returns>The tessdata path.</returns>publicstringGetTessdataFolderPath(){returnPath.Combine(GetAppDataFolderPath(),TessdataFolderName);}
2. Download tessdata/*.traineddata to that path
Make sure to check the directory exists there before downloading.
/// <summary>/// Downloads the Tesseract English language model to the tessdata folder./// </summary>/// <param name="tessdataFolderPath">The path to the tessdata folder.</param>privatestaticasyncTaskDownloadTrainedData(stringtessdataFolderPath){conststringtessdataEngFileName="eng.traineddata";conststringtessdataEngUrl="https://github.com/tesseract-ocr/tessdata_fast/raw/main/eng.traineddata";usingvarclient=newHttpClient();awaitusingvarstream=awaitclient.GetStreamAsync(tessdataEngUrl);awaitusingvarfs=newFileStream(Path.Combine(tessdataFolderPath,tessdataEngFileName),FileMode.OpenOrCreate);awaitstream.CopyToAsync(fs);}
Error
But I do have the environment variable set to the
tessdata
folder witheng.traineddaata
.It only works if I call it from my project root directory where
tessdata
folder is published into.Works
Does Not Work
The text was updated successfully, but these errors were encountered: