基于CloudCompare开发的提取ISS3D关键点。
void qLxPluginPCL::doISS3D()
{
assert(m_app);
if (!m_app)
return; const ccHObject::Container& selectedEntities = m_app->getSelectedEntities();
size_t selNum = selectedEntities.size();
if (selNum!=)
{
m_app->dispToConsole("Select only one cloud!",ccMainAppInterface::ERR_CONSOLE_MESSAGE);
return;
} ccHObject* ent = selectedEntities[];
assert(ent);
if (!ent || !ent->isA(CC_TYPES::POINT_CLOUD))
{
m_app->dispToConsole("Select a real point cloud!",ccMainAppInterface::ERR_CONSOLE_MESSAGE);
return;
} ccPointCloud* m_cc_cloud = static_cast<ccPointCloud*>(ent); //input cloud
unsigned count = m_cc_cloud->size();
bool hasNorms = m_cc_cloud->hasNormals();
CCVector3 bbMin, bbMax;
m_cc_cloud->getBoundingBox(bbMin,bbMax);
const CCVector3d& globalShift = m_cc_cloud->getGlobalShift();
double globalScale = m_cc_cloud->getGlobalScale(); ccIss3Ddlg dlg;
if (!dlg.exec())
return; double s_SalientRadius=dlg.sbSalientRadius->value();
double s_NonMaxRadius =dlg.spNonMaxRadius->value();
double s_Threshold21 = dlg.spThreshold21->value();
double s_Threshold32 = dlg.spThreshold32->value(); pcl::PointCloud<PointXYZ>::Ptr pcl_cloud (new pcl::PointCloud<PointXYZ>);
try
{
unsigned pointCount = m_cc_cloud->size();
pcl_cloud->resize(pointCount); for (unsigned i = ; i < pointCount; ++i)
{
const CCVector3* P = m_cc_cloud->getPoint(i);
pcl_cloud->at(i).x = static_cast<float>(P->x);
pcl_cloud->at(i).y = static_cast<float>(P->y);
pcl_cloud->at(i).z = static_cast<float>(P->z);
}
}
catch(...)
{
//any error (memory, etc.)
pcl_cloud.reset();
} printf("读取了data点云数据:%d\n",pcl_cloud->size()); pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ()); pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_out (new pcl::PointCloud<pcl::PointXYZ>); pcl::ISSKeypoint3D<pcl::PointXYZ,pcl::PointXYZ> iss_detector;
iss_detector.setSearchMethod (tree);
iss_detector.setSalientRadius(s_SalientRadius);
iss_detector.setNonMaxRadius(s_NonMaxRadius);
/*iss_detector.setSalientRadius(2.0f);
iss_detector.setNonMaxRadius(1.6f);*/
iss_detector.setInputCloud(pcl_cloud);
/*iss_detector.setThreshold21 (0.975);
iss_detector.setThreshold32 (0.975);*/
iss_detector.setThreshold21 (s_Threshold21);
iss_detector.setThreshold32 (s_Threshold32);
iss_detector.setMinNeighbors ();
iss_detector.setNumberOfThreads ();
cout<<"parameter set successful"<<endl;
iss_detector.compute(*cloud_out); int pointCount = cloud_out->size(); //static_cast<size_t>(sm_cloud ? sm_cloud->width * sm_cloud->height : 0); ccPointCloud* ccCloud =new ccPointCloud();
if (!ccCloud->reserve(static_cast<unsigned>(pointCount)))
return ;
for (size_t i = ; i < pointCount; ++i)
{
CCVector3 P(cloud_out->at(i).x,cloud_out->at(i).y,cloud_out->at(i).z);
ccCloud->addPoint(P);
}
ccCloud->setName(QString("ISS3D"));
ccColor::Rgb col = ccColor::Generator::Random();
ccCloud->setRGBColor(col);
ccCloud->showColors(true);
ccCloud->setPointSize();
ccHObject* group = ;
if (!group)
group = new ccHObject(QString("ISS3D").arg(ent->getName()));
group->addChild(ccCloud);
group->setVisible(true);
m_app->addToDB(group);
}
界面: