标签:play another wol class sensu har pie segment zha
The following models are supported:
The following list describes the robust sample consensus estimators implemented:
#include <iostream> #include <thread> #include <pcl/console/parse.h> #include <pcl/filters/extract_indices.h> #include <pcl/io/pcd_io.h> #include <pcl/point_types.h> #include <pcl/sample_consensus/ransac.h> #include <pcl/sample_consensus/sac_model_plane.h> #include <pcl/sample_consensus/sac_model_sphere.h> #include <pcl/visualization/pcl_visualizer.h> using namespace std::chrono_literals; int main(int argc, char** argv) { // initialize PointClouds pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); pcl::PointCloud<pcl::PointXYZ>::Ptr final(new pcl::PointCloud<pcl::PointXYZ>); pcl::io::loadPCDFile("D:\\pcd\\sphere.pcd", *cloud); pcl::SampleConsensusModelSphere<pcl::PointXYZ>::Ptr model_s(new pcl::SampleConsensusModelSphere<pcl::PointXYZ>(cloud)); pcl::RandomSampleConsensus<pcl::PointXYZ> ransac(model_s); ransac.setDistanceThreshold(2); ransac.computeModel(); std::vector<int> inliers; ransac.getInliers(inliers); Eigen::VectorXf coff; ransac.getModelCoefficients(coff); //cout << coff << endl; // copies all inliers of the model computed to another PointCloud pcl::copyPointCloud(*cloud, inliers, *final); // creates the visualization object and adds either our original cloud or all of the inliers // depending on the command line arguments specified. pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer("3D Viewer")); viewer->setBackgroundColor(0, 0, 0); viewer->addPointCloud<pcl::PointXYZ>(final, "sample cloud"); pcl::PointXYZ center(coff(0), coff(1), coff(2)); double R = coff(3); cout << "center " << center.x << " " << center.y << " " << center.z << endl; cout << "R" << R << endl; //viewer->addSphere(center, coff(2),"mySphere"); viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "sample cloud"); viewer->addCoordinateSystem (1.0, "global"); viewer->initCameraParameters(); while (!viewer->wasStopped()) { viewer->spinOnce(100); std::this_thread::sleep_for(100ms); } return 0; }
标签:play another wol class sensu har pie segment zha
原文地址:https://www.cnblogs.com/larry-xia/p/11887572.html