private static async Task <Guid> UploadFilesAsync(IOcrClient ocrClient) { ImageSubmittingParams submitParams; var firstFilePath = "New Image.jpg"; var secondFilePath = "Picture_003.jpg"; // First file using (var fileStream = new FileStream(firstFilePath, FileMode.Open)) { var submitImageResult = await ocrClient.SubmitImageAsync( null, fileStream, Path.GetFileName(firstFilePath)); // Save TaskId for next files and ProcessDocument method submitParams = new ImageSubmittingParams { TaskId = submitImageResult.TaskId }; } // Second file using (var fileStream = new FileStream(secondFilePath, FileMode.Open)) { await ocrClient.SubmitImageAsync( submitParams, fileStream, Path.GetFileName(secondFilePath)); } return(submitParams.TaskId.Value); }
public static async Task ProcessRecord(WebApiRequestRecord record, IOcrClient ocrClient, int idx) { WebApiResponseRecord waRecord = new WebApiResponseRecord(); record.Data.TryGetValue("formUrl", out object imgFile); record.Data.TryGetValue("formSasToken", out object sasToken); string imgFileWithSaS = imgFile.ToString() + sasToken.ToString(); string fileType = imgFile.ToString().Substring(imgFile.ToString().LastIndexOf(".")); string localFile = Path.GetTempPath() + "\\" + "temp_" + idx.ToString() + fileType; using (var client = new WebClient()) { client.DownloadFile(imgFileWithSaS, localFile); } // Process image // You could also call ProcessDocumentAsync or any other processing method declared below var resultUrls = await ProcessImageAsync(ocrClient, localFile); //Get results - the first doc is a docx, second is a text file using (var client = new WebClient()) { waRecord.Data.Add("content", client.DownloadString(resultUrls[1].ToString())); } File.Delete(Path.GetTempPath() + "\\" + "temp_" + idx.ToString() + fileType); waRecord.RecordId = record.RecordId; bag.Add(waRecord); }
public void SetUp() { var container = new IndicoTestContainerBuilder() .ForAutoReviewWorkflow() .Build(); _dataHelper = container.Resolve <DataHelper>(); _jobAwaiter = container.Resolve <JobAwaiter>(); _ocrClient = container.Resolve <IOcrClient>(); }
public RecognizeFromUrlController( IImagePreProcessor preProcessor, IOcrClient ocrClient, ITextPostProcessor postProcessor, IHttpClientFactory httpClientFactory, JsonSerializer serializer) { PreProcessor = preProcessor; OcrClient = ocrClient; PostProcessor = postProcessor; HttpClientFactory = httpClientFactory; Serializer = serializer; }
protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) { // Inputs IOcrClient ocrClient = GetOcrClient(context); var objectContainer = context.GetFromContext <IObjectContainer>(OcrScope.ParentContainerPropertyTag); objectContainer.Add(ocrClient); /////////////////////////// // Add execution logic HERE /////////////////////////// // Outputs return((ctx) => { }); }
private static async Task <List <string> > ProcessDocumentAsync(IOcrClient ocrClient) { var taskId = await UploadFilesAsync(ocrClient); var processingParams = new DocumentProcessingParams { ExportFormats = new[] { ExportFormat.Docx, ExportFormat.Txt, }, Language = "English,French", TaskId = taskId, }; var taskInfo = await ocrClient.ProcessDocumentAsync( processingParams, waitTaskFinished : true); return(taskInfo.ResultUrls); }
public void OneTimeSetUp() { Config = new TestConfig(); new ConfigurationBuilder() .AddJsonFile("testsettings.json") .Build() .GetSection(nameof(TestConfig)) .Bind(Config); ApiClient = new OcrClient( new AuthInfo { Host = Config.Host, ApplicationId = Config.ApplicationId, Password = Config.Password, }); }
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); } }
public static async Task <List <string> > ProcessImageAsync(IOcrClient ocrClient, string strFilePath) { AuthInfo AuthInfo = new AuthInfo { Host = "https://cloud-eu.ocrsdk.com", ApplicationId = @"eda2b839-3717-48aa-80b5-fb500fd78909", Password = @"E2EXXLkQnGXthipqNBfd5FDR" }; var parameters = ProcessingParamsBuilder.GetMrzProcessingParams(); string filePath = strFilePath; using (var fileStream = new FileStream(@filePath, FileMode.Open)) { var taskInfo = await ocrClient.ProcessMrzAsync( parameters, fileStream, Path.GetFileName(filePath), waitTaskFinished : true); return(taskInfo.ResultUrls); } }
public Processor(IScope scope, AuthInfo authInfo) { _ocrClient = new OcrClient(authInfo); _scope = scope; }
private static async Task <TaskList> GetFinishedTasksAsync(IOcrClient ocrClient) { var finishedTasks = await ocrClient.ListFinishedTasksAsync(); return(finishedTasks); }