Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/people tracking #55

Draft
wants to merge 102 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
b42ea9e
add first setup
reinzor Aug 8, 2023
f9b27d6
add dependency on tracker for installation
reinzor Aug 8, 2023
eabbae6
made people tracker in cpp to get a continuous stream of images
reinzor Aug 22, 2023
d16a6a0
remove script
reinzor Sep 2, 2023
098c62c
add warning
reinzor Sep 2, 2023
920a0ed
remove python trial
reinzor Sep 2, 2023
38bdc55
add namespace
reinzor Sep 2, 2023
5736455
resolve namespace
reinzor Sep 2, 2023
034b202
Fix topic ns
PetervDooren Sep 2, 2023
b0a27a3
publish markers
PetervDooren Sep 2, 2023
38583b9
fix typo
PetervDooren Sep 2, 2023
506beb7
fix indexing error
PetervDooren Sep 2, 2023
d04256a
add comments
PetervDooren Sep 2, 2023
f220f28
add ros listener
KenH2 Oct 31, 2023
4a9334c
person
KenH2 Oct 31, 2023
27dfd04
make yolo.py executable
PetervDooren Oct 31, 2023
2a9520f
Added test capability for laptop webcam
KenH2 Nov 2, 2023
ffe1fe0
New listener, with no buffer
KenH2 Nov 5, 2023
352dca3
Custom MSG test
KenH2 Nov 5, 2023
083453d
Add Custom MSGS for future communication
KenH2 Nov 5, 2023
e36be3f
added Node person_detection
KenH2 Nov 5, 2023
962c22d
added Node HoC
KenH2 Nov 7, 2023
c8ab26f
added Node people_tracker
KenH2 Nov 7, 2023
06f2d84
crop image into separate persons
KenH2 Nov 7, 2023
6930dbf
cleaned separation function
KenH2 Nov 7, 2023
02b99e4
Added msg person_detections
KenH2 Nov 7, 2023
96afda4
Fixed time issue msg
KenH2 Nov 7, 2023
1d84193
Implementation HoC node
KenH2 Nov 7, 2023
913461d
Cleaned HoC node
KenH2 Nov 7, 2023
2cbc835
Implementation People_tracker node
KenH2 Nov 7, 2023
6fc2803
Fix UKF class
KenH2 Nov 9, 2023
49d3cc5
Pose Detection Test
KenH2 Nov 9, 2023
c29b4ea
Added z, y to msgs
KenH2 Nov 12, 2023
d6f3e29
Add history check to tracker
KenH2 Nov 12, 2023
b326cba
Add y-tracking
KenH2 Nov 12, 2023
a1b54ae
Add ToDo in callback_HoC
KenH2 Nov 12, 2023
11e849d
Clean up UKFclasss
KenH2 Nov 12, 2023
db35841
Launch file with switch laptop & HERO
KenH2 Nov 12, 2023
0f185bc
Clean-up code
KenH2 Nov 12, 2023
763310e
Start face-detection
KenH2 Nov 14, 2023
16f5aff
Face detection on all received images
KenH2 Nov 14, 2023
04af780
Face-detection on recent data only
KenH2 Nov 14, 2023
d1d7c2f
Clearer definition start target
KenH2 Nov 14, 2023
c810459
Reset Service for HoC
KenH2 Nov 14, 2023
42a73b8
Reset Service for Face & Detection
KenH2 Nov 14, 2023
a9dca1d
Update to correct webcam msg
KenH2 Nov 14, 2023
21205ad
seperate data_association function + Prep Tracker update
KenH2 Nov 16, 2023
fbe04b9
Work on re-identifier
KenH2 Nov 16, 2023
bc93b56
Depth service
KenH2 Nov 19, 2023
65781e1
Z_position implementation
KenH2 Nov 19, 2023
1dbcf6c
clean-up depth node
KenH2 Nov 19, 2023
5060b48
start with rewritting tracking
KenH2 Nov 19, 2023
e61bc4d
Redone data stored people_tracker
KenH2 Nov 20, 2023
80c9cf3
Small change HoC compare people tracker
KenH2 Nov 20, 2023
109bf2a
Fix HoC Compare people tracking
KenH2 Nov 20, 2023
1c65220
Tracker Update start
KenH2 Nov 23, 2023
622e602
Turn on/off depth
KenH2 Nov 23, 2023
6be570d
Tracker Update - integration in loop
KenH2 Nov 23, 2023
8019976
Small fix tracker logic
KenH2 Nov 27, 2023
347977b
depth to median
KenH2 Nov 27, 2023
d3ff7d7
Start Data Logger
KenH2 Dec 3, 2023
ea8e2ef
Data Logger w. on/off
KenH2 Dec 3, 2023
d07a9a4
Fix tracker
KenH2 Dec 7, 2023
1590375
Clean Up
KenH2 Dec 7, 2023
68c1b2f
Tracking w. velocity
KenH2 Dec 10, 2023
bfda184
( ColourTarget.msg) Add missing newline at EOF
MatthijsBurgh Dec 11, 2023
a614afa
(CMakeLists.txt) Add missing newline at EOF
MatthijsBurgh Dec 11, 2023
4324bdc
(detect_person.msg) Add missing newline at EOF
MatthijsBurgh Dec 11, 2023
cf2fbc8
(test_script+webcam.launch) At missing newline at EOF
MatthijsBurgh Dec 11, 2023
6d897f9
(people_tracker.cpp) At missing newline at EOF
MatthijsBurgh Dec 11, 2023
7ab11e1
(people_tracking.launch) Add missing newline at EOF
MatthijsBurgh Dec 11, 2023
231d9d0
(tracking) add missing dep on rgbd and rgbd_image_buffer
MatthijsBurgh Dec 11, 2023
254039b
Added y_dependency distance
KenH2 Dec 12, 2023
785b903
Merge remote-tracking branch 'origin/master' into feature/people_trac…
MatthijsBurgh Dec 12, 2023
8e9b1b3
(tracking) cleanup
MatthijsBurgh Dec 12, 2023
fd0e6bc
value change depth_camera
KenH2 Dec 14, 2023
65557d8
saving change
KenH2 Dec 14, 2023
4a6bcc1
depth camera udpate
KenH2 Dec 14, 2023
e4ae7e0
depth camera update
KenH2 Dec 14, 2023
724254e
depth camera update 2
KenH2 Dec 14, 2023
e376e99
depth camera update 2
KenH2 Dec 14, 2023
e9eee44
depth camera update 3
KenH2 Dec 14, 2023
5f9e6f3
depth camera update 4
KenH2 Dec 14, 2023
1014c3e
depth image fix
KenH2 Dec 14, 2023
8168c44
depth image fix 2
KenH2 Dec 14, 2023
9f63c61
save data fix
KenH2 Dec 14, 2023
4340f42
save data fix 2
KenH2 Dec 14, 2023
e379323
save data fix 3
KenH2 Dec 14, 2023
48ffbf3
colour update
KenH2 Dec 14, 2023
fc8ad75
z_pos update
KenH2 Dec 14, 2023
d2ddb5a
z_pos update 2
KenH2 Dec 14, 2023
4421ae8
z_pos update 2
KenH2 Dec 14, 2023
e34b0bc
depth processing increase speed
KenH2 Dec 19, 2023
32c211f
print movement
KenH2 Dec 19, 2023
ab8a9d4
exception case added
KenH2 Dec 19, 2023
7858410
clean up
KenH2 Dec 19, 2023
e9c22e1
png images
KenH2 Dec 19, 2023
89e308b
value update
KenH2 Dec 20, 2023
6452b3a
Clean-up Facial Recognition node
KenH2 Jan 9, 2024
848a070
Clean-up HoC node
KenH2 Jan 9, 2024
9f66638
Clean-up Person Detection node
KenH2 Jan 9, 2024
749f43a
Clean-up Person Tracker node
KenH2 Jan 9, 2024
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
1 change: 1 addition & 0 deletions people_recognition/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<exec_depend>people_recognition_2d</exec_depend>
<exec_depend>people_recognition_3d</exec_depend>
<exec_depend>people_recognition_msgs</exec_depend>
<exec_depend>people_tracking</exec_depend>

