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 Python via .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 methods of Resources
class.
To return the URL of the online repository from which Aspose.OCR for Python via .NET resources are downloaded, use Resources.get_repository()
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 Python via .NET does not support authentication. You may use:
Provide a link to Resources.set_repository()
method. Depending on the resource, use the following links:
https://github.com/{project}/{repository}/blob/{branch}/
. For example, Resources.set_repository("https://github.com/aspose-ocr/resources/blob/main")
.https://{domain}/{project}/{repository}/-/raw/{branch}/
. For example, Resources.set_repository("https://aspose.com/ocr/resources/-/raw/master/")
.Resources.set_repository("http://localhost/aspose-ocr-resources/")
.To specify an absolute or relative path to the folder where the resources will be downloaded, use Resources.set_local_path()
method. Pass false
to the create
parameter to prevent the directory from being created automatically. For example: Resources.set_local_path("aspose/ocr", false)
To get the full path where the resources will be downloaded, use Resources.get_local_path()
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 Resources.list_remote()
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. | Resources.fetch_all() |
|
|
Download a specific resource by name. | Resources.fetch_resource() |
|
|
Bulk download of resources by names. | Resources.fetch_resources() |
|
|
To prevent the resources from being automatically downloaded, use Resources.allow_automatic_downloads(false)
method. This will not affect the manual downloads.
To get the list of Aspose.OCR resources stored in the local folder, use Resources.list_local()
method. The resource names are returned as a string array.
To delete a locally stored resource, use Resources.remove_local()
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
Resources.set_local_path("aspose/ocr")
Resources.fetch_resource("aspose-ocr-cyrillic-v1");
# Instantiate Aspose.OCR API
api = AsposeOcr()
# Add image to the recognition batch
input = OcrInput(InputType.SINGLE_IMAGE)
input.add("source.png")
# Recognize Ukrainian text
recognitionSettings = RecognitionSettings()
recognitionSettings.language = Language.UKR
# Recognize the image
result = api.recognize(input, recognitionSettings)
# Print recognition result
print(result[0].recognition_text)
input("Press Enter to continue...")
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.