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.

API-URL - http://opencv-api.herokuapp.com/
Documentation: http://opencv-api.herokuapp.com/docs
status: alpha

withot filter

face-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 = "http://opencv-api.herokuapp.com/api/v1/facefilter"

# enter your full file path
file_path = ""

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

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

r = requests.post(url, files=files, data=data)
print(r.json())
Enter fullscreen mode Exit fullscreen mode

facefilter

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)

Collapse
 
drakeentity profile image
Coding_Ninja

Great work buddy.

mypic