超体素类似与超像素,其基本单元是体素,一个体素为一个立方体。简单的立方体可视化如下所示:
#include <thread>
#include <pcl/common/common_headers.h>
#include <pcl/features/normal_3d.h>
#include <pcl/visualization/pcl_visualizer.h>
using namespace std;
void main(int argc, char** argv) {
pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer("HelloMyFirstVisualPCL"));
viewer->setBackgroundColor(0, 0, 0);
ifstream infile("Chair.txt", ios::in);
double x, y, z;
char line[128];
double voxel = 10;
int ii = 0;
int jj = 0;
while (infile.getline(line,sizeof(line)))
{
ii = ii + 1;
stringstream ss(line);
if (int(ii%50)==0)
{
jj++;
ss >> x;
ss >> y;
ss >> z;
Eigen::Vector3f center(floor(x / voxel)*voxel + voxel / 2, floor(y / voxel)*voxel + voxel / 2, floor(z / voxel)*voxel + voxel / 2);
Eigen::Quaternionf rotation(1, 0, 0, 0);
string cube = "cude" + to_string(ii);
viewer->addCube(center, rotation, voxel, voxel, voxel, cube);
//viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_REPRESENTATION, pcl::visualization::PCL_VISUALIZER_REPRESENTATION_WIREFRAME, cube);
该语句使用线条进行可视化
//viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LUT_HSV, pcl::visualization::PCL_VISUALIZER_REPRESENTATION_WIREFRAME, cube);
}
}
while (!viewer->wasStopped())
{
viewer->spinOnce(100);
}
}
PCL中渲染较多的立方体时,会变得非常的卡顿,只显示部分立方体。