if(Ptrr->size() > 0) {\n\t\tpcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());\n\t\tcoefficients->values.resize(4);\n\t\tcoefficients->values[0] = 1;\n\t\tcoefficients->values[1] = 0;\n\t\tcoefficients->values[2] = 1;\n\t\tcoefficients->values[3] = 0;\n\t\t// --------------创建滤波器对象-------------------\n\t\tpcl::ProjectInlierspcl::PointXYZRGB proj;\n\t\tproj.setModelType(pcl::SACMODEL_PLANE);\n\t\tproj.setInputCloud(Ptrr);\n\t\tproj.setModelCoefficients(coefficients);\n\t\tproj.filter(*touy);\n\t\t//pcl::io::savePLYFileASCII("E:\dianyun\put12.ply", *touy);\n\n\t\t//可视化\n\t\t//boost::shared_ptrpcl::visualization::PCLVisualizer viewer(new pcl::visualization::PCLVisualizer("cloud show"));\n\t\t//int v1 = 0;\n\t\t//int v2 = 1;\n\t\t//viewer->createViewPort(0, 0, 0.5, 1, v1);\n\t\t//viewer->createViewPort(0.5, 0, 1, 1, v2);\n\t\t//viewer->setBackgroundColor(1, 1, 1, v1);\n\t\t//viewer->setBackgroundColor(1, 1, 1, v2);\n\t\t////原始点云绿色\n\t\t//pcl::visualization::PointCloudColorHandlerCustompcl::PointXYZRGB src_h(Ptrr, 0, 255, 0);\n\t\t////投影后的点云\n\t\t//pcl::visualization::PointCloudColorHandlerCustompcl::PointXYZRGB pro_cloud(touy, 0, 0, 255);\n\t\t////viewer->setBackgroundColor(255, 255, 255);\n\t\t//viewer->addPointCloud(Ptrr, src_h, "cloud", v1);\n\t\t//viewer->addPointCloud(touy, pro_cloud, "pro_cloud", v2);\n\t\t//while (!viewer->wasStopped())\n\t\t//{\n\t\t//\tviewer->spinOnce(100);\n\t\t//\tboost::this_thread::sleep(boost::posix_time::microseconds(10000));\n\t\t//}\n\n\t\t//根据投影的点云数据拟合椭圆,使用\n\t\t// Fit ellipse\n\t\tcv::RotatedRect ellipse = fitEllipse(touy);\n\n\t\t// Output major and minor axes\n\t\tstd::cout << "Major axis: " << ellipse.size.width << std::endl;\n\t\tstd::cout << "Minor axis: " << ellipse.size.height << std::endl;\n}

PCL 点云投影:在点云数据非空的情况下执行投影操作

原文地址: https://www.cveoy.top/t/topic/p1hO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录