How to use Video Person Tracking API with JavaScript in 5 minutes?
Tags: persontracking, javascript, api, ai
Published: 2023-01-11 14:18:40

*In this tutorial, you will learn how to use person tracking API in 5 minutes using JavaScript and Eden AI person tracking API. Eden AI provides an easy and developer-friendly API that allows you to track persons in videos.*

## **What is Video Person Tracking API ?**

[Person Tracking API](https://www.edenai.co/feature/person-tracking?referral=how-to-person-tracking-javascript) allows you to track people and their activity within a scene or segment. The way that person tracking works is simple: person detection identifies individuals in a video, then tracks them over time by their face, clothing or posture.

![Person Tracking API results on Eden AI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kf04ik2gy2p7ifa6oduc.png)
Person Tracking API can be used as a standalone tool, or it can be combined with [face detection](https://www.edenai.co/feature/face-detection?referral=how-to-person-tracking-javascript) to generate more accurate results. You can use person tracking to analyze situations with high levels of complexity, such as crowded scenes with multiple individuals, crowded transportation areas such as airports, trains and metro stations.

‍

## **Getting Started with Video Person Tracking API**

The first step to start using person tracking API 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](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](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](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/638f09b0a3de914651c26a15_formdata.png)

‍

## **How to use Person Tracking API with JavaScript**

You are now ready to process your video file into Eden AI's person tracking API.

‍

### **1. Get your Person Tracking API Key on Eden AI**

To perform person tracking, you'll need to create an account on [Eden AI](https://app.edenai.run/user/register?referral=how-to-person-tracking-javascript) for free. Then, you will be able to get your **API key** direclty from the homepage with free credits offered by Eden AI.

![Eden AI - Get your API key for FREE](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dqaai8ms7znkbc3q6oxn.png)

**[Get your API key for FREE](https://app.edenai.run/user/register?referral=how-to-person-tracking-javascript)**

### **2. Let’s Track Persons in your Video File**

Now that you have initialized the required JavaScript modules and got your API key, you will be able to track persons in videos. With Eden AI, you can choose from a wide range of different engines you want for person tracking. You can access all our person tracking providers on our documentation [here](https://docs.edenai.co/reference/video_person_tracking_async_create?referral=how-to-person-tracking-javascript).
Here is the JavaScript code to add FormData parameters values for your request:
![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/639335a3bff36d79e19778b4_carbon(38).png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/639335a3bff36d79e19778b4_carbon(38).png)
For example, we called two different person tracking engines. Once the parameters values are passed, you can configure your request:
![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/639335adb61a6c3debe367ba_carbon(39).png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/639335adb61a6c3debe367ba_carbon(39).png)
Next, you'll need to create launchJob() function that will execute POST request:
![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/639317be6d8df4260a9af1b0_carbon(23).png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/639317be6d8df4260a9af1b0_carbon(23).png)
Then, you'll have to create the getJob() function that will execute GET request with the Job ID of your POST request:
![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/639335b8cea6fb49796114ac_carbon(40).png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/639335b8cea6fb49796114ac_carbon(40).png)
You will first get this response:

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63468b71bcd332585a894d57_table-get-process.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63468b71bcd332585a894d57_table-get-process.png)

Once the request is done (status : finished), you will be able to get the result for Person Tracking task:

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63468f732e28f581cedbe5a9_person-get-response.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63468f732e28f581cedbe5a9_person-get-response.png)

## **Benefits of using Person Tracking API with Eden AI**

Using person tracking with Eden AI API is quick and easy.

![Multiple AIs in one API - Eden AI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l9un8l9n89yyu802nkkz.gif)
### 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 Person Tracking request with specific parameters, check out our [documentation](https://docs.edenai.co/reference/video_person_tracking_async_retrieve?referral=how-to-person-tracking-javascript).

**[Create your Account on Eden AI](https://app.edenai.run/user/register?referral=how-to-person-tracking-javascript)**