Age detection is an excellent way to gather user data and tailor advertising subjects. Normally this useful functionality is locked behind AI training and other tedious processes. However, today we will look at how to accomplish this very quickly and easily. Let’s get straight to it.
We begin simply enough by installing our API client using NuGet:
Install-Package Cloudmersive.APIClient.NET.ImageRecognition -Version 1.3.5
Now call the FaceDetectAge function and provide your image file using the following snippet.
using Cloudmersive.APIClient.NET.ImageRecognition.Model;namespace Example
public class FaceDetectAgeExample
public void main()
// Configure API key authorization: Apikey
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new FaceApi();
var imageFile = new System.IO.Stream(); // System.IO.Stream | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.try
// Detect the age of people in an image
AgeDetectionResult result = apiInstance.FaceDetectAge(imageFile);
catch (Exception e)
Debug.Print("Exception when calling FaceApi.FaceDetectAge: " + e.Message );
And that’s it! All done. Let’s take a quick look at an example:
And here is a response for our image:
As you can see, this function supports multiple people and provides their location in the photograph, as well as the age information.