nobita
A non-verbal communication library for robot development using OAK-D
Japanese readme is here.
Preparing
To use this library, you need a Python environment running OAK-D and DepthAI.
Install by PyPi
pip install nobita
Install by the repository
pip install https://github.com/wbawakate/nobita
Overview
Since Nobita wraps the tedious process of DepthAI, two-step inference such as face detection and emotion estimation can be done with few lines of code.
This figure shows the data flow when using DepthAI and OAK-D to handle multiple neural networks. First, the first neural network is used to infer the image obtained from the RGB of OAK-D. Then you need to convert the data into the input format of that second neural network. Therefore, it is necessary to transfer data between the OAK-D and the host computer many times. When using raw DepthAI, the amount of code to write tends to increase because all data transfer needs to be defined. With Nobita, you can more easily deploy multiple neural networks to OAK-D.
There are two main elements to Nobita; nobita.modules and nobita.VisionPipeline. nobita.modules is a set of neural network modules that handle typical tasks related to non-verbal communication, such as face detection and emotion inference. For more information, see Modules. nobita.VisionPipeline deploys nobita.modules as a pipeline to OAK-D and performs continuous inference.
Now, let's start emotion estimation from face images using nobita. The following is the code for face detection and emotion estimation.
import cv2
import numpy as np
from nobita import VisionPipeline
from nobita.modules import FaceDetection, EmotionEstimation
emotions = ["neutral", "happy", "sad", "surprise", "anger"]
# prepare VisionPipeline of nobita
# pass `nobita.modules` to modules as a list
# if you use OAK-D, set `use_oak=True`
with VisionPipeline(modules=[FaceDetection(), EmotionEstimation()], use_oak=True) as pipeline:
while True:
# get result of estimation and camera preview as dict
# key of the dict is name of `nobita.modules`.
# value of the dict is list of numpy.array, which is prediction values of estimation of the `nobita.module`.
out_frame = pipeline.get()
if out_frame["FaceDetection"] :
# facial image by cropped by face detection
face_cv2_frame = cv2.UMat(out_frame["FaceDetection"][0] )
if out_frame["EmotionEstimation"]:
id_emo = np.argmax(out_frame["EmotionEstimation"][0])
max_prob = np.max(out_frame["FaceDetection"][0])
# put estimated emotion on a facial image as text
cv2.putText(face_cv2_frame, f"{emotions[id_emo]}",(5, 15),cv2.FONT_HERSHEY_TRIPLEX,0.6,(255,0,0))
# show the facial image
cv2.imshow(f"face 0", face_cv2_frame)
if cv2.waitKey(1) == ord("q"):
cv2.destroyAllWindows()
break
Just pass nobita.modules such as FaceDetection and EmotionEstimation to nobita.VisionPipeline to perform two-step inference easily. The result of the inference can be retrieved as a dictionary with pipeline.get(). In the demo, the emotion text inferred by EmotionEstimation is pasted on the face image detected by FaceDetection and shown on the display.
Demo
There is demo code for each module in demo/.
Run the code as follows in the demo/ directory.
python face_emotion.py
Each demo has an option --device. This option allows you to specify the device to capture the video. If you are using OAK-D, specify -1 (default). When using other webcams, specify the same device ID as when specifying the device in OpenCV.
Module
Below table is a list of nobita.modules.
| module | discription | source | blob file |
|---|---|---|---|
| FaceDetection | face detection | OpenVINO Toolkit | face-detection-retail-0004_openvino_2021.2_6shave.blob |
| PoseEstimation | human pose estimation | depthai_movenet | movenet_singlepose_lightning_U8_transpose.blob |
| EmotionEstimation | emotion estimation by facial imases | OpenVINO Toolkit | emotions-recognition-retail-0003.blob |
| AgeGender | age and gender estimation facial imases | OpenVINO Toolkit | age-gender-recognition-retail-0013_openvino_2021.2_6shave.blob |
| FaceLandmark | facial landmark detection by facial images | OpenVINO Toolkit | facial-landmarks-35-adas-0002-shaves6.blob |
| HeadPose | head pose estimation by facial images | OpenVINE | head-pose-estimation-adas-0001-shaves4.blob |
Credit
- WBA Future Leaders ( https://wbawakate.jp )
Metadata
Release files for nobita 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nobita-0.0.1.tar.gz | 43.0 MB | Without provenance | Details for nobita-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nobita-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for nobita-0.0.1-py3-none-any.whl |
Total release size: 86.0 MB
Release files / nobita-0.0.1.tar.gz
| Download URL | nobita-0.0.1.tar.gz |
|---|---|
| Size | 43.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
32b2589cd8d93413612d3511808fd80a80dcbd5417449dbc904682f5fe8bba78
|
|
BLAKE2b-256 checksum How to use checksums |
39ba75af63740df410c8d626b57d2a246b103b5377ad524d01a08483b2bf9886
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.7 CPython/3.9.5 Linux/5.4.0-80-generic
|
Release files / nobita-0.0.1-py3-none-any.whl
| Download URL | nobita-0.0.1-py3-none-any.whl |
|---|---|
| Size | 43.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce001db0f3c430009df4ed2e16072ac4b3ccac6d5bf9677542f10721387e7521
|
|
BLAKE2b-256 checksum How to use checksums |
b46c13cbc375d73f4cd7376c0bf5aa68472d47232de0d467af7017dd55071b22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.7 CPython/3.9.5 Linux/5.4.0-80-generic
|
Security for nobita 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.