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;
}
pcl::PointXYZRGB
" – African