Aug 26, 2021

1 min read

Identify Age from a Photo in C/C++

Gathering demographic information from images has never been easier — instead of perusing photos and attempting to analyze age, you can use Deep Learning technology to do the job for you. The following API leverages Deep Learning to identify the age, position, and size human faces in an image, and even provides a recognition confidence level on top of that.

The first step is to install libcurl in your C/C++ project:


After the installation, you can call the function with the below example code:

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: multipart/form-data");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_mime *mime;
curl_mimepart *part;
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
curl_mime_name(part, "imageFile");
curl_mime_filedata(part, "/path/to/file");
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
res = curl_easy_perform(curl);

With the process complete, you will be able to utilize the resulting data for a marketing campaign or study!