<export>
<metapackage/>
Expand Down
55 changes: 55 additions & 0 deletions people_tracking/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.0.2)
project(people_tracking)

find_package(catkin REQUIRED COMPONENTS
message_generation
people_recognition_msgs
rgbd
rgbd_image_buffer
roscpp
sensor_msgs
visualization_msgs
)

catkin_python_setup()

add_message_files(
FILES
FaceTarget.msg
ColourTarget.msg
DetectPerson.msg
DetectedPerson.msg
)

add_service_files(
FILES
Depth.srv
)

generate_messages(
DEPENDENCIES
sensor_msgs
)

catkin_package(
CATKIN_DEPENDS message_runtime sensor_msgs
)

include_directories(
# include
SYSTEM
${catkin_INCLUDE_DIRS}
)

add_executable(people_tracker test/experiments/people_tracker.cpp)
target_link_libraries(people_tracker ${catkin_LIBRARIES})

install(
TARGETS people_tracker
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

if (CATKIN_ENABLE_TESTING)
find_package(catkin_lint_cmake REQUIRED)
catkin_add_catkin_lint_test(-W2)
endif()
75 changes: 75 additions & 0 deletions people_tracking/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# People Tracking
Node for people tracking. #TODO this README has been copied from people_detection_2d. check if it is still up to date

## Custom dependencies
- [image_recognition_openpose](https://github.com/tue-robotics/image_recognition/tree/master/image_recognition_openpose)
- [image_recognition_openface](https://github.com/tue-robotics/image_recognition/tree/master/image_recognition_openpose)
- [image_recognition_keras](https://github.com/tue-robotics/image_recognition/tree/master/image_recognition_keras)
- [image_recognition_color_extractor](https://github.com/tue-robotics/image_recognition/tree/master/image_recognition_color_extractor)
- [image_recognition_msgs](https://github.com/tue-robotics/image_recognition/tree/master/image_recognition_msgs)

# How To
### Start the dependent nodes
The relative namespaces of the dependent nodes must be as follows so that their advertised services are the same as the values of the [parameters](#parameters) of people recognition node:
```
rosrun image_recognition_openpose openpose_node __ns:=openpose

rosrun image_recognition_openface face_recognition_node __ns:=face_recognition

rosrun image_recognition_keras face_properties_node __ns:=face_recognition

rosrun image_recognition_color_extractor color_extractor_node
```

### Run the people recognition node and service
```
rosrun people_recognition_2d people_recognition_2d_node
```
This will create a service `detect_people` of type `RecognizePeople2D` and which requires a color image
(`sensor_msgs/Image`) as input in the service request and returns `people` in the response which is an array of
custom message type `people_recognition_msgs/Person2D`

### Parameters
| Name | Default Value |
|------------------------------|---------------------------------------|
| `~openpose_srv_name` | `openpose/recognize` |
| `~openface_srv_name` | `face_recognition/recognize` |
| `~keras_srv_name` | `face_recognition/get_face_properties`|
| `~color_extractor_srv_name` | `extract_color` |

### Message definition of Person2D
```
string name
uint8 age
uint8 gender
float64 gender_confidence
string posture
string emotion
string[] shirt_colors
image_recognition_msgs/Recognition[] body_parts
image_recognition_msgs/CategoricalDistribution categorical_distribution
image_recognition_msgs/CategoryProbability[] probabilities
string label
float32 probability
float32 unknown_probability
sensor_msgs/RegionOfInterest roi
uint32 x_offset
uint32 y_offset
uint32 height
uint32 width
bool do_rectify
uint32 group_id
```
### Test service
```
roscd people_recognition_2d/scripts
./people_recognition_2d_srv_test image ../test/assets/example.jpg
```

# Work Flow
The node first calls the recognize services of the openpose and openface nodes. ROIs of faces are extracted from
the recognitions returned by OpenPose and are associated with the recognitions returned by OpenFace through the
face ROIs to create a `Person2D` object. The ROIs of body parts returned by OpenPose are associated with each
`Person2D` object. Face images are sent to the Keras node and properties (age and gender) are extracted and
assoicated with each 'Person2D' object. The ROIs of the faces are shifted vertically to approximate the ROIs of
the shirts. These are sent to the color extractor to get the dominant colors.
8 changes: 8 additions & 0 deletions people_tracking/example/example.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<launch>
<group ns="hero">
<node pkg="people_tracking" type="people_tracker" name="people_tracker">
<rosparam command="load" file="$(find people_tracking)/example/example_config.yaml"/>
</node>
</group>
</launch>
4 changes: 4 additions & 0 deletions people_tracking/example/example_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
frame_id: base_link
rgbd_topic: head_rgbd_sensor/rgbd
rate: 10
people_recognition_service: /hero/people_recognition/detect_people
8 changes: 8 additions & 0 deletions people_tracking/msg/ColourTarget.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
float64 time
int32 nr_batch
int32 nr_persons

float32[] colour_vectors
int32[] x_positions
int32[] y_positions
int32[] z_positions
2 changes: 2 additions & 0 deletions people_tracking/msg/DetectPerson.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
string name
int32 age
9 changes: 9 additions & 0 deletions people_tracking/msg/DetectedPerson.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
float64 time
int32 nr_batch
int32 nr_persons

sensor_msgs/Image[] detected_persons
int32[] x_positions
int32[] y_positions
int32[] z_positions

10 changes: 10 additions & 0 deletions people_tracking/msg/FaceTarget.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
float64 time
int32 batch_nr
int32 nr_persons
int32[] x_positions
int32[] y_positions
int32[] z_positions
sensor_msgs/Image detected_person

bool[] face_detections_valid
bool[] face_detections
55 changes: 55 additions & 0 deletions people_tracking/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0"?>
<?xml-model
href="http://download.ros.org/schema/package_format3.xsd"
schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>people_tracking</name>
<version>0.0.1</version>
<description>The people_tracking package</description>

<maintainer email="[email protected]">Arpit Aggarwal</maintainer>

<license>MIT</license>

<url type="bugtracker">https://github.com/tue-robotics/people_recognition/issues</url>
<url type="repository">https://github.com/tue-robotics/people_recognition/tree/master/people_recognition_2d</url>

<author email="[email protected]">Arpit Aggarwal</author>

<buildtool_depend>catkin</buildtool_depend>

<buildtool_depend>python3-setuptools</buildtool_depend>

<depend>sensor_msgs</depend>

<build_depend>people_recognition_msgs</build_depend>
<build_depend>rgbd</build_depend>
<build_depend>rgbd_image_buffer</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>visualization_msgs</build_depend>

<build_depend>message_generation</build_depend>

<exec_depend>cv_bridge</exec_depend>
<exec_depend>image_recognition_util</exec_depend>
<exec_depend>message_runtime</exec_depend>
<exec_depend>people_recognition_msgs</exec_depend>
<exec_depend>rgbd</exec_depend>
<exec_depend>rgbd_image_buffer</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>visualization_msgs</exec_depend>

<test_depend>catkin_lint_cmake</test_depend>

<doc_depend>python3-sphinx</doc_depend>
<doc_depend>python-sphinx-autoapi-pip</doc_depend>
<doc_depend>python-sphinx-rtd-theme-pip</doc_depend>
<doc_depend>python3-yaml</doc_depend>

<export>
<rosdoc config="rosdoc.yaml" />
</export>

</package>
3 changes: 3 additions & 0 deletions people_tracking/rosdoc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- builder: sphinx
sphinx_root_dir: docs
name: Python API
11 changes: 11 additions & 0 deletions people_tracking/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python

from setuptools import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
packages=['people_tracking'],
package_dir={'': 'src'},
)

setup(**d)
55 changes: 55 additions & 0 deletions people_tracking/src/people_tracking/UKFclass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import numpy as np
from filterpy.kalman import MerweScaledSigmaPoints
from filterpy.kalman import UnscentedKalmanFilter


class UKF:
def __init__(self):
self.current_time = 0.0

dt = 0.1 # standard dt

# Create sigma points
self.points = MerweScaledSigmaPoints(6, alpha=0.1, beta=2.0, kappa=-1)

self.kf = UnscentedKalmanFilter(dim_x=6, dim_z=3, dt=dt, fx=self.fx, hx=self.hx, points=self.points)

# Initial state: [x, vx, y, vy, z, vz]
self.kf.x = np.array([1., 0, 300., 0, 1., 0])

# Initial uncertainty
self.kf.P *= 1

# Measurement noise covariance matrix
z_std = 0.2
self.kf.R = np.diag([z_std ** 2, z_std ** 2, z_std ** 2])

# Process noise covariance matrix
process_noise_stds = [3.0 ** 2, 0.1 ** 2, 3 ** 2, 0.1 ** 2, 0.1 ** 2, 0.1 ** 2]

self.kf.Q = np.diag(process_noise_stds)

def fx(self, x, dt):
""" State transition function """
F = np.array([[1, dt, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 0, 1, dt, 0, 0],
[0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 1, dt],
[0, 0, 0, 0, 0, 1]], dtype=float)
return np.dot(F, x)

def hx(self, x):
""" Measurement function [x, y, z] """
return np.array([x[0], x[2], x[4]])

def predict(self, time):
""" Predict the next state """
delta_t = time - self.current_time
self.kf.predict(dt=delta_t)
self.current_time = time

def update(self, time, z):
""" Update filter with measurements z. """
self.predict(time)
self.kf.update(z)
Loading
Loading