Author: Jordi Pages < firstname.lastname@example.org >
Maintainer: Sara Cooper < email@example.com >
|Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.|
Face detection (C++)Description: Example of ROS node embedding OpenCV's face detector.
Tutorial Level: ADVANCED
Next Tutorial: Planar object detection and pose estimation
This tutorial presents a ROS node that subscribes to an image topic and applies the OpenCV face detector based on an Adaboost cascade of Haar features. The node publishes ROIs of the detections and a debug image showing the processed image with the ROIs likely to contain faces.
First, make sure that the tutorials are properly installed along with the ARI simulation, as shown in the Tutorials Installation Section.
Download the face detector
In order to execute the demo first we need to download the source code of the face detector. Run the following instructions:
cd ~/tiago_public_ws/src git clone https://github.com/pal-robotics/pal_face_detector_opencv.git
Building the workspace
Now we need to build the workspace
cd ~/ari_public_ws catkin build
Open four consoles and in each one source the workspace
cd ~/ari_public_ws source ./devel/setup.bash
In the first console launch the simulation
$ roslaunch ari_gazebo ari_gazebo.launch public_sim:=true world:=tutorial_office
Note that in this simulation world there are several person models
In the second console run the face detector node as follows
$ roslaunch pal_face_detector_opencv detector.launch image_topic:=/head_front_camera/image_raw
In order to detect faces we need that the robot approaches the persons. In the third console run the key_teleop node as follows
$ rosrun key_teleop key_teleop.py
Then, using the arrow keys of the keyboard we can make ARI move around the simulated world and approach the different persons.
Watching the detections
In the fourth console we may run an image visualizer to see the face detections
$ rosrun image_view image_view image:=/pal_face/debug
Note that faces detected are stroked with a ROI. The detections are not only represented in the /pal_face/debug Image topic but also in /pal_face/faces, which contains a vector with the image ROIs of all the detected faces. In order to see the contents of the topic we may use
$ rostopic echo -n 1 /pal_face/faces
which will prompt one message of the topic that when a face is detected will look like
header: seq: 0 stamp: secs: 1222 nsecs: 399000000 frame_id: "head_front_camera_optical_frame" faces: - x: 992 y: 448 width: 88 height: 88 eyesLocated: False leftEyeX: 0 leftEyeY: 0 rightEyeX: 0 rightEyeY: 0 position: x: 0.0 y: 0.0 z: 0.0 name: '' confidence: 0.0 gender: '' genderConfidence: 0.0 expression: '' expression_confidence: 0.0 emotion_anger_confidence: 0.0 emotion_disgust_confidence: 0.0 emotion_fear_confidence: 0.0 emotion_happiness_confidence: 0.0 emotion_neutral_confidence: 0.0 emotion_sadness_confidence: 0.0 emotion_surprise_confidence: 0.0 camera_pose: header: seq: 0 stamp: secs: 0 nsecs: 0 frame_id: '' child_frame_id: '' transform: translation: x: 0.0 y: 0.0 z: 0.0 rotation: x: 0.0 y: 0.0 z: 0.0 w: 0.0 ---