Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added face emotion game app #300

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ For a step by step tutorial on how to build an image classification network look
|[simple_classifier_cpp](simple_classifier_cpp/README.md) | C++<br>Multiple Networks<br>Application reads a single image from the filesystem and does an image classification inference on that image. Takes the image, the network and a labels file on the commandline|![](simple_classifier_cpp/screen_shot.jpg)|
|[simple_classifier_py](simple_classifier_py/README.md) | Python<br>Multiple Networks<br>Application reads a single image from the filesystem and does an image classification inference on that image. Takes the image, the network and a labels file on the commandline|![](simple_classifier_py/screen_shot.jpg)|
|[simple_classifier_py_camera](simple_classifier_py_camera/README.md) | Python<br>Multiple Networks<br>Application reads a video stream from a camera and does image classification inference on the stream continually updating the top result.|![](simple_classifier_py_camera/screen_shot.jpg)|
|[face_emotion_game](face_emotion_game/README.md) | Python<br>Multiple Networks<br>Application reads a video stream from a camera and does face detection and emotion recognition, the app presented as a game, and user can collect scores by his facial expressions.|![](face_emotion_game/screenshot.jpg)|


## Object Detection Applications
Expand Down
119 changes: 119 additions & 0 deletions apps/face_emotion_game/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
GREEN = '\033[1;32m'
YELLOW = '\033[1;33m'
NOCOLOR = '\033[0m'

# filenames for the graph files that we'll copy to this directory.
FACE_RELATIVE_DIR = ../../networks/face_detection_retail_0004
FACE_FILE_NAME_BASE = face-detection-retail-0004

EMOTION_RELATIVE_DIR = ../../networks/emotions_recognition_retail_0003
EMOTION_FILE_NAME_BASE = emotions-recognition-retail-0003


# name of the directory and the base name of the main python file (minus the .py extension)
APP_NAME = face_emotion_game

.PHONY: all
all: deps data


.PHONY: data
data:
@echo $(YELLOW)'\n'${APP_NAME}": No data required."$(NOCOLOR)


.PHONY: deps
deps: get_ir
@echo $(YELLOW)'\n'${APP_NAME}": Making dependencies..."$(NOCOLOR)



.PHONY: default_model
default_model: get_ir
@echo $(YELLOW)'\n'${APP_NAME}": Making default models..."$(NOCOLOR)


.PHONY: get_ir
get_ir:
@echo $(YELLOW)'\n'${APP_NAME}": Downloading IRs..."$(NOCOLOR);
@if [ -e ${EMOTION_FILE_NAME_BASE}.xml ] && [ -e ${EMOTION_FILE_NAME_BASE}.bin ] ;\
then \
echo " - Emotion Recognition IRs already exist in the project folder.";\
else \
echo " - Emotion Recognition IR files do not exist in project directory.";\
echo " - Making Emotion Recognition IRs...";\
(cd ${EMOTION_RELATIVE_DIR}; make get_ir;);\
echo " - Copying Emotion Recognition IR files to current folder..." ;\
mkdir src/data ;\
mkdir src/data/emotions-recognition ;\
cp ${EMOTION_RELATIVE_DIR}/${EMOTION_FILE_NAME_BASE}.xml src/data/emotions-recognition/ ;\
cp ${EMOTION_RELATIVE_DIR}/${EMOTION_FILE_NAME_BASE}.bin src/data/emotions-recognition/ ;\
fi;\
@if [ -e ${FACE_GEN_MODEL_FILE_NAME_BASE}.xml ] && [ -e ${FACE_GEN_MODEL_FILE_NAME_BASE}.bin ] ;\
then \
echo " - Face detection model IR already exist in the project folder.";\
else \
echo " - Face detection model IR files do not exist in project directory.";\
echo " - Making Face detection IRs...";\
(cd ${FACE_RELATIVE_DIR}; make get_ir;);\
echo " - Copying Face IR files to current folder..." ;\
mkdir src/data ;\
mkdir src/data/face-detection ;\
cp ${FACE_RELATIVE_DIR}/${FACE_FILE_NAME_BASE}.xml src/data/face-detection/ ;\
cp ${FACE_RELATIVE_DIR}/${FACE_FILE_NAME_BASE}.bin src/data/face-detection/ ;\
fi


.PHONY: run
run: run_py


