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 Java 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 directory in the application’s working directory; if the directory is missing, it is automatically created. No configuration is required.
However, you have an option to manually manage the resources for your project.
To return the URL of the online repository from which Aspose.OCR for Java resources are downloaded, use 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 Java does not support authentication. You may use:
Provide a link to Resources.SetRepository()
method. Depending on the resource, use the following links:
https://github.com/{project}/{repository}/blob/{branch}/
. For example, Resources.SetRepository("https://github.com/aspose-ocr/resources/blob/main");
.https://{domain}/{project}/{repository}/-/raw/{branch}/
. For example, Resources.SetRepository("https://aspose.com/ocr/resources/-/raw/master/");
.Resources.SetRepository("http://localhost/aspose-ocr-resources/");
.To specify an absolute or relative path to the directory where the resources will be downloaded, use Resources.SetLocalPath()
method. Pass false
to the create
parameter to prevent the directory from being created automatically. For example: Resources.SetLocalPath("aspose/ocr", false);
To get the full path where the resources will be downloaded, use Resources.GetLocalPath()
method. By default, the resources are downloaded into the aspose_data directory in the application’s working directory.
To get the full list of compatible resources from the online repository, use 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. | Resources.FetchAll() |
|
|
Download a specific resource by name. | Resources.FetchResource() |
|
|
Bulk download of resources by names. | Resources.FetchResources() |
|
|
To prevent the resources from being automatically downloaded, use Resources.AllowAutomaticDownloads(false)
method. This will not affect the manual downloads.
To get the list of Aspose.OCR resources stored in the local directory, use Resources.ListLocal()
method. The resource names are returned as a string array.
To delete a locally stored resource, use Resources.RemoveLocal()
method or simply remove the corresponding file.
The code sample below illustrates how to manually install Hindi recognition model:
// Download Hindi OCR model to "aspose/ocr" directory in the application working directory
Resources.SetLocalPath("aspose/ocr");
Resources.FetchResource("aspose-ocr-hindi-v1");
// Initialize Aspose.OCR recognition API
AsposeOCR api = new AsposeOCR();
RecognitionSettings recognitionSettings = new RecognitionSettings();
// Add image to the recognition batch
OcrInput source = new OcrInput(InputType.SingleImage);
source.add("image.png");
// Extract text from image
RecognitionSettings recognitionSettings = new RecognitionSettings();
recognitionSettings.setLanguage(Language.Hin);
ArrayList<RecognitionResult> results = api.Recognize(source, recognitionSettings);
System.out.println(result[0].recognition_text);
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.