| 47 | } |
| 48 | |
| 49 | int |
| 50 | main(int argc, char** argv) |
| 51 | { |
| 52 | if (argc != 3) { |
| 53 | PCL_ERROR("Syntax: ./ppf_object_recognition pcd_model_list pcd_scene\n"); |
| 54 | return -1; |
| 55 | } |
| 56 | |
| 57 | /// read point clouds from HDD |
| 58 | PCL_INFO("Reading scene ...\n"); |
| 59 | PointCloud<PointXYZ>::Ptr cloud_scene(new PointCloud<PointXYZ>()); |
| 60 | PCDReader reader; |
| 61 | reader.read(argv[2], *cloud_scene); |
| 62 | PCL_INFO("Scene read: %s\n", argv[2]); |
| 63 | |
| 64 | PCL_INFO("Reading models ...\n"); |
| 65 | std::vector<PointCloud<PointXYZ>::Ptr> cloud_models; |
| 66 | std::ifstream pcd_file_list(argv[1]); |
| 67 | while (!pcd_file_list.eof()) { |
| 68 | char str[512]; |
| 69 | pcd_file_list.getline(str, 512); |
| 70 | PointCloud<PointXYZ>::Ptr cloud(new PointCloud<PointXYZ>()); |
| 71 | reader.read(str, *cloud); |
| 72 | cloud_models.push_back(cloud); |
| 73 | PCL_INFO("Model read: %s\n", str); |
| 74 | } |
| 75 | |
| 76 | pcl::SACSegmentation<pcl::PointXYZ> seg; |
| 77 | pcl::ExtractIndices<pcl::PointXYZ> extract; |
| 78 | seg.setOptimizeCoefficients(true); |
| 79 | seg.setModelType(pcl::SACMODEL_PLANE); |
| 80 | seg.setMethodType(pcl::SAC_RANSAC); |
| 81 | seg.setMaxIterations(1000); |
| 82 | seg.setDistanceThreshold(0.05); |
| 83 | extract.setNegative(true); |
| 84 | pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients()); |
| 85 | pcl::PointIndices::Ptr inliers(new pcl::PointIndices()); |
| 86 | const auto nr_points = cloud_scene->size(); |
| 87 | while (cloud_scene->size() > 0.3 * nr_points) { |
| 88 | seg.setInputCloud(cloud_scene); |
| 89 | seg.segment(*inliers, *coefficients); |
| 90 | PCL_INFO("Plane inliers: %zu\n", static_cast<std::size_t>(inliers->indices.size())); |
| 91 | if (inliers->indices.size() < 50000) |
| 92 | break; |
| 93 | |
| 94 | extract.setInputCloud(cloud_scene); |
| 95 | extract.setIndices(inliers); |
| 96 | extract.filter(*cloud_scene); |
| 97 | } |
| 98 | |
| 99 | PointCloud<PointNormal>::Ptr cloud_scene_input = |
| 100 | subsampleAndCalculateNormals(cloud_scene); |
| 101 | std::vector<PointCloud<PointNormal>::Ptr> cloud_models_with_normals; |
| 102 | |
| 103 | PCL_INFO("Training models ...\n"); |
| 104 | std::vector<PPFHashMapSearch::Ptr> hashmap_search_vector; |
| 105 | for (const auto& cloud_model : cloud_models) { |
| 106 | PointCloud<PointNormal>::Ptr cloud_model_input = |
nothing calls this directly
no test coverage detected