Skip to content

Commit 5a77462

Browse files
authored
Merge branch 'main' into receptionist-look-at-person
2 parents e0a8fbf + 62c5f74 commit 5a77462

File tree

93 files changed

+2604
-916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2604
-916
lines changed

common/helpers/colour_estimation/README.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

common/helpers/colour_estimation/doc/EXAMPLE.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

common/helpers/colour_estimation/doc/PREREQUISITES.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

common/helpers/colour_estimation/doc/USAGE.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

common/helpers/colour_estimation/src/colour_estimation/__init__.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

common/helpers/colour_estimation/src/colour_estimation/rgb.py

Lines changed: 0 additions & 68 deletions
This file was deleted.

common/helpers/cv2_pcl/src/cv2_pcl/__init__.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import cv2
55
from cv2_img import cv2_img_to_msg
66

7+
from typing import Tuple, Union
8+
79
Mat = np.ndarray
810

911
def pcl_to_img_msg(pcl: PointCloud2) -> Mat:
@@ -17,14 +19,19 @@ def pcl_to_img_msg(pcl: PointCloud2) -> Mat:
1719

1820

1921

20-
def pcl_to_cv2(pcl: PointCloud2) -> Mat:
22+
def pcl_to_cv2(
23+
pcl: PointCloud2, height: Union[int, None] = None, width: Union[int, None] = None
24+
) -> Mat:
2125
"""
2226
Convert a given PointCloud2 message to a cv2 image
2327
"""
2428

29+
height = height or pcl.height
30+
width = width or pcl.width
31+
2532
# Extract rgb image from pointcloud
2633
frame = np.fromstring(pcl.data, dtype=np.uint8)
27-
frame = frame.reshape(pcl.height, pcl.width, 32)
34+
frame = frame.reshape(height, width, -1)
2835
frame = frame[:, :, 16:19]
2936

3037
# Ensure array is contiguous
@@ -33,16 +40,25 @@ def pcl_to_cv2(pcl: PointCloud2) -> Mat:
3340
return frame
3441

3542

36-
def seg_to_centroid(pcl: PointCloud2, xyseg: np.ndarray) -> np.ndarray:
43+
def seg_to_centroid(
44+
pcl: PointCloud2,
45+
xyseg: np.ndarray,
46+
height: Union[int, None] = None,
47+
width: Union[int, None] = None,
48+
) -> np.ndarray:
3749
"""
3850
Computes the centroid of a given segment in a pointcloud
3951
"""
4052

53+
height = height or pcl.height
54+
width = width or pcl.width
55+
4156
# Convert xyseg to contours
4257
contours = xyseg.reshape(-1, 2)
4358

4459
# cv2 image
45-
cv_im = pcl_to_cv2(pcl)
60+
cv_im = pcl_to_cv2(pcl, height, width)
61+
4662
# Compute mask from contours
4763
mask = np.zeros(shape=cv_im.shape[:2])
4864
cv2.fillPoly(mask, pts=[contours], color=(255, 255, 255))
@@ -55,23 +71,35 @@ def seg_to_centroid(pcl: PointCloud2, xyseg: np.ndarray) -> np.ndarray:
5571

5672
# Unpack pointcloud into xyz array
5773
pcl_xyz = rnp.point_cloud2.pointcloud2_to_xyz_array(pcl, remove_nans=False)
74+
pcl_xyz = pcl_xyz.reshape(height, width, 3)
5875

5976
# Extract points of interest
6077
xyz_points = [pcl_xyz[x][y] for x, y in indices]
6178

6279
return np.nanmean(xyz_points, axis=0)
6380

6481

65-
def bb_to_centroid(pcl: PointCloud2, x: int, y: int, w: int, h: int) -> np.ndarray:
82+
def bb_to_centroid(
83+
pcl: PointCloud2,
84+
x: int,
85+
y: int,
86+
w: int,
87+
h: int,
88+
height: Union[int, None] = None,
89+
width: Union[int, None] = None,
90+
) -> np.ndarray:
6691
"""
6792
Computes the centroid of a given bounding box in a pointcloud
6893
"""
6994

95+
height = height or pcl.height
96+
width = width or pcl.width
97+
7098
# Convert xywh to bounding box coordinates.
7199
x1, y1, x2, y2 = x, y, x + w, y + h
72100

73101
# cv2 image
74-
frame = pcl_to_cv2(pcl)
102+
frame = pcl_to_cv2(pcl, height, width)
75103
# Compute mask from bounding box
76104
mask = np.zeros(shape=frame.shape[:2])
77105
mask[y1:y2, x1:x2] = 255 # bounding box dimensions
@@ -83,6 +111,7 @@ def bb_to_centroid(pcl: PointCloud2, x: int, y: int, w: int, h: int) -> np.ndarr
83111

