DEV Community

Cover image for How to use Face Detection API with JavaScript in 5 minutes?
Eden AI
Eden AI

Posted on • Originally published at edenai.co

How to use Face Detection API with JavaScript in 5 minutes?

In this tutorial, you will learn how to use Face Detection API in 5 minutes using JavaScript. Eden AI provides an easy and developer-friendly API that allows you to detect faces in images.

What is Face Detection API?

Face Detection API result on Eden AI

A face detection API is a software interface that allows developers to access and use a pre-built model for detecting faces in images. These APIs typically allow developers to send an image to the API, and the API will return the location and bounding box of any faces found in the image. These APIs can be used in a variety of applications such as security systems, image editing software, and social media platforms.

Getting Started with Face Detection API using JavaScript

The first step to getting started with Face Detection is to set Axios, a promise-based HTTP client for the browser and Node.js, that will allow you to call Eden AI API.

https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/638f08881993bd518d9ca0cc_carbon(3).png

Next, you'll need to initialize the File System module in order to access local files on your computer.

https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/638f088e8cc139623cbbce22_carbon(2).png

Finally, you'll need to create your multipart/formdata parameters form:

https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/638f09b0a3de914651c26a15_formdata.png

How to use Face Detection API with JavaScript

1. Get a Face Detection API Key on Eden AI

To perform Face Detection, you will need to create an account on Eden AI for free. Then, you will be able to get your API key directly from the homepage with free credits offered by Eden AI.

Eden AI platform - Get your API key

Get your API key for FREE

2. Let’s Detect Faces in your images

Now that you have initialized the required JavaScript module and got your API key, you will be able to detect faces in images. With Eden AI, you can choose from a wide rang of different engines you want for Face Detection. You can access Face Detection providers available on Eden AI on our documentation here.

Here is the JavaScript code to add the form data parameters values for your request:

https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/638f6cd8f8f3b452eee03d77_carbon(14).png

For example, we called two different Face Detection engines. Once the parameters values are passed, you can configure your request:

https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/638f6ce190643886e5a7ed55_carbon(15).png

Then, you just need to launch the request and print the result:

https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/638f6d1e1a7e8a83944abff6_carbon(16).png

Here is an example of a Face Detection API response:

https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63481f59d88c3f3b45faac6a_face-response.png

Benefits of using Face Detection API with Eden AI

Using Face Detection with Eden AI API is quick and easy.

Multiple AI engines in one API

Save time and cost

We offer a unified API for all providers: simple and standard to use, with a quick switch between providers and an access to the specificic features of each provider

Easy to integrate

The JSON output format is the same for all suppliers thanks to Eden AI's standardisation work. The response elements are also standardised thanks to Eden AI's powerful matching algorithms.

Customization

With Eden AI you have the possibility to integrate a third party platform: we can quickly develop connectors. To go further and customize your Face Detection request with specific parameters, check out our documentation.

Create your Account on Eden AI

Top comments (0)