public void Execute(Arguments arguments) { manager = AbbyyManager.Instance; System.Drawing.Rectangle rectangle = !arguments.Relative.Value ? arguments.Area.Value : arguments.Area.Value.ToAbsoluteCoordinates(); System.Drawing.Bitmap partOfScreen = RobotWin32.GetPartOfScreen(rectangle); IEngine engine = manager.Engine; DocumentProcessingParams processingParams = engine.CreateDocumentProcessingParams(); RecognizerParams recognizingParams = processingParams.PageProcessingParams.RecognizerParams; recognizingParams.SetPredefinedTextLanguage(arguments.Language.Value); engine.LoadPredefinedProfile(AbbyyManager.TextAccuracyProfile); FRDocument imageDocument = engine.CreateFRDocument(); using (System.IO.MemoryStream stream = new System.IO.MemoryStream()) { partOfScreen.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp); stream.Position = 0; IReadStream imageStream = new StreamNet2AbbyyAdapter(stream); imageDocument.AddImageFileFromStream(imageStream); } imageDocument.Process(processingParams); Scripter.Variables.SetVariableValue(arguments.Result.Value, new TextStructure(imageDocument.PlainText.Text)); }
public async Task ProcessDocument_ShouldBeOk() { // Arrange var submitImageTask = await SubmitImageAsync(TestFile.Image); var parameters = new DocumentProcessingParams { TaskId = submitImageTask.TaskId, Language = "English", ExportFormats = new[] { ExportFormat.PdfSearchable, ExportFormat.Rtf, }, }; // Act var processDocumentTask = await ApiClient.ProcessDocumentAsync( parameters, true ); // Assert CheckResultTask(processDocumentTask, submitImageTask.TaskId, 2); }
private DocumentProcessingParams GetProcessingParameters(string language, SettingsMode mode, List <string> dictionary, int languageWeight, int dictionaryWeight) { engine.LoadPredefinedProfile(DocumentConversionAccuracyProfile); DocumentProcessingParams processingParams = engine.CreateDocumentProcessingParams(); SetPageProcessingParameters(processingParams, language, dictionary, languageWeight, dictionaryWeight); SetSplittingParameters(processingParams, mode); SetDocumentSynthesisParameters(processingParams, mode); return(processingParams); }
/// <inheritdoc /> public Task <TaskInfo> ProcessDocumentAsync( DocumentProcessingParams parameters, bool waitTaskFinished = false, CancellationToken cancellationToken = default) { return(StartTaskAsync( HttpMethod.Post, Urls.Ocr.ProcessDocument, parameters, null, null, waitTaskFinished: waitTaskFinished, cancellationToken: cancellationToken)); }
private void SetPageProcessingParameters(DocumentProcessingParams processingParams, string language, List <string> dictionary, int languageWeight, int dictionaryWeight) { PageProcessingParams pageProcessingParams = processingParams.PageProcessingParams ?? engine.CreatePageProcessingParams(); processingParams.PageProcessingParams = pageProcessingParams; SetPreProcessingParameters(pageProcessingParams); SetObjectExtractionParameters(pageProcessingParams); SetPageAnalyzeParameters(pageProcessingParams); SetPageSynthesisParameters(pageProcessingParams); SetRecognitionParameters(language, pageProcessingParams, dictionary, languageWeight, dictionaryWeight); }
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); }
private void SetDocumentSynthesisParameters(DocumentProcessingParams processingParams, SettingsMode mode) { SynthesisParamsForDocument documentSynthesisParams = processingParams.SynthesisParamsForDocument ?? engine.CreateSynthesisParamsForDocument(); switch (mode) { case SettingsMode.None: documentSynthesisParams.DetectFontFormatting = true; documentSynthesisParams.DetectDocumentStructure = true; break; case SettingsMode.LineByLine: documentSynthesisParams.DetectFontFormatting = true; documentSynthesisParams.DetectDocumentStructure = false; break; default: break; } SetDocumentStructureDetectionParameters(documentSynthesisParams, mode); SetFontFormatDetectionParameters(documentSynthesisParams, mode); }
private void SetSplittingParameters(DocumentProcessingParams processingParams, SettingsMode mode) { PageSplittingParams pageSplittingParams = processingParams.SplittingParams ?? engine.CreatePageSplittingParams(); processingParams.SplittingParams = pageSplittingParams; }