.PHONY: run_py
run_py: deps data
@echo $(YELLOW)'\n'${NETWORK_NAME}": Running Python sample..."$(NOCOLOR)
@echo "Checking OpenVINO environment..."
@if [ -z "$(INTEL_OPENVINO_DIR)" ] ; \
then \
echo "Please initiate the Intel OpenVINO environment by going to the installation directory for openvino and running the setupvars.sh file in the bin folder." ; \
exit 1 ; \
else \
echo "Intel OpenVINO environment is already set!" ; \
fi
python3 ${APP_NAME}.py -m -fps;


.PHONY: install-reqs
install-reqs:
@echo $(YELLOW)"\n"$(APP_NAME)": Checking installation requirements..."$(NOCOLOR)
@echo "No requirements needed."


.PHONY: uninstall-reqs
uninstall-reqs:
@echo $(YELLOW)'\n'${APP_NAME}": Uninstalling requirements..."$(NOCOLOR)
@echo "Nothing to uninstall."


.PHONY: help
help:
@echo "\nPossible make targets: ";
@echo $(YELLOW)" make run or run_py"$(NOCOLOR)"- runs the application";
@echo $(YELLOW)" make help "$(NOCOLOR)"- shows this message";
@echo $(YELLOW)" make all "$(NOCOLOR)"- makes everything needed to run but doesn't run";
@echo $(YELLOW)" make data "$(NOCOLOR)"- downloads data as needed";
@echo $(YELLOW)" make deps "$(NOCOLOR)"- makes/prepares dependencies";
@echo $(YELLOW)" make install-reqs "$(NOCOLOR)"- Installs requirements needed to run this sample on your system.";
@echo $(YELLOW)" make uninstall-reqs "$(NOCOLOR)"- Uninstalls requirements that were installed by the sample program.";
@echo $(YELLOW)" make default_model "$(NOCOLOR)"- compiles a default model to use when running";
@echo $(YELLOW)" make get_ir "$(NOCOLOR)"- gets the age-gender/face IR files from the model zoo";
@echo $(YELLOW)" make clean "$(NOCOLOR)"- removes all created content"
@echo ""


clean:
@echo $(YELLOW)'\n'${APP_NAME}": Cleaning up files..."$(NOCOLOR);
rm -f src/data/emotions-recognition/${EMOTION_FILE_NAME_BASE}.xml;
rm -f src/data/emotions-recognition/${EMOTION_FILE_NAME_BASE}.bin;
rm -f src/data/face-detection/${FACE_FILE_NAME_BASE}.xml;
rm -f src/data/face-detection/${FACE_FILE_NAME_BASE}.bin;

65 changes: 65 additions & 0 deletions apps/face_emotion_game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Face Emotion Game
## Introduction
This app does facial detection and emotion detection using the Intel Movidius Neural Compute Stick 2.

The example does face detection on a camera frame using face-detection-retail.0004, crops the detected faces, then does emotion recognition using the emotions-recognition-retail-0003 network. When running, the app shows the realtime camera preview while overlaying, a box around faces (color coded for gender), and the facial expressions label. User should do their expression to match the emoji that appears on top of the camera window. All models can be found on the [Open Model Zoo](https://github.com/opencv/open_model_zoo). This sample uses pre-compiled IRs, so the model optimizer is not utilized.

![](src\images\face_emotion_game.png)


## Building the Example

To run the example code do the following:
1. Open a terminal and change directory to the sample base directory
2. Type the following command in the terminal: ```make all```

## Running the Example

After building the example you can run the example code by doing the following:
1. Open a terminal and change directory to the sample base directory
2. Type the following command in the terminal: ```make run```

When the application runs normally, another window should pop up and show the feed from the webcam/usb cam. The program should perform inferences on faces on frames taken from the webcam/usb cam.

## Prerequisites
This program requires:
- 1 x NCS2 device
- 1 x Raspberry Pi 3
- 1 x Webcam (USB)
- OpenVINO 2019 R2 Toolkit

*It may run with older versions but you may see some glitches such as the GUI Window not closing when you click the X in the title bar, and other key binding issues.

Note: All development and testing has been done on Raspberry Pi 3.

## Makefile
Provided Makefile has various targets that help with the above mentioned tasks.

### make run or make run_cpp
Runs the sample application.

### make help
Shows available targets.

### make all
Builds and/or gathers all the required files needed to run the application.

### make data
Gathers all of the required data need to run the sample.

### make deps
Builds all of the dependencies needed to run the sample.

### make default_model
Compiles an IR file from a default model to be used when running the sample.

### make install-reqs
Checks required packages that aren't installed as part of the OpenVINO installation.

### make uninstall-reqs
Uninstalls requirements that were installed by the sample program.

### make clean
Removes all the temporary files that are created by the Makefile.


Loading