DEV Community

Cover image for OpenCV-Snapchat Filter RestAPI with FastAPI
Deepak Raj
Deepak Raj

Posted on • Updated on

OpenCV-Snapchat Filter RestAPI with FastAPI

It's a Rest API for Face Filter using OpenCV, FastAPI.
Currently, It's using a simple haar cascade for face detection and applying mask by resizing on the face.
It can be integrated into the web app or Android/IOS mobile APP.

status: alpha

withot filter


Try It with your picture.

you will get the Image Url in Response. open it in the browser.

Create a POST request with file-field to get the filtered Image.

import requests

url = ""

# enter your full file path
file_path = ""

files ={
    'file': open(file_path, 'rb')

#choose mask 1 to 3
data ={
    'mask': 2

r =, files=files, data=data)
Enter fullscreen mode Exit fullscreen mode


face detection

Future roadmap

Facial keypoints and face emotion deep learning models for better accuracy and mask.

Share your Filtered Image in Comments and your Feedback.

Top comments (1)

drakeentity profile image

Great work buddy.