in src/k4a_ros_device.cpp [583:613]
k4a_result_t K4AROSDevice::getRgbPointCloudInDepthFrame(const k4a::capture& capture,
sensor_msgs::PointCloud2Ptr& point_cloud)
{
const 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;
}
const 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 color image into the depth camera frame:
calibration_data_.k4a_transformation_.color_image_to_depth_camera(k4a_depth_frame, k4a_bgra_frame,
&calibration_data_.transformed_rgb_image_);
// Tranform depth image to point cloud
calibration_data_.k4a_transformation_.depth_image_to_point_cloud(k4a_depth_frame, K4A_CALIBRATION_TYPE_DEPTH,
&calibration_data_.point_cloud_image_);
point_cloud->header.frame_id = calibration_data_.tf_prefix_ + calibration_data_.depth_camera_frame_;
point_cloud->header.stamp = timestampToROS(k4a_depth_frame.get_device_timestamp());
return fillColorPointCloud(calibration_data_.point_cloud_image_, calibration_data_.transformed_rgb_image_,
point_cloud);
}