Detect Large Text in a Photo in Python

Cloudmersive
2 min readFeb 14, 2022

--

If you’re building applications to handle & process a high volume of images, it’s very useful to identify key characteristics of those images without opening them. With this iteration of the Cloudmersive Image API (/imate/recogznie/detect-text/large), you can identify the position and size of large text within a given photograph and plan your next photo edits accordingly. It’s important to note, however, that this iteration is NOT suitable for high-density text — it’s intended for photos that may or may not have important text somewhere within the image. Below, we’ll run through connecting to this API in Python (all code is ready-to-run & copied from the Cloudmersive API Console).

First things first, install the Python SDK using the below command:

pip install cloudmersive-image-api-client

Next, use the below code snippets to complete the API call and return the information about your image. You can simply copy & paste your Cloudmersive API key into the middle snippet where indicated (and if you don’t have a key, you can get one easily by making a free account on the Cloudmersive website):

from __future__ import print_function
import time
import cloudmersive_image_api_client
from cloudmersive_image_api_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: Apikey
configuration = cloudmersive_image_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# create an instance of the API class
api_instance = cloudmersive_image_api_client.RecognizeApi(cloudmersive_image_api_client.ApiClient(configuration))
image_file = '/path/to/inputfile' # file | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
try:
# Detect large text in a photo
api_response = api_instance.recognize_detect_text_large(image_file)
pprint(api_response)
except ApiException as e:
print("Exception when calling RecognizeApi->recognize_detect_text_large: %s\n" % e)

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet