mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 17:40:23 +08:00
DbViewer: added menu actions to view/update/export optimized mesh saved in database. CloudViewer: cubes can be added for convenience, fixed double-click not always working. util3d: added conversion function from LaserScan to PointCloud2, added conversion functions between polygons format saved in database and PCL polygons format with vertices.
This commit is contained in:
@@ -2285,6 +2285,45 @@ cv::Mat laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud,
|
||||
return laserScan(cv::Range::all(), cv::Range(0,oi));
|
||||
}
|
||||
|
||||
pcl::PCLPointCloud2::Ptr laserScanToPointCloud2(const LaserScan & laserScan, const Transform & transform)
|
||||
{
|
||||
pcl::PCLPointCloud2::Ptr cloud(new pcl::PCLPointCloud2);
|
||||
if(laserScan.isEmpty())
|
||||
{
|
||||
return cloud;
|
||||
}
|
||||
|
||||
if(laserScan.format() == LaserScan::kXY || laserScan.format() == LaserScan::kXYZ)
|
||||
{
|
||||
pcl::toPCLPointCloud2(*laserScanToPointCloud(laserScan, transform), *cloud);
|
||||
}
|
||||
else if(laserScan.format() == LaserScan::kXYI || laserScan.format() == LaserScan::kXYZI)
|
||||
{
|
||||
pcl::toPCLPointCloud2(*laserScanToPointCloudI(laserScan, transform), *cloud);
|
||||
}
|
||||
else if(laserScan.format() == LaserScan::kXYNormal || laserScan.format() == LaserScan::kXYZNormal)
|
||||
{
|
||||
pcl::toPCLPointCloud2(*laserScanToPointCloudNormal(laserScan, transform), *cloud);
|
||||
}
|
||||
else if(laserScan.format() == LaserScan::kXYINormal || laserScan.format() == LaserScan::kXYZINormal)
|
||||
{
|
||||
pcl::toPCLPointCloud2(*laserScanToPointCloudINormal(laserScan, transform), *cloud);
|
||||
}
|
||||
else if(laserScan.format() == LaserScan::kXYZRGB)
|
||||
{
|
||||
pcl::toPCLPointCloud2(*laserScanToPointCloudRGB(laserScan, transform), *cloud);
|
||||
}
|
||||
else if(laserScan.format() == LaserScan::kXYZRGBNormal)
|
||||
{
|
||||
pcl::toPCLPointCloud2(*laserScanToPointCloudRGBNormal(laserScan, transform), *cloud);
|
||||
}
|
||||
else
|
||||
{
|
||||
UERROR("Unknown conversion from LaserScan format %d to PointCloud2.", laserScan.format());
|
||||
}
|
||||
return cloud;
|
||||
}
|
||||
|
||||
pcl::PointCloud<pcl::PointXYZ>::Ptr laserScanToPointCloud(const LaserScan & laserScan, const Transform & transform)
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZ>::Ptr output(new pcl::PointCloud<pcl::PointXYZ>);
|
||||
|
||||
@@ -1196,6 +1196,51 @@ void concatenateTextureMaterials(pcl::TextureMesh & mesh, const cv::Size & image
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::vector<unsigned int> > convertPolygonsFromPCL(const std::vector<pcl::Vertices> & polygons)
|
||||
{
|
||||
std::vector<std::vector<unsigned int> > polygonsOut(polygons.size());
|
||||
for(unsigned int p=0; p<polygons.size(); ++p)
|
||||
{
|
||||
polygonsOut[p] = polygons[p].vertices;
|
||||
}
|
||||
return polygonsOut;
|
||||
}
|
||||
std::vector<std::vector<std::vector<unsigned int> > > convertPolygonsFromPCL(const std::vector<std::vector<pcl::Vertices> > & tex_polygons)
|
||||
{
|
||||
std::vector<std::vector<std::vector<unsigned int> > > polygonsOut(tex_polygons.size());
|
||||
for(unsigned int t=0; t<tex_polygons.size(); ++t)
|
||||
{
|
||||
polygonsOut[t].resize(tex_polygons[t].size());
|
||||
for(unsigned int p=0; p<tex_polygons[t].size(); ++p)
|
||||
{
|
||||
polygonsOut[t][p] = tex_polygons[t][p].vertices;
|
||||
}
|
||||
}
|
||||
return polygonsOut;
|
||||
}
|
||||
std::vector<pcl::Vertices> convertPolygonsToPCL(const std::vector<std::vector<unsigned int> > & polygons)
|
||||
{
|
||||
std::vector<pcl::Vertices> polygonsOut(polygons.size());
|
||||
for(unsigned int p=0; p<polygons.size(); ++p)
|
||||
{
|
||||
polygonsOut[p].vertices = polygons[p];
|
||||
}
|
||||
return polygonsOut;
|
||||
}
|
||||
std::vector<std::vector<pcl::Vertices> > convertPolygonsToPCL(const std::vector<std::vector<std::vector<unsigned int> > > & tex_polygons)
|
||||
{
|
||||
std::vector<std::vector<pcl::Vertices> > polygonsOut(tex_polygons.size());
|
||||
for(unsigned int t=0; t<tex_polygons.size(); ++t)
|
||||
{
|
||||
polygonsOut[t].resize(tex_polygons[t].size());
|
||||
for(unsigned int p=0; p<tex_polygons[t].size(); ++p)
|
||||
{
|
||||
polygonsOut[t][p].vertices = tex_polygons[t][p];
|
||||
}
|
||||
}
|
||||
return polygonsOut;
|
||||
}
|
||||
|
||||
pcl::TextureMesh::Ptr assembleTextureMesh(
|
||||
const cv::Mat & cloudMat,
|
||||
const std::vector<std::vector<std::vector<unsigned int> > > & polygons,
|
||||
|
||||
Reference in New Issue
Block a user