How to Unskew a Photo of a Document in Python

Document scanning applications benefit dramatically from OCR preprocessing steps. Thankfully, using only a few lines of complementary, ready-to-run Python code examples provided further down the page, you can take advantage of a free & powerful OCR preprocessing API which automatically detects and unskews a photo of a document (into a perfectly square image). Using this solution before any downstream OCR operations (especially those handling images from handheld cameras & smartphones) with improve the accuracy of that operation and lead to more consistent OCR results.

To install the Python SDK, first run the below command:

Next, add the imports and call the function:

To complete your API call & use this API for free, register a free account on our website and copy your free-tier API key into the configuration.api_key field above. Your free-tier key will supply a limit of 800 API calls per month with zero additional commitments upon reaching that limit.

--

--

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

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
Cloudmersive

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