[英]Structure from Motion Visualizer
I am working on Structure from Motion. 我正在研究Motion的结构。 I think when it come to structure from motion, people would have came across MultiView Geometry book.
我认为,从运动到结构,人们会遇到《 MultiView Geometry》一书。 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.
在下面的代码中,有一个称为填充点云的函数,该函数具有两个参数pointcloud和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.
我在pointcloud中有point3d类型值,但在那本书中没有找到有关pointcloud_RGB的任何信息,它突然出现在此函数中,该函数用于填充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;
}
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 我相信这是MasteringOpenCV-第4章的代码片段。我检查了整个项目,看来这是一个错误点
pointcloud_RGB
在
const std::vector<cv::Vec3b>& pointcloud_RGB = std::vector<cv::Vec3b>()
and no value is assigned except here; 除了这里没有分配任何值;
rgbv = pointcloud_RGB[i];
and this is under the condition of 这是在以下条件下
if (i < pointcloud_RGB.size())
the program would never go into this if since pointcloud_RGB is empty and therefore cannot be bigger than i. 由于pointcloud_RGB为空,因此程序不能进入此程序,因此不能大于i。 That's why it should run without any problems.
这就是为什么它应该运行没有任何问题的原因。
The real point cloud is pcl::PointXYZRGB pclp;
真正的点云是
pcl::PointXYZRGB pclp;
and it is filled in here with XYZ coordinates + RGB values; 并在这里用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]);
Of course there's always the possibility of sending an e-mail to the author and ask for a clarification. 当然,总有可能向作者发送电子邮件并要求澄清。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.