in src/k4a_ros_device.cpp [615:644]
k4a_result_t K4AROSDevice::getRgbPointCloudInRgbFrame(const k4a::capture& capture,
sensor_msgs::PointCloud2Ptr& point_cloud)
{
k4a::image k4a_depth_frame = capture.get_depth_image();
if (!k4a_depth_frame)
{
ROS_ERROR("Cannot render RGB point cloud: no depth frame");
return K4A_RESULT_FAILED;
}
k4a::image k4a_bgra_frame = capture.get_color_image();
if (!k4a_bgra_frame)
{
ROS_ERROR("Cannot render RGB point cloud: no BGRA frame");
return K4A_RESULT_FAILED;
}
// transform depth image into color camera geometry
calibration_data_.k4a_transformation_.depth_image_to_color_camera(k4a_depth_frame,
&calibration_data_.transformed_depth_image_);
// Tranform depth image to point cloud (note that this is now from the perspective of the color camera)
calibration_data_.k4a_transformation_.depth_image_to_point_cloud(
calibration_data_.transformed_depth_image_, K4A_CALIBRATION_TYPE_COLOR, &calibration_data_.point_cloud_image_);
point_cloud->header.frame_id = calibration_data_.tf_prefix_ + calibration_data_.rgb_camera_frame_;
point_cloud->header.stamp = timestampToROS(k4a_depth_frame.get_device_timestamp());
return fillColorPointCloud(calibration_data_.point_cloud_image_, k4a_bgra_frame, point_cloud);
}