zoukankan      html  css  js  c++  java
  • [CC]Plugin-提取ISS3D关键点

    基于CloudCompare开发的提取ISS3D关键点。

      1 void qLxPluginPCL::doISS3D()
      2 {
      3     assert(m_app);
      4     if (!m_app)
      5         return;
      6 
      7     const ccHObject::Container& selectedEntities = m_app->getSelectedEntities();
      8     size_t selNum = selectedEntities.size();
      9     if (selNum!=1)
     10     {
     11         m_app->dispToConsole("Select only one cloud!",ccMainAppInterface::ERR_CONSOLE_MESSAGE);
     12         return;
     13     }
     14 
     15     ccHObject* ent = selectedEntities[0];
     16     assert(ent);
     17     if (!ent || !ent->isA(CC_TYPES::POINT_CLOUD))
     18     {
     19         m_app->dispToConsole("Select a real point cloud!",ccMainAppInterface::ERR_CONSOLE_MESSAGE);
     20         return;
     21     }
     22 
     23     ccPointCloud* m_cc_cloud = static_cast<ccPointCloud*>(ent);
     24 
     25 
     26     //input cloud
     27     unsigned count = m_cc_cloud->size();
     28     bool hasNorms = m_cc_cloud->hasNormals();
     29     CCVector3 bbMin, bbMax;
     30     m_cc_cloud->getBoundingBox(bbMin,bbMax);
     31     const CCVector3d& globalShift = m_cc_cloud->getGlobalShift();
     32     double globalScale = m_cc_cloud->getGlobalScale();
     33 
     34     ccIss3Ddlg dlg;
     35     if (!dlg.exec())
     36         return;
     37     
     38     double s_SalientRadius=dlg.sbSalientRadius->value();
     39     double s_NonMaxRadius =dlg.spNonMaxRadius->value();
     40     double s_Threshold21 = dlg.spThreshold21->value();
     41     double s_Threshold32 = dlg.spThreshold32->value();
     42 
     43     pcl::PointCloud<PointXYZ>::Ptr pcl_cloud (new pcl::PointCloud<PointXYZ>);
     44     try
     45     {
     46         unsigned pointCount = m_cc_cloud->size();
     47         pcl_cloud->resize(pointCount);
     48 
     49         for (unsigned i = 0; i < pointCount; ++i)
     50         {
     51             const CCVector3* P = m_cc_cloud->getPoint(i);
     52             pcl_cloud->at(i).x = static_cast<float>(P->x);
     53             pcl_cloud->at(i).y = static_cast<float>(P->y);
     54             pcl_cloud->at(i).z = static_cast<float>(P->z);
     55         }
     56     }
     57     catch(...)
     58     {
     59         //any error (memory, etc.)
     60         pcl_cloud.reset();
     61     }
     62 
     63     printf("读取了data点云数据:%d
    ",pcl_cloud->size());
     64 
     65     pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
     66   
     67     pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_out (new pcl::PointCloud<pcl::PointXYZ>);
     68 
     69     pcl::ISSKeypoint3D<pcl::PointXYZ,pcl::PointXYZ> iss_detector;
     70     iss_detector.setSearchMethod (tree);
     71     iss_detector.setSalientRadius(s_SalientRadius);
     72     iss_detector.setNonMaxRadius(s_NonMaxRadius);
     73     /*iss_detector.setSalientRadius(2.0f);
     74     iss_detector.setNonMaxRadius(1.6f);*/
     75     iss_detector.setInputCloud(pcl_cloud);
     76     /*iss_detector.setThreshold21 (0.975);
     77     iss_detector.setThreshold32 (0.975);*/
     78     iss_detector.setThreshold21 (s_Threshold21);
     79     iss_detector.setThreshold32 (s_Threshold32);
     80     iss_detector.setMinNeighbors (5);
     81     iss_detector.setNumberOfThreads (4);
     82     cout<<"parameter set successful"<<endl;
     83     iss_detector.compute(*cloud_out);
     84 
     85     int pointCount = cloud_out->size();
     86 
     87     //static_cast<size_t>(sm_cloud ? sm_cloud->width * sm_cloud->height : 0);
     88 
     89     ccPointCloud* ccCloud =new ccPointCloud();
     90     if (!ccCloud->reserve(static_cast<unsigned>(pointCount)))
     91         return ;
     92     for (size_t i = 0; i < pointCount; ++i)
     93     {
     94         CCVector3 P(cloud_out->at(i).x,cloud_out->at(i).y,cloud_out->at(i).z);
     95         ccCloud->addPoint(P);
     96     }
     97     ccCloud->setName(QString("ISS3D"));
     98     ccColor::Rgb col = ccColor::Generator::Random();
     99     ccCloud->setRGBColor(col);
    100     ccCloud->showColors(true);
    101     ccCloud->setPointSize(5);
    102     ccHObject* group = 0;
    103     if (!group)
    104         group = new ccHObject(QString("ISS3D").arg(ent->getName()));
    105     group->addChild(ccCloud);
    106     group->setVisible(true);
    107     m_app->addToDB(group);
    108 }

     界面:

  • 相关阅读:
    shader之渐变长方体实现(threejs)
    shader之threejs应用
    shader之cesium应用
    pip install -- Failed building wheel for XXX
    pycharm -- 界面乱码
    Android Studio -- 优化速度
    django -- ImageField 上传图片修改头像
    AI -- 回溯法解决四皇后问题
    Android Studio -- 真机测试
    傻瓜函数式编程
  • 原文地址:https://www.cnblogs.com/yhlx125/p/5574690.html
Copyright © 2011-2022 走看看