84112
# Unpack pointcloud into xyz array
85113
pcl_xyz = rnp.point_cloud2.pointcloud2_to_xyz_array(pcl, remove_nans=False)
114+
pcl_xyz = pcl_xyz.reshape(height, width, 3)
86115

87116
# Extract points of interest
88117
xyz_points = [pcl_xyz[x][y] for x, y in indices]

common/helpers/colour_estimation/CMakeLists.txt renamed to common/helpers/navigation_helpers/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
cmake_minimum_required(VERSION 3.0.2)
2-
project(colour_estimation)
2+
project(navigation_helpers)
33

44
## Compile as C++11, supported in ROS Kinetic and newer
55
# add_compile_options(-std=c++11)
66

77
## Find catkin macros and libraries
88
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
99
## is used, also find other catkin packages
10-
find_package(catkin REQUIRED)
10+
find_package(catkin REQUIRED geometry_msgs)
1111

1212
## System dependencies are found with CMake's conventions
1313
# find_package(Boost REQUIRED COMPONENTS system)
@@ -100,7 +100,7 @@ catkin_python_setup()
100100
## DEPENDS: system dependencies of this project that dependent projects also need
101101
catkin_package(
102102
# INCLUDE_DIRS include
103-
# LIBRARIES colour_estimation
103+
# LIBRARIES navigation_helpers
104104
# CATKIN_DEPENDS other_catkin_pkg
105105
# DEPENDS system_lib
106106
)
@@ -118,7 +118,7 @@ include_directories(
118118

119119
## Declare a C++ library
120120
# add_library(${PROJECT_NAME}
121-
# src/${PROJECT_NAME}/colour_estimation.cpp
121+
# src/${PROJECT_NAME}/navigation_helpers.cpp
122122
# )
123123

124124
## Add cmake target dependencies of the library
@@ -129,7 +129,7 @@ include_directories(
129129
## Declare a C++ executable
130130
## With catkin_make all packages are built within a single CMake context
131131
## The recommended prefix ensures that target names across packages don't collide
132-
# add_executable(${PROJECT_NAME}_node src/colour_estimation_node.cpp)
132+
# add_executable(${PROJECT_NAME}_node src/navigation_helpers_node.cpp)
133133

134134
## Rename C++ executable without prefix
135135
## The above recommended prefix causes long target names, the following renames the
@@ -193,7 +193,7 @@ include_directories(
193193
#############
194194

195195
## Add gtest based cpp test target and link libraries
196-
# catkin_add_gtest(${PROJECT_NAME}-test test/test_colour_estimation.cpp)
196+
# catkin_add_gtest(${PROJECT_NAME}-test test/test_navigation_helpers.cpp)
197197
# if(TARGET ${PROJECT_NAME}-test)
198198
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
199199
# endif()

common/helpers/colour_estimation/package.xml renamed to common/helpers/navigation_helpers/package.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<?xml version="1.0"?>
22
<package format="2">
3-
<name>colour_estimation</name>
3+
<name>navigation_helpers</name>
44
<version>0.0.0</version>
5-
<description>Python utilities for estimating the name of given colours.</description>
5+
<description>The navigation_helpers package</description>
66

77
<!-- One maintainer tag required, multiple allowed, one person per tag -->
88
<!-- Example: -->
99
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
10-
<maintainer email="me@insrt.uk">Paul Makles</maintainer>
10+
<maintainer email="jared.swift@kcl.ac.uk">Jared Swift</maintainer>
1111

1212

1313
<!-- One license tag required, multiple allowed, one license per tag -->
1414
<!-- Commonly used license strings: -->
1515
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
16-
<license>MIT</license>
16+
<license>TODO</license>
1717

1818

1919
<!-- Url tags are optional, but multiple are allowed, one per tag -->
2020
<!-- Optional attribute type can be: website, bugtracker, or repository -->
2121
<!-- Example: -->
22-
<!-- <url type="website">http://wiki.ros.org/colour_estimation</url> -->
22+
<!-- <url type="website">http://wiki.ros.org/navigation_helpers</url> -->
2323

2424

2525
<!-- Author tags are optional, multiple are allowed, one per tag -->

common/helpers/colour_estimation/setup.py renamed to common/helpers/navigation_helpers/setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
from catkin_pkg.python_setup import generate_distutils_setup
55

66
setup_args = generate_distutils_setup(
7-
packages=['colour_estimation'],
8-
package_dir={'': 'src'}
7+
packages=["navigation_helpers"], package_dir={"": "src"}
98
)
109

1110
setup(**setup_args)

0 commit comments

Comments
 (0)