Skip to content
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
44 changes: 44 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 2.8.3)
project(face_classification)

find_package(catkin REQUIRED COMPONENTS
rospy
std_msgs
sensor_msgs
message_generation
cv_bridge
)

## Generate messages in the 'msg' folder
add_message_files(
DIRECTORY
ros/msg
FILES
FaceClassification.msg
FaceClassificationArray.msg
)

add_service_files(
DIRECTORY
ros/srv
FILES
FaceClassificationBuffered.srv
FaceClassificationContinuous.srv
)

catkin_python_setup()

generate_messages(
DEPENDENCIES
std_msgs
sensor_msgs
)

catkin_package(
CATKIN_DEPENDS
rospy
std_msgs
sensor_msgs
message_runtime
cv_bridge
)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ With a few steps one can get its own face classification and detection running.
* Run the train_gender_classification.py file
> python3 train_gender_classifier.py

## ROS USAGE

* In order to use this as a ROS package, consult [this](ros/doc/README.md).
32 changes: 32 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<package>
<name>face_classification</name>
<version>1.0.0</version>
<description>
Package for face detection and gender and emotion classification
</description>

<license>GPLv3</license>

<author email="miguel.oliveira.silva@tecnico.ulisboa.pt">Miguel Silva</author>
<maintainer email="miguel.oliveira.silva@tecnico.ulisboa.pt">Miguel Silva</maintainer>

<buildtool_depend>catkin</buildtool_depend>

<build_depend>rospy</build_depend>
<build_depend>rospkg</build_depend>
<build_depend>message_generation</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>cv_bridge</build_depend>

<run_depend>rospy</run_depend>
<run_depend>rospkg</run_depend>
<run_depend>message_runtime</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>cv_bridge</run_depend>

<test_depend>roslaunch</test_depend>

</package>
38 changes: 38 additions & 0 deletions repository.debs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
if [ $# == 0 ]; then
INSTALL_PACKAGES=true
else
INSTALL_PACKAGES=$1
fi

# your ROS distribution
DISTRO=kinetic

# create list of packages to install
packagelist=(
python-pandas
)

pippackagelist=(
keras==2.1.6 #Keras is a high-level neural networks API to run top of TensorFlow, CNTK, or Theano
)


### Install debian packages listed in array above
if [ $INSTALL_PACKAGES != false ]; then
sudo apt-get install -y ${packagelist[@]}
sudo pip2 install ${pippackagelist[@]}
fi

### install further repositories if repository.rosinstall file exists
if [ -f repository.rosinstall ]; then
rosinstall .. /opt/ros/${DISTRO} repository.rosinstall

### install dependencies of the previously cloned repositories
dependent_repositories=$(grep -r "local-name:" repository.rosinstall | cut -d":" -f 2 | sed -r 's/\s+//g')
for i in $dependent_repositories
do
cd ../$i
if [ -f repository.debs ]; then ./repository.debs $INSTALL_PACKAGES ; fi
done
fi
19 changes: 19 additions & 0 deletions ros/doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ROS USAGE

## Schema

This is the node schema, representing the messages that it subscribes and publishes, the parameters and the service that it publishes.

![alt tag](pipeline.png)

## Buffered Mode

This mode collects a buffer of images and it uses a filter in order to ignore wrong observations.

This node can works in buffer mode if someone publishes at the service face_classification_buffered with the size of the buffer that it's desired.

## Continuous Mode

This mode is running the face classification in real time.

This node can works in continuous mode if someone publishes at the service face_classification_continuous with True.
Binary file added ros/doc/pipeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ros/doc/pipeline.xml
Binary file not shown.
19 changes: 19 additions & 0 deletions ros/launch/face_classification_simple.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<launch>

<arg name="camera_name" default="head_camera"/>

<node pkg="face_classification" type="face_classification_node" name="face_classification_node" respawn="false" output="screen">
<param name="show_image" type="bool" value="true" />
<param name="image_topic" value="$(arg camera_name)/rgb/image_raw/compressed" />
<param name="camera_delay" type="double" value="0.5" />
<param name="compressed" type="bool" value="true" />
<param name="image_acquisition_rate" type="double" value="4" />
<param name="node_rate" type="double" value="60" />
<param name="gender_offset_x" value="30"/>
<param name="gender_offset_y" value="60"/>
<param name="emotion_offset_x" value="20"/>
<param name="emotion_offset_y" value="40"/>
</node>

</launch>
33 changes: 33 additions & 0 deletions ros/launch/face_classification_test.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<launch>

<arg name="camera_type_is_depth" default="false"/>
<arg name="camera_name" default="camera"/>

<group if="$(arg camera_type_is_depth)" >
<include file="$(find openni2_launch)/launch/openni2.launch" >
<arg name="camera" value="$(arg camera_name)"/>
<arg name="publish_tf" value="false"/>
</include>
</group>

<group unless="$(arg camera_type_is_depth)" >
<node ns="$(arg camera_name)" name="rgb" pkg="usb_cam" type="usb_cam_node" output="screen" >
<param name="pixel_format" value="yuyv" />
</node>
</group>

<node pkg="face_classification" type="face_classification_node" name="face_classification_node" respawn="false" output="screen">
<param name="show_image" type="bool" value="true" />
<param name="image_topic" value="$(arg camera_name)/rgb/image_raw/compressed" />
<param name="camera_delay" type="double" value="0.5" />
<param name="compressed" type="bool" value="true" />
<param name="image_acquisition_rate" type="double" value="4" />
<param name="node_rate" type="double" value="60" />
<param name="gender_offset_x" value="30"/>
<param name="gender_offset_y" value="60"/>
<param name="emotion_offset_x" value="20"/>
<param name="emotion_offset_y" value="40"/>
</node>

</launch>
5 changes: 5 additions & 0 deletions ros/msg/FaceClassification.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
uint32 id
string name
string emotion
string gender
sensor_msgs/RegionOfInterest bounding_box
3 changes: 3 additions & 0 deletions ros/msg/FaceClassificationArray.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
std_msgs/Header header
std_msgs/Header image_input_header
FaceClassification[] faces
6 changes: 6 additions & 0 deletions ros/scripts/face_classification_node
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python

import face_classification_ros.face_classification_node

if __name__ == '__main__':
face_classification_ros.face_classification_node.main()
Empty file.
Loading