2015-07-02 38 views
0

我工作的结构与运动。我认为,从运动结构来看,人们会碰到MultiView几何书。这本书非常好,但我在这本书中发现了一些令人困惑的数据。在下面的代码中,有一个叫做填充点云的函数,它有两个参数pointcloud和pointcloud_RGB。我在点云三维点类型值,但我没有找到有关pointcloud_RGB在这本书中任何东西,它突然出现在这个功能,这是用来填补VEC3d rgbv。有人能帮助谁遇到这本书。结构从运动展台

void PopulatePCLPointCloud(const vector<cv::Point3d>& pointcloud, 
    const std::vector<cv::Vec3b>& pointcloud_RGB = std::vector<cv::Vec3b>() 
) 

{ 
cout<<"Creating point cloud..."; 
cloud.reset(new pcl::PointCloud<pcl::PointXYZRGB>); 

for (unsigned int i=0; i<pointcloud.size(); i++) { 
// get the RGB color value for the point 
     cv::Vec3b rgbv(255,255,255); 

if (i < pointcloud_RGB.size()) { 
rgbv = pointcloud_RGB[i]; 
} 

     // check for erroneous coordinates (NaN, Inf, etc.) 
       if (pointcloud[i].x != pointcloud[i].x || 
         pointcloud[i].y != pointcloud[i].y || 
         pointcloud[i].z != pointcloud[i].z || 
#ifndef WIN32 
         isnan(pointcloud[i].x) || 
         isnan(pointcloud[i].y) || 
         isnan(pointcloud[i].z) || 
#else 
         _isnan(pointcloud[i].x) || 
         _isnan(pointcloud[i].y) || 
         _isnan(pointcloud[i].z) || 
         false 
         ) 
       { 
         continue; 
       } 
pcl::PointXYZRGB pclp; 
pclp.x = pointcloud[i].x; 
pclp.y = pointcloud[i].y; 
pclp.z = pointcloud[i].z; 
// RGB color, needs to be represented as an integer 
uint32_t rgb = ((uint32_t)rgbv[2] << 16 | (uint32_t)rgbv[1] << 8 | 
(uint32_t)rgbv[0]); 
pclp.rgb = *reinterpret_cast<float*>(&rgb); 
cloud->push_back(pclp); 
} 
cloud->width = (uint32_t) cloud->points.size(); // number of points 
cloud->height = 1; // a list of points, one row of data 

//Create visualizer 

pcl::visualization::CloudViewer viewer ("Simple Cloud Viewer"); 
viewer.showCloud (cloud); 

       cv::waitKey(0); 
       return; 
} 
+0

字面上,当我搜索“pcl :: PointXYZRGB”时,[第一链接](http://docs.pointclouds.org/1.7.0/structpcl_1_1_point_x_y_z_r_g_b.html)“ – CoryKramer

+0

非常感谢您的重播。我已经点云型三维点,并在该函数也用型vec3d的pointcloud_RGB,所以我问还有什么在pointcloud_RGB,因为他们没有说什么,所以我很困惑。对不起如果我不理解你(我不擅长PCL)。 – Raj

回答

0

我相信这是从MasteringOpenCV代码片段 - 第4章我已经检查了整个项目,看来这是某种在

const std::vector<cv::Vec3b>& pointcloud_RGB = std::vector<cv::Vec3b>() 

,并定义一个错误pointcloud_RGB的除此之外没有赋值;

rgbv = pointcloud_RGB[i]; 

,这是

if (i < pointcloud_RGB.size()) 

程序的情况下决不会去到这一点,如果因为pointcloud_RGB是空的,因此不能比我大。这就是为什么它应该运行没有任何问题。

真正的点云是pcl::PointXYZRGB pclp;,它是这里填写与XYZ坐标+ RGB值;

pcl::PointXYZRGB pclp; 
pclp.x = pointcloud[i].x; 
pclp.y = pointcloud[i].y; 
pclp.z = pointcloud[i].z; 
// RGB color, needs to be represented as an integer 
uint32_t rgb = ((uint32_t)rgbv[2] << 16 | (uint32_t)rgbv[1] << 8 | 
(uint32_t)rgbv[0]); 

当然总有可能向作者发送电子邮件并要求澄清。

+0

非常感谢您的评论。我正在获得3de点云的7.0e008重新投影误差,你认为它是非常巨大的? – Raj

+0

这似乎挺大的。你可以检查你的点云;毕竟,你应该获得感兴趣对象的3D模型。 – karttinen

+0

非常感谢您的重播,我的可视化点云很奇怪。你能发送你的电子邮件吗?我想与你讨论更多。 – Raj