drawFaces
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 drawFaces component ?drawFaces component is used to draw face data(detected faces information) on face image.
- Description : drawFaces() takes an input a json string with base64 image, and detected faces information(bounding boxes, probability and 5 landmarks) and returns base64 string with drawn values on image. Check Input and output parameters for details.
- Parameters :
- Input(Via STDIN) : A JSON String with following contents:
- Input1: For each detected face
- Bounding box co-ordinates
- Probability being face
- 5 Landmarks co-ordinates values
- Input2: Original image in base64 string format
- Input1: For each detected face
- Output(Via STDOUT) : A JSON string with following contents
- Base64 image string with drawn landmarks, bounding boxes and probability
- int responseID
- Input(Via STDIN) : A JSON String with following contents:
#
List of drawFaces features in shunya stack- Get Image with drawn face detections
#
Using drawFacesdrawFaces
#
Requirements to use - Shunya OS installed (supported Arm devices) or Shunya OS docker container (X86 based windows/linux devices)
- Shunya AI installed in Shunya OS.
drawFaces
#
Steps to use - Give face data JSON as an input.
- Get Image with drawn face detections
note
Run the steps given below inside Shunya OS installed (supported Arm devices) or Shunya OS docker container (X86 based windows/linux devices) terminals.
Lets take an example use case: Say we need to
- Give detected faces information as as input in JSON format
- Get JSON output of all the detected faces drawn on image.
Steps are
#
1. Give face data JSON as an input.Start with an ready to use template for drawing faces on image.
Open the examples in a text editor and modify as per your usecase.
- For CPP you will find the examples in the folder
cpp-examples/face-detection/drawFaces
- Open the file
draw_faces.cpp
- Modify the line to set the input json string
- For Python you will find the examples in the folder
python-examples/face-detection/drawFaces
- Open the file
draw_faces.py
- Modify the line to set the input json string
- For CPP you will find the examples in the folder
#
2. Get Image with drawn face detectionsOnce you are done editing, save and run the code, by running
Running the codes will print the JSON output on the terminal (to STDOUT).
For Example:
Lets say the input image is
Input JSON containing face data is
Then the JSON output is
#
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
Download the code
```shell git clone https://gitlab.iotiot.in/shunya/products/shunya-ai-examples.git cd shunya-ai-examples/python-examples/face-detection ```In this folder there is a file, face_detect.cpp or face_detect.py
detectFaces Components used
```shell detectFaces = Popen(['/usr/bin/detectFaces'], stdout=PIPE, stdin=PIPE) ```drawFaces component used
```shell drawFaces = Popen(['/usr/bin/drawFaces'], stdout=PIPE, stdin=PIPE) ```Run code by yourself
- You will get a new image stored in system.```shell python3 face_detect.py ```