来自 Motion Visualizer 的结构 [英] Structure from Motion Visualizer

查看:69
本文介绍了来自 Motion Visualizer 的结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究 Motion 中的结构.我认为当涉及到运动的结构时,人们会遇到多视图几何这本书.这是一本非常好的书,但我在那本书中发现了一些令人困惑的数据.在下面的代码中,有一个名为 Populate point cloud 的函数,它有两个参数 pointcloud 和 pointcloud_RGB.我在pointcloud中有point3d类型值,但在那本书中我没有找到任何关于pointcloud_RGB的东西,它突然出现在这个用于填充VEC3d rgbv的函数中.有人可以帮助遇到这本书的人吗.

I am working on Structure from Motion. I think when it come to structure from motion, people would have came across MultiView Geometry book. It is a very good book but I found something confusing data in that book. In the below following code, there is function called Populate point cloud, which has two parameter pointcloud and pointcloud_RGB. I have point3d type values in pointcloud but I didn't find anything about pointcloud_RGB in that book and it suddenly appears in this function, which is used to fill the VEC3d rgbv. Can some one please help who came across this book.

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; 
}

推荐答案

我相信这是 MasteringOpenCV - 第 4 章的代码片段.我检查了整个项目,似乎这是某种错误 pointcloud_RGB 定义在

I believe this is the code snippet from MasteringOpenCV - Chapter 4. I've checked the whole project and it appears that this is some sort of a bug pointcloud_RGB is defined at

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

除了这里没有赋值;

rgbv = pointcloud_RGB[i];

这是在

if (i < pointcloud_RGB.size())

如果因为 pointcloud_RGB 是空的,所以程序永远不会进入这个,因此不能大于 i.这就是为什么它应该运行没有任何问题.

the program would never go into this if since pointcloud_RGB is empty and therefore cannot be bigger than i. That's why it should run without any problems.

真正的点云是pcl::PointXYZRGB pclp;这里用XYZ坐标+RGB值填充;

The real point cloud is pcl::PointXYZRGB pclp; and it is filled in here with XYZ coordinates + RGB values;

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]); 

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

Of course there's always the possibility of sending an e-mail to the author and ask for a clarification.

这篇关于来自 Motion Visualizer 的结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