Skip to content
This repository was archived by the owner on Jul 26, 2024. It is now read-only.

Commit 9f77d19

Browse files
committed
matched meta-data to the message's memory layout
1 parent f18910e commit 9f77d19

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/k4a_ros_device.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,9 @@ k4a_result_t K4AROSDevice::getPointCloud(const k4a::capture& capture, sensor_msg
666666
k4a_result_t K4AROSDevice::fillColorPointCloud(const k4a::image& pointcloud_image, const k4a::image& color_image,
667667
sensor_msgs::PointCloud2Ptr& point_cloud)
668668
{
669-
point_cloud->height = pointcloud_image.get_height_pixels();
670-
point_cloud->width = pointcloud_image.get_width_pixels();
669+
// Flip height and width to match expected memory layout
670+
point_cloud->height = pointcloud_image.get_width_pixels();
671+
point_cloud->width = pointcloud_image.get_height_pixels();
671672
point_cloud->is_dense = false;
672673
point_cloud->is_bigendian = false;
673674

@@ -693,8 +694,9 @@ k4a_result_t K4AROSDevice::fillColorPointCloud(const k4a::image& pointcloud_imag
693694
pcd_modifier.resize(point_count);
694695

695696
// Restore actual dimensions as pcd_modifier.resize(n) sets the cloud size to n x 1
696-
point_cloud->height = pointcloud_image.get_height_pixels();
697-
point_cloud->width = pointcloud_image.get_width_pixels();
697+
point_cloud->height = pointcloud_image.get_width_pixels();
698+
point_cloud->width = pointcloud_image.get_height_pixels();
699+
point_cloud->row_step = pointcloud_image.get_height_pixels() * point_cloud->point_step;
698700

699701
const int16_t* point_cloud_buffer = reinterpret_cast<const int16_t*>(pointcloud_image.get_buffer());
700702
const uint8_t* color_buffer = color_image.get_buffer();
@@ -728,8 +730,9 @@ k4a_result_t K4AROSDevice::fillColorPointCloud(const k4a::image& pointcloud_imag
728730

729731
k4a_result_t K4AROSDevice::fillPointCloud(const k4a::image& pointcloud_image, sensor_msgs::PointCloud2Ptr& point_cloud)
730732
{
731-
point_cloud->height = pointcloud_image.get_height_pixels();
732-
point_cloud->width = pointcloud_image.get_width_pixels();
733+
// Flip height and width to match expected memory layout
734+
point_cloud->height = pointcloud_image.get_width_pixels();
735+
point_cloud->width = pointcloud_image.get_height_pixels();
733736
point_cloud->is_dense = false;
734737
point_cloud->is_bigendian = false;
735738

@@ -745,8 +748,9 @@ k4a_result_t K4AROSDevice::fillPointCloud(const k4a::image& pointcloud_image, se
745748
pcd_modifier.resize(point_count);
746749

747750
// Restore actual dimensions as pcd_modifier.resize(n) sets the cloud size to n x 1
748-
point_cloud->height = pointcloud_image.get_height_pixels();
749-
point_cloud->width = pointcloud_image.get_width_pixels();
751+
point_cloud->height = pointcloud_image.get_width_pixels();
752+
point_cloud->width = pointcloud_image.get_height_pixels();
753+
point_cloud->row_step = pointcloud_image.get_height_pixels() * point_cloud->point_step;
750754

751755
const int16_t* point_cloud_buffer = reinterpret_cast<const int16_t*>(pointcloud_image.get_buffer());
752756

0 commit comments

Comments
 (0)