detectFaces
warning
The document is a continuation of the previous document, if you have landed directly on this page then, Please read from page Get started.
#
What is detectFaces component ?detectFaces component is used to detect faces. It takes image and probability as json string and returns bounding box , probability ,landmarks and response id.
- Description : detectFaces() takes an input(through STDIN) as image in base64 format and probability in float both wrapped in JSON format and returns the face information with each face probability greater than input given. Check Input and output parameters for details.
- Parameters :
- Input(Via STDIN) : A JSON String with following contents:
- Input1 : Image (.jpg/.png) in base64 format
- Input2 : Float probability (value between 0 to 1)
- Output(Via STDOUT) : A JSON string with following contents
- For each face
- Bounding box co-ordinates
- Probability being face
- 5 Landmarks co-ordinates values
- int responseID
- For each face
- Input(Via STDIN) : A JSON String with following contents:
#
List of detectFaces features in shunya stack- At the input level, you can customize the image probability, i.e. if you set probability = 0.8, then you will get detections for those faces whose probability > 0.8.
- Face detection APIs give you bounding boxes values, 5 landmarks and probability for detected faces.
#
Using detectFaces features in Shunya stack#
1. Setting probability threshold for faces being detectedStart with an ready to use template for detecting face from image.
You can see there are 2 folders: cpp-examples and python-examples.
C++ Example
In C++ example(detect_faces.cpp), you can set the probability at line number 40. Range of probability is between 0 to 1.
Python Example
In python example(detect_faces.py), you can set the probability at line number 18.
#
2. Getting following details after detectFaces APIdetectFaces APIs give the detected faces with
- Bounding box co-ordinates
- Probability being face
- 5 Landmarks co-ordinates values
for each face. Lets look into code to understand how to get those values.
C++
with above c++ program you will get the output in detectFacesOut variable which you can use to store the information about detected faces.
Python
with above python program, you will get the output in detectFacesOut variable which you can use to store the information about detected faces.
#
Understand this component with an example (ready to use code)- This is an example for face-detection and here we will be using 2 components: detectFaces and drawFaces
- Check this ready to use example in c++ and python
- C++ Example
- In this folder there is a file, face_detect.cpp
- detectFaces Components used
- drawFaces component used
- Run code by yourself
- You will get a new image stored in system.