Skip to content

Commit f8fea02

Browse files
Creation of a new catkin_pkg named face_recognition. Initial implementation
1 parent d1c74ae commit f8fea02

File tree

12 files changed

+196757
-0
lines changed

12 files changed

+196757
-0
lines changed

face_recognition/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cmake_minimum_required(VERSION 3.0.2)
2+
project(face_recognition)
3+
4+
5+
find_package(catkin REQUIRED COMPONENTS)
6+
7+
catkin_python_setup()
8+
9+
catkin_package()
10+
11+
install(PROGRAMS
12+
scripts/get_face_recognition
13+
scripts/face_recognition_node
14+
scripts/train_from_images
15+
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
16+
)
17+
if(CATKIN_ENABLE_TESTING)
18+
find_package(catkin_lint_cmake REQUIRED)
19+
catkin_add_catkin_lint_test()
20+
endif()

face_recognition/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# NEEDS WORK
2+
# image_recognition_openface
3+
4+
Face recognition with use of Openpose (https://cmusatyalab.github.io/openface/)
5+
6+
## Installation
7+
8+
See https://github.com/tue-robotics/image_recognition
9+
10+
Make sure that openface is correctly installed. Installation instructions can be found here: https://cmusatyalab.github.io/openface/setup/. Make sure you have installed **CUDA8**. CUDA10 is not working: https://github.com/torch/torch7/issues/1180
11+
12+
```bash
13+
export TORCH_INSTALL_PATH=~/torch
14+
export OPENFACE_INSTALL_PATH=~/openface
15+
git clone https://github.com/torch/distro.git ~/torch --recursive && \
16+
cd $TORCH_INSTALL_PATH && bash install-deps && ./install.sh && \
17+
for NAME in dpnn nn optim optnet csvigo cutorch cunn fblualib torchx tds; do $TORCH_INSTALL_PATH/install/bin/luarocks install $NAME; done && \
18+
sudo -H pip install dlib && \
19+
git clone https://github.com/cmusatyalab/openface.git $OPENFACE_INSTALL_PATH && \
20+
cd $OPENFACE_INSTALL_PATH && sudo -H python setup.py install && \
21+
./models/get-models.sh
22+
```
23+
24+
## How-to
25+
26+
### ROS Node
27+
28+
Run the image_recognition_openface node in one terminal (Specify the dlib and openface_net path as ROS parameter):
29+
30+
rosrun image_recognition_openface face_recognition_node
31+
32+
Run the rqt annotation client (https://github.com/tue-robotics/image_recognition_rqt)
33+
34+
rosrun image_recognition_rqt annotation_gui
35+
36+
Setup the service by clicking the gear wheel in the top-right corner. Select the `/annotate` services exposed by the openface ros node. Also don't forget to set-up your labels.
37+
38+
![Configuration](doc/config.png)
39+
40+
Now draw a rectangle around the face you would like to learn. The face recognizer will find the biggest face in the image and store a representation for this face.
41+
42+
![Annotate](doc/annotate.png)
43+
44+
Now select the label and you will see that the openface ros node stores the face (console output node):
45+
46+
[INFO] [WallTime: 1478636380.407308] Succesfully learned face of 'rokus'
47+
48+
Learn as many faces as you want ..
49+
50+
Next step is starting the image_recognition_Rqt test gui (https://github.com/tue-robotics/image_recognition_rqt)
51+
52+
rosrun image_recognition_rqt test_gui
53+
54+
Again configure the service you want to call with the gear-wheel in the top-right corner of the screen. If everything is set-up, draw a rectangle in the image and ask the service for detections:
55+
56+
![Test](doc/test_face.png)
57+
58+
You will see that the result of the detection will prompt in a dialog combo box. Also the detections will be drawn on the image.
59+
60+
### Command line
61+
62+
Command line interface to test the detection / recognition based on an image:
63+
64+
usage: get_face_recognition IMAGE [-k ALIGN_PATH] [-s NET_PATH] [-v]
65+
66+
Run the command on an example image:
67+
68+
rosrun image_recognition_openface get_face_recognition `rospack find image_recognition_openface`/doc/example.png
69+
70+
This will lookup this image in the image_recognition_openface/doc folder and perform recognitions
71+
72+
![Example](doc/example.png)
73+
74+
Output:
75+
76+
[RecognizedFace(roi=(374, 188, 108, 123), l2_distances=[]), RecognizedFace(roi=(72, 147, 88, 105), l2_distances=[]), RecognizedFace(roi=(377, 95, 74, 86), l2_distances=[]), RecognizedFace(roi=(149, 26, 74, 86), l2_distances=[]), RecognizedFace(roi=(52, 47, 75, 86), l2_distances=[]), RecognizedFace(roi=(246, 115, 88, 102), l2_distances=[]), RecognizedFace(roi=(0, 0, 42, 60), l2_distances=[]), RecognizedFace(roi=(336, 33, 74, 86), l2_distances=[]), RecognizedFace(roi=(228, 0, 62, 60), l2_distances=[])]
77+
78+
Since no faces were trained, the l2_distances will not be calculated of-course.

face_recognition/package.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0"?>
2+
<?xml-model
3+
href="http://download.ros.org/schema/package_format3.xsd"
4+
schematypens="http://www.w3.org/2001/XMLSchema"?>
5+
<package format="3">
6+
<name>face_recognition</name>
7+
<version>0.0.0</version>
8+
<description>The face_recognition package</description>
9+
10+
<maintainer email="[email protected]">iason</maintainer>
11+
12+
<license>MIT</license>
13+
14+
<buildtool_depend>catkin</buildtool_depend>
15+
16+
<buildtool_depend>python3-setuptools</buildtool_depend>
17+
<exec_depend>roscpp</exec_depend>
18+
<exec_depend>cv_bridge</exec_depend>
19+
<exec_depend>diagnostic_updater</exec_depend>
20+
<exec_depend>image_recognition_msgs</exec_depend>
21+
<exec_depend>image_recognition_util</exec_depend>
22+
<exec_depend>python-dlib</exec_depend> <!--pip package-->
23+
<exec_depend>python3-numpy</exec_depend>
24+
<exec_depend>python3-opencv</exec_depend>
25+
<exec_depend>rospy</exec_depend>
26+
27+
<test_depend>catkin_lint_cmake</test_depend>
28+
29+
<doc_depend>python3-sphinx</doc_depend>
30+
<doc_depend>python-sphinx-autoapi-pip</doc_depend>
31+
<doc_depend>python-sphinx-rtd-theme-pip</doc_depend>
32+
<doc_depend>python3-yaml</doc_depend>
33+
34+
35+
<export>
36+
<rosdoc config="rosdoc.yaml" />
37+
</export>
38+
</package>

face_recognition/rosdoc.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- builder: sphinx
2+
sphinx_root_dir: docs
3+
name: Python API

0 commit comments

Comments
 (0)