public HighLevelOcrService(TLowLevelService lowLevelOcrService, HighLevelOcrServiceParams ocrParams) { this.lowLevelOcrService = lowLevelOcrService; if (ocrParams == null) { ocrParams = new HighLevelOcrServiceParams(); } this.ocrParams = ocrParams; }
public static async Task <List <IGenericOcrRunner> > GetStandardOcrs(IOcrCache ocrCache, StandardOcrSettings standardOcrSettings, IImageCompressor imageCompressor) { List <IGenericOcrRunner> genericOcrRunners = new List <IGenericOcrRunner>(); var ocrParams = new HighLevelOcrServiceParams { OcrCache = ocrCache, ImageCompressor = imageCompressor }; if (standardOcrSettings.AwsOcrSettings != null) { var awsSettings = standardOcrSettings.AwsOcrSettings; genericOcrRunners.Add(new AwsOcrService(awsSettings.AccessKey, awsSettings.SecretKey, awsSettings.Region, ocrParams)); } if (standardOcrSettings.AzureOcrSettings != null) { var azureSettings = standardOcrSettings.AzureOcrSettings; genericOcrRunners.Add(new AzureOcrService(azureSettings.SubscriptionKey, azureSettings.Endpoint, ocrParams)); } if (standardOcrSettings.GoogleOcrSettings != null) { var googleSettings = standardOcrSettings.GoogleOcrSettings; genericOcrRunners.Add(new GoogleOcrService(googleSettings.ApiToken, ocrParams)); } if (standardOcrSettings.TesseractOcrSettings != null) { var tesseractSettings = standardOcrSettings.TesseractOcrSettings; if (tesseractSettings.ShouldTryToAutomaticallInstall && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var tesseractInstaller = new WindowsTesseractInstaller(tesseractSettings.TesseractExecutable); await tesseractInstaller.Install(); tesseractSettings.Installer = tesseractInstaller; tesseractSettings.TesseractExecutable = tesseractInstaller.TesseractExePath; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { tesseractSettings.TesseractExecutable = "tesseract"; } genericOcrRunners.Add(new TesseractOcrService(tesseractSettings.TesseractExecutable, tesseractSettings.DataDir, ocrParams)); } if (standardOcrSettings.WindowsOcrSettings != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { genericOcrRunners.Add(new WindowsOcrService(ocrParams)); } return(genericOcrRunners); }