OCRScrapeBase Class
Definition
- Namespace:
UiPath.OCR.Contracts.Scrape - Assembly:
UiPath.OCR.Contracts
Description
An abstract class that defines the behavior of an IOCRActivity in a screen scraping operation.
Members
Constructors
OCRScrapeBase(UiPath.OCR.Contracts.Activities.IOCRActivity)- Initializes a new instance of the OCR scrape engine. The constructor argument is an Activity that implements theIOCRActivity.
Methods
CreateOcrEngineActivity(System.Activities.InArgument<System.Drawing.Image>)- Returns a new OCR Activity object with the specified Image set as an InArgument.GetScrapeArguments()System.Collections.Generic.Dictionary<string, object>- Collects all theUiPath.OCR.Contracts.Activities.IOCRActivityarguments from the scrape control. These arguments is used to run theUiPath.OCR.Contracts.Activities.IOCRActivity,PerformOCRmethod and to fill the activity arguments when the activity is created to be used in a workflow.GetScrapeControl()- Gets the control that is shown on the screen.GetScrapeControl(UiPath.OCR.Contracts.Scrape.ScrapeEngineUsages)- Returns the UserControl that can be used to configure this OCR engine.OCRScrapeBase(UiPath.OCR.Contracts.Activities.IOCRActivity)- Activity constructor.ScrapeOCRAsync(System.Drawing.Bitmap)- Asynchronously performs OCR on the specified Image.ScrapeOCRAsync(System.Drawing.Bitmap, UiPath.OCR.Contracts.Scrape.ScrapeEngineUsages, System.Threading.CancellationToken)- Asynchronously performs OCR on the specified Image. Can be canceled. Allows the caller to specify whether the OCR should be performed in Screen or Document mode.
Properties
Name- Custom display the name given to this OCR. This name is visible in certain drop-down controls.Priority- Custom priority is given to this OCR. Lower values indicate higher priority. This determines the ordering of OCR engines in certain drop-down controls.
Code Sample
internal class SampleOCRScrape : OCRScrapeBase
{
private readonly ScrapeEngineUsages _usage;
private readonly SampleScrapeControl _sampleScrapeControl = new SampleScrapeControl();
public override ScrapeEngineUsages Usage { get; } = ScrapeEngineUsages.Document | ScrapeEngineUsages.Screen;
public SampleOCRScrape(IOCRActivity ocrEngineActivity, ScrapeEngineUsages usage) : base(ocrEngineActivity)
{
_usage = usage;
}
public override ScrapeControlBase GetScrapeControl()
{
return _sampleScrapeControl;
}
public override Dictionary<string, object> GetScrapeArguments()
{
return new Dictionary<string, object>
{
{ nameof(SampleOCRAsyncCodeActivity.CustomInput), _sampleScrapeControl.SampleInput }
};
}
}