How to Detect and Un-Skew a Photo of a Document using Java

// 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.RecognizeApi;
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)
RecognizeApi apiInstance = new RecognizeApi();
File imageFile = new File("/path/to/inputfile"); // File | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
String postProcessingEffect = "postProcessingEffect_example"; // String | Optional, post-processing effects to apply to the email, default is None. Possible values are None and BlackAndWhite (force the image into a black and white view to aid in OCR operations).
try {
byte[] result = apiInstance.recognizeDetectAndUnskewDocument(imageFile, postProcessingEffect);
} catch (ApiException e) {
System.err.println("Exception when calling RecognizeApi#recognizeDetectAndUnskewDocument");



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store



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