wrappers/pcl/pcl-color/rs-pcl-color.cpp
//===================================================
//  PCL_Conversion
// - Function is utilized to fill a point cloud
//  object with depth and RGB data from a single
//  frame captured using the Realsense.
//=================================================== 
PCL_Conversion
Function is utilized to fill a point cloud
object with depth and RGB data from a single
frame captured using the Realsense.
PCL_Conversion Function is utilized to fill a point cloud object with depth and RGB data from a single frame captured using the Realsense .
cloud_pointer PCL_Conversion(const rs2::points& points, const rs2::video_frame& color){
    cloud_pointer cloud(new point_cloud);
    std::tuple<uint8_t, uint8_t, uint8_t> RGB_Color;
    auto sp = points.get_profile().as<rs2::video_stream_profile>();
    cloud->width  = static_cast<uint32_t>( sp.width()  );   
    cloud->height = static_cast<uint32_t>( sp.height() );
    cloud->is_dense = false;
    cloud->points.resize( points.size() );
    auto Texture_Coord = points.get_texture_coordinates();
    auto Vertex = points.get_vertices();
    for (int i = 0; i < points.size(); i++)
    {   
        ===
        ===
        cloud->points[i].x = Vertex[i].x;
        cloud->points[i].y = Vertex[i].y;
        cloud->points[i].z = Vertex[i].z;
        RGB_Color = RGB_Texture(color, Texture_Coord[i]);
        cloud->points[i].r = get<2>(RGB_Color); 
        cloud->points[i].g = get<1>(RGB_Color); 
        cloud->points[i].b = get<0>(RGB_Color); 
    }
   return cloud; 
}
cloud_pointer PCL_Conversion ( const rs2 :: points & points , const rs2 :: video_frame & color ) { cloud_pointer cloud ( new point_cloud ) ; std :: tuple < uint8_t , uint8_t , uint8_t > RGB_Color ; auto sp = points . get_profile ( ) . as < rs2 :: video_stream_profile > ( ) ; cloud -> width = static_cast < uint32_t > ( sp . width ( ) ) ; cloud -> height = static_cast < uint32_t > ( sp . height ( ) ) ; cloud -> is_dense = false ; cloud -> points . resize ( points . size ( ) ) ; auto Texture_Coord = points . get_texture_coordinates ( ) ; auto Vertex = points . get_vertices ( ) ; for ( int i = 0 ; i < points . size ( ) ; i ++ ) { cloud -> points [ i ] . x = Vertex [ i ] . x ; cloud -> points [ i ] . y = Vertex [ i ] . y ; cloud -> points [ i ] . z = Vertex [ i ] . z ; RGB_Color = RGB_Texture ( color , Texture_Coord [ i ] ) ; cloud -> points [ i ] . r = get < 2 > ( RGB_Color ) ; cloud -> points [ i ] . g = get < 1 > ( RGB_Color ) ; cloud -> points [ i ] . b = get < 0 > ( RGB_Color ) ; } return cloud ; }
PCL_Conversion
 Function is utilized to fill a point cloud
object with depth and RGB data from a single
frame captured using the Realsense.
PCL_Conversion Function is utilized to fill a point cloud object with depth and RGB data from a single frame captured using the Realsense .
// Object Declaration (Point Cloud) // Declare Tuple for RGB value Storage (<t0>, <t1>, <t2>) //================================ // PCL Cloud Object Configuration //================================ // Convert data captured from Realsense camera to Point Cloud // Iterating through all points and setting XYZ coordinates // and RGB values //=================================== // Mapping Depth Coordinates // - Depth data stored as XYZ values //=================================== // Obtain color texture for specific point // Mapping Color (BGR due to Camera Model) // Reference tuple<2> // Reference tuple<1> // Reference tuple<0> // PCL RGB Point Cloud generated