Automatically detecting faces in a photograph has never been easier. Our image procession API lets you instantly harness the power of machine learning to trivialize this task in minutes. Let’s take a quick look at how to do this.
First step is to install the API client using pip installer.
Second, call face_locate:
from __future__ import print_function
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'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API class
api_instance = cloudmersive_image_api_client.FaceApi(cloudmersive_image_api_client.ApiClient(configuration))
image_file = '/path/to/file' # file | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.try:
# Find faces in an image
api_response = api_instance.face_locate(image_file)
except ApiException as e:
print("Exception when calling FaceApi->face_locate: %s\n" % e)
And that’s it. No really, that’s all you’ve got to do. Let’s look at a quick example using the following image:
Our result looks like this:
As you can see, it specifies the corners of each face as well as the number of total faces.