OCR Preprocessing API: Utilize Machine Learning to Convert an Image of Text into a Binary View

Cloudmersive
1 min readApr 18, 2022

--

Looking for enhanced accuracy in image binarization for OCR? Our Deep Learning Binarization API kicks it up a notch, converting an image of text to a light and dark view and upsampling it to 300 DPI (if currently below that number).

For your convenience, instructions are included below to connect your API using Java (installation with Maven).

Start by adding this reference to the pom.xml repository:

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

After that, add a reference to the pom.xml dependency:

<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v4.25</version>
</dependency>
</dependencies>

Then add the below import classes and call the function:

// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.PreprocessingApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");
PreprocessingApi apiInstance = new PreprocessingApi();
File imageFile = new File("/path/to/inputfile"); // File | Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
try {
byte[] result = apiInstance.preprocessingBinarizeAdvanced(imageFile);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PreprocessingApi#preprocessingBinarizeAdvanced");
e.printStackTrace();
}

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet