Create AR Face Filters With the Chrome Face Detection API

Rate this content
Bookmark

In the fast pacing space of social media apps, some functionality could also be used for web applications. I am going to show you how you could use the feature flagged Face Detection API in Chrome. With a demo, we will explore the possibilities to implement face filters in your future projects. With the webcam access of a device, we add glasses by processing a video feed and using it for fun, finding that sweet spot where fun and learning come together.

FAQ

To enable the Chrome Face Detection API, you need to activate a feature flag in the Chrome browser. This involves accessing a specific URL in Chrome and enabling the experimental feature through the browser's settings.

The Chrome Face Detection API is part of the larger Shape Detection API that includes text detection and barcode detection. It focuses on detecting faces in media but does not recognize specific individuals. It identifies presence and location of a face without distinguishing personal identity.

The face detector can handle properties such as 'maxDetectedFaces' to set the maximum number of faces to detect, and 'fastMode', which when set to true, speeds up the detection process but provides less detailed data.

Yes, the Chrome Face Detection API can handle both still images and video streams. However, detecting multiple faces in a video stream can be challenging as it may randomly select faces in each frame depending on the movement and number of faces.

Practical uses of the Chrome Face Detection API include enhancing augmented reality (AR) applications, improving photo alignment by automatically centering faces in profile pictures, and security applications like monitoring areas for the presence of people.

The API can detect rotated faces to a certain threshold. If the rotation exceeds this threshold, the detection might fail. However, developers can programmatically adjust the source image or video to compensate for the rotation and improve detection accuracy.

Limitations include difficulty in handling multiple faces simultaneously, especially in video streams, and challenges associated with face detection in varying light conditions, angles, and rotations beyond certain thresholds.

Developers can customize the output by applying different filters or effects to detected faces, such as adding virtual glasses. They can also manipulate the landmarks detected (like eyes and nose) to introduce creative visual enhancements in applications.

Jorrik Klijnsma
Jorrik Klijnsma
30 min
01 Jun, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The Chrome Face Detection API is part of the bigger shape detection API and includes text detection and barcode detection. Enabling the API is as simple as opening a specific URL and enabling the experimental feature. The API provides features like detecting faces and processing landmarks, rendering glasses on faces, and applying face filters. It can handle multiple faces and images in videos, but performance depends on hardware and device processing speed. The API is currently in progress and feedback is being requested for potential production capabilities.

1. Introduction to Chrome Face Detection API

Short description:

Welcome. My name is Jorrik Leijnsma. I'm a creative front-end developer and I'm going to share something about the Chrome face detection API. Developers come with some kind of image. Sometimes we are a bit nerdy, but we are also problem solvers. Code can be fun and what you create with code is often seen as fun. AI is introduced into the scene, and there are more demanding users expecting more features. The Chrome Face Detection API is part of the bigger shape detection API.

Welcome. My name is Jorrik Leijnsma. As Caroline said, I'm a creative front-end developer and I'm going to share something about the Chrome face detection API. It's a mouthful, but managed to say it okay.

So, I'm a front-end developer and I work for over six years as a front-end developer now. Last two years at a company called Ordina. And, what we have, we are developers. I think most of us are here. And developers come with some kind of image. Sometimes we are a bit, like, nerdy, and... But we are also problem solvers.

But there's also this shift changing where code can be fun, and also what you create with code is more and more often seen as fun. But the code part is still boring. And that's where sometimes there is this interesting thing where you also want to create no boring code. But also not the great end result. So maybe people can show hands if you have seen boring code somewhere in your life. Yeah. I think most of us have. Or have you seen code that's not boring and was more interesting? Maybe also raise hands. So maybe a few less, but still there. And the last question, maybe people have seen code that was not functional at all, but was purely for fun purposes. So also some hands over there.

With the recent years, these all kinds of developments, AI is introduced into the scene. There are more demanding users. They are expecting more and more features. And you have the problem of maybe not being noticed if you don't have these amazing features in your app or service or whatever. So you need to be divergent and show what you can do and what's possible. This Chrome Face Detection API, it's something that's behind the feature flag, meaning it's not usable right out of the box. There is a process for this shape detection API. The Chrome Face Detection API is part of that bigger shape detection API.

2. Enabling the Chrome Face Detection API

Short description:

The Chrome Face Detection API includes text detection and barcode detection. It's important to note that face detection does not mean face recognition. Enabling the Chrome feature flag is as simple as opening a specific URL and enabling the experimental feature. You can then use the face detector by calling a new face detector and setting the max detected faces and fast mode properties.

It includes text detection and also barcode detection. And the barcode detection is already done, it's ready to use for everyone. But that face detection and text detection are still being developed. For this, it's an important note that the face detection does not mean face recognition. So it detects your face, but is not able to recognize a face from this is this person or that's that user logging in. So it's only showing there is this face on this type of media.

So how do you enable the Chrome feature flag? So there's this link, when you open this, let me try if it works. No, that needs to open. Let me copy paste it in then. It's not not not a valid normal link, choose application and then show options. You're not seeing this. I have to select Chrome for it to open. Google Chrome browser. So over here, let me slide it over. So now it should be visible. This is the part if you open that URL. You're seeing this experimental feature thing. And you just need to enable it. It comes with some other features as well. So keep that in mind. I recently got some trouble with selecting, for example, text on GitHub, which is not showing properly, so that also seems to be part of this something buggy going on in this web platform stuff. So that's how you enable this feature. Like this. That was way easier. So now you have enabled in your browser and now you can use it.

To use it, you start to call a new face detector. It's as simple as that. It can handle two properties. It can handle the max detected faces, which can set to I think any number, but at a certain point, your machine is not going to be fast enough to detect all those faces. And there's this fast mode which can be true or false.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Install Nothing: App UIs With Native Browser APIs
JSNation 2024JSNation 2024
31 min
Install Nothing: App UIs With Native Browser APIs
You might not need as much JS as you think to accomplish common UI patterns with these new native browser APIs. Dive into new and future CSS, HTML and JS APIs that make our code leaner and faster to ship.
Pushing the Limits of Video Encoding in Browsers With WebCodecs
JSNation 2023JSNation 2023
25 min
Pushing the Limits of Video Encoding in Browsers With WebCodecs
Top Content
High quality video encoding in browsers have traditionally been slow, low-quality and did not allow much customisation. This is because browsers never had a native way to encode videos leveraging hardware acceleration. In this talk, I’ll be going over the secrets of creating high-quality videos in-browsers efficiently with the power of WebCodecs and WebAssembly. From video containers to muxing, audio and beyond, this talk will give you everything you need to render your videos in browsers today!
Visualising Front-End Performance Bottlenecks
React Summit 2020React Summit 2020
34 min
Visualising Front-End Performance Bottlenecks
There are many ways to measure web performance, but the most important thing is to measure what actually matters to users. This talk is about how to measure, analyze and fix slow running JavaScript code using browser APIs.
WebHID API: Control Everything via USB
JSNation 2022JSNation 2022
23 min
WebHID API: Control Everything via USB
Operational System allows controlling different devices using Human Interface Device protocol for a long time. With WebHID API you can do the same right from the browser. Let’s talk about the protocol features and limitations. We’ll try to connect some devices to the laptop and control them with JavaScript.
MIDI in the Browser... Let's Rock the Web!
JSNation 2022JSNation 2022
28 min
MIDI in the Browser... Let's Rock the Web!
If you own an electronic music instrument made in the last 3 decades, it most likely supports the MIDI protocol. What if I told you that it is possible to interact with your keytar or drum machine directly from your beloved browser? You would go crazy, right? Well, prepare to do so…With built-in support in Chrome, Firefox and Opera, this possibility is now a reality. This talk will introduce the audience to the Web MIDI API and to my own WEBMIDI.js library so you can get rockin' fast.Web devs, man your synths!
Web Push Notifications Done Right
JSNation 2023JSNation 2023
11 min
Web Push Notifications Done Right
Finally, Web Push API is available in all major browsers and platforms. It's a feature that can take your users' experience to the next level or... ruin it! In my session, after a tech intro about how Web Push works, we'll explore implementing smart permission request dialogues, various types of notifications themselves, and communicating with your app for more sophisticated scenarios - all done right, with the best possible UX.

Workshops on related topic

Writing Universal Modules for Deno, Node and the Browser
Node Congress 2022Node Congress 2022
57 min
Writing Universal Modules for Deno, Node and the Browser
Workshop
Luca Casonato
Luca Casonato
This workshop will walk you through writing a module in TypeScript that can be consumed users of Deno, Node and the browsers. I will explain how to set up formatting, linting and testing in Deno, and then how to publish your module to deno.land/x and npm. We’ll start out with a quick introduction to what Deno is.