Author: Jordi Pages < jordi.pages@pal-robotics.com >

Maintainer: Jordi Pages < jordi.pages@pal-robotics.com >

Support: tiago-support@pal-robotics.com

Source: https://github.com/pal-robotics/tiago_tutorials.git

(!) 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.

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

person_detection_title.jpg

Purpose

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.

Pre-Requisites

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 https://github.com/pal-robotics/pal_person_detector_opencv.git

Building the workspace

Now we need to build the workspace

cd ~/tiago_public_ws
catkin build

Execution

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 end_effector:=pal-gripper world:=simple_office_with_people

Note that in this simulation world there are several person models

gazebo_person_detection.jpg

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

sudo apt update
sudo apt install ros-melodic-image-view
rosrun image_view image_view image:=/person_detector/debug

Or

rosrun rqt_image_view rqt_image_view

And choose /person_detector/debug in the scrolling menu

image_view_person_detections.jpg

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

header: 
  seq: 34
  stamp: 
    secs: 2646
    nsecs: 967000000
  frame_id: ''
detections: 
  - 
    x: 152
    y: 100
    width: 160
    height: 320
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
---

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 ./devel/setup.bash
rosrun key_teleop key_teleop.py

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

person_detection_01.jpg

person_detection_02.jpg

Wiki: Robots/TIAGo/Tutorials/PersonDetection (last edited 2023-02-24 11:05:50 by thomaspeyrucain)