private static async Task <List <string> > ProcessImageAsync(IOcrClient ocrClient, string localFile) { var imageParams = new ImageProcessingParams { ExportFormats = new[] { ExportFormat.Docx, ExportFormat.Txt, }, Language = "English,Arabic,Hebrew", }; using (var fileStream = new FileStream(localFile, FileMode.Open)) { var taskInfo = await ocrClient.ProcessImageAsync( imageParams, fileStream, Path.GetFileName(localFile), waitTaskFinished : true); return(taskInfo.ResultUrls); } }
private static async Task <List <string> > ProcessImageAsync(IOcrClient ocrClient) { var imageParams = new ImageProcessingParams { ExportFormats = new[] { ExportFormat.Docx, ExportFormat.Txt, }, Language = "English,French", }; const string filePath = "New Image.jpg"; using (var fileStream = new FileStream(filePath, FileMode.Open)) { var taskInfo = await ocrClient.ProcessImageAsync( imageParams, fileStream, Path.GetFileName(filePath), waitTaskFinished : true); return(taskInfo.ResultUrls); } }
private async Task ProcessFileAsync(string filePath, Options options, object state) { Console.WriteLine($"Start single file processing: {filePath}"); TaskInfo task; var parameters = ProcessingParamsBuilder.GetImageProcessingParams(options); using (_scope.Start("Uploading")) using (var fileStream = File.OpenRead(filePath)) { task = await _ocrClient.ProcessImageAsync(parameters, fileStream, options.FileName).ConfigureAwait(false); } UploadFileCompleted?.Invoke(this, new UploadCompletedEventArgs(task, state)); task = await WaitTaskAsync(task.TaskId, state).ConfigureAwait(false); await DownloadResultFilesAsync(task, options, state).ConfigureAwait(false); Console.WriteLine("Processing has completed"); }