Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
By default, Aspose.OCR for .NET automatically downloads the required resources when you call the method which depends on them.
Out of the box, the library is preconfigured to use the Aspose.OCR resource repository. The resources will be downloaded into the aspose_data folder in the application’s working directory; if the folder is missing, it is automatically created. No configuration is required.
However, you have an option to manually manage the resources for your project using the static methods of Aspose.OCR.Resources
class.
To return the URL of the online repository from which Aspose.OCR for .NET resources are downloaded, use Aspose.OCR.Resources.GetRepository()
method. By default, the resources are downloaded from https://github.com/aspose-ocr/resources/; however, you can use your own repository or even Internet or intranet web site:
Copy the entire content of the main branch: https://github.com/aspose-ocr/resources/tree/main. You can use any of the following options:
git clone git@github.com:aspose-ocr/resources.git
Publish all downloaded files to your own HTTP resource. The resource must be must be freely accessible to the application without providing credentials; Aspose.OCR for .NET does not support authentication. You may use:
Provide a link to Aspose.OCR.Resources.SetRepository()
method. Depending on the resource, use the following links:
https://github.com/{project}/{repository}/blob/{branch}/
. For example, Aspose.OCR.Resources.SetRepository("https://github.com/aspose-ocr/resources/blob/main");
.https://{domain}/{project}/{repository}/-/raw/{branch}/
. For example, Aspose.OCR.Resources.SetRepository("https://aspose.com/ocr/resources/-/raw/master/");
.Aspose.OCR.Resources.SetRepository("http://localhost/aspose-ocr-resources/");
.To specify an absolute or relative path to the folder where the resources will be downloaded, use Aspose.OCR.Resources.SetLocalPath()
method. Pass false
to the create
parameter to prevent the directory from being created automatically. For example: Aspose.OCR.Resources.SetLocalPath("aspose/ocr", false);
To get the full path where the resources will be downloaded, use Aspose.OCR.Resources.GetLocalPath()
method. By default, the resources are downloaded into the aspose_data folder in the application’s working directory.
To get the full list of compatible resources from the online repository, use Aspose.OCR.Resources.ListRemote()
method. To find more information on a specific resource, refer to the following link.
There are several ways to download the resources:
Option | Method | Benefits | Drawbacks |
---|---|---|---|
Automatically download the resource when you call the method which depends on it. | n/a |
|
|
Download all resources at once. | Aspose.OCR.Resources.FetchAll() |
|
|
Download a specific resource by name. | Aspose.OCR.Resources.FetchResource() |
|
|
Bulk download of resources by names. | Aspose.OCR.Resources.FetchResources() |
|
|
To prevent the resources from being automatically downloaded, use Aspose.OCR.Resources.AllowAutomaticDownloads(false)
method. This will not affect the manual downloads.
To get the list of Aspose.OCR resources stored in the local folder, use Aspose.OCR.Resources.ListLocal()
method. The resource names are returned as a string array.
To delete a locally stored resource, use Aspose.OCR.Resources.RemoveLocal()
method or simply remove the corresponding file.
The code sample below illustrates how to manually install Cyrillic recognition model:
// Download Cyrillic OCR model to "aspose/ocr" directory in the application working directory
Aspose.OCR.Resources.SetLocalPath("aspose/ocr");
Aspose.OCR.Resources.FetchResource("aspose-ocr-cyrillic-v1");
// Initialize Aspose.OCR for .NET recognition API
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();
// Add images to OcrInput object
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage);
input.Add("source1.png");
input.Add("source2.jpg");
// Set recognition language
Aspose.OCR.RecognitionSettings recognitionSettings = new Aspose.OCR.RecognitionSettings();
recognitionSettings.Language = Aspose.OCR.Language.Ukr;
// Recognize image
Aspose.OCR.OcrOutput results = recognitionEngine.Recognize(input, recognitionSettings);
foreach(Aspose.OCR.RecognitionResult result in results)
{
Console.WriteLine(result.RecognitionText);
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.