Recognize a Photo of a Business Card, Extract Key Information in Python
Many of us don’t carry around traditional wallets these days, which makes storing new business cards a challenge — a challenge easily solved by taking a snapshot of the business card on your phone. Once in digital image format, you can use the Cloudmersive OCR API to recognize & extract key information from the business card with convenient labels such as “PersonName,” “PersonTitle,” “BusinessName,” and much more. You can connect your app in Python using the code below.
First things first, use the below command to install the Python SDK:
pip install cloudmersive-ocr-api-client
After that, you can copy in the callback function. In the second snippet, you’ll need to supply your Cloudmersive API key for authorization where indicated (if you don’t have a key, you can easily get one by creating a free account on the Cloudmersive website).
from __future__ import print_function
import time
import cloudmersive_ocr_api_client
from cloudmersive_ocr_api_client.rest import ApiException
from pprint import pprint# Configure API key authorization: Apikey
configuration = cloudmersive_ocr_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'# create an instance of the API class
api_instance = cloudmersive_ocr_api_client.ImageOcrApi(cloudmersive_ocr_api_client.ApiClient(configuration))
image_file = '/path/to/inputfile' # file | Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.try:
# Recognize a photo of a business card, extract key business information
api_response = api_instance.image_ocr_photo_recognize_business_card(image_file)
pprint(api_response)
except ApiException as e:
print("Exception when calling ImageOcrApi->image_ocr_photo_recognize_business_card: %s\n" % e)