๐Ÿ’ปBasic OpenCV API with Django ๐Ÿ“ท

๐Ÿ˜ˆFace Detection API ๐Ÿ˜„

Resource :

I updated the code from PyImageSearch Blog to Python 3 and Django 3.

MVT (Model - View -Template)

Setup :

pip install numpy django requests

Create Project :

django-admin startproject face_api
cd face_api
code . # Visual Stusio Code
  • create a new app named face_detector
python manage.py startapp face_detector

Create API :

  • Edit views.py in face_detector

โ— ๏ธ _grab_image is private function. Unable to run from outside the views.py file. you can move _grab_image to other file and setting with __all__ for change to public function.

โ• if you import module by :

from module_name import *

private variable , private class and private function are not imported

โ• if _ (single underscore) โž• variable_name โžก๏ธ private variable

โ• if _ (single underscore) โž• class_name โžก๏ธ private class

โ• if _ (single underscore) โž• function_name โžก๏ธ private function

  • Edit urls.py in face_api

Download and Import Face Detection Model

mkdir cascades

import model to cascades folder and edit code line 14 in file views.py

Test API :

python manage.py runserver
  • if api can detect face on your image from HTTP POST, api will send result is true [JSON format]
{ success : true } 

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Nonpavit Detbun ๐Ÿ”‹๐Ÿบ
Nonpavit Detbun ๐Ÿ”‹๐Ÿบ

Written by Nonpavit Detbun ๐Ÿ”‹๐Ÿบ

Iโ€™m Electrical Engineering. ๐Ÿ“Ÿ I have an interest in Web App, Mobile App, IoT and Microcontroller ๐Ÿง

Responses (2)

Write a response