Author: Jordi Pages < >

Maintainer: Jordi Pages < >



(!) Please ask about problems and questions regarding this tutorial on Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Person detection (C++)

Description: ROS node using the OpenCV person detector based on HOG Adaboost cascade

Keywords: OpenCV

Tutorial Level: ADVANCED

Next Tutorial: Face Detection



This tutorial presents a ROS node that subscribes to an image topic and applies the OpenCV person detector based on an Adaboost cascade of HoG. The node publishes ROIs of the detections and a debug image showing the processed image with the ROIs likely to contain a person.


First, make sure that the tutorials are properly installed along with the TIAGo simulation, as shown in the Tutorials Installation Section.

Download person detector

In order to execute the demo first we need to download the source code of the person detector in the public simulation workspace in a console

$ cd ~/tiago_public_ws/src
$ git clone

Building the workspace

Now we need to build the workspace

cd ~/tiago_public_ws
$ catkin build


Open three consoles and in each one source the workspace

cd ~/tiago_public_ws
source ./devel/setup.bash

In the first console launch the simulation

$ roslaunch tiago_gazebo tiago_gazebo.launch public_sim:=true robot:=steel world:=tutorial_office

Note that in this simulation world there are several person models


In the second console run the person detector node as follows

$ roslaunch pal_person_detector_opencv detector.launch image:=/xtion/rgb/image_raw

In the third console we may run an image visualizer to see the person detections

$  rosrun image_view image_view image:=/person_detector/debug


Note that persons detected are stroked with a ROI. The detections are not only represented in the /person_detector/debug Image topic but also in /person_detector/detections, which contains a vector with the image ROIs of all the detected persons. In order to see the contents of the topic we may use

$  rostopic echo -n 1 /person_detector/detections

which will prompt one message of the topic that when a person is detected will look like

  seq: 34
    secs: 2646
    nsecs: 967000000
  frame_id: ''
    x: 152
    y: 100
    width: 160
    height: 320
    seq: 0
      secs: 0
      nsecs:         0
    frame_id: ''
  child_frame_id: ''
      x: 0.0
      y: 0.0
      z: 0.0
      x: 0.0
      y: 0.0
      z: 0.0
      w: 0.0

Moving around

In order to see better how the person detector performs we can open a new console and run the key_teleop node in order to move the robot around

source /opt/ros/indigo/setup.bash
rosrun key_teleop

Then, using the arrow keys of the keyboard we can make TIAGo move around the simulated world to gaze toward the different persons and see how the detector works



Wiki: Robots/TIAGo/Tutorials/PersonDetection (last edited 2017-03-15 14:50:53 by AlessandroDiFava)