| 55 | using CloudPtr = Cloud::Ptr; |
| 56 | |
| 57 | int |
| 58 | main (int argc, char **argv) |
| 59 | { |
| 60 | double dist = 0.05; |
| 61 | pcl::console::parse_argument (argc, argv, "-d", dist); |
| 62 | |
| 63 | double rans = 0.05; |
| 64 | pcl::console::parse_argument (argc, argv, "-r", rans); |
| 65 | |
| 66 | int iter = 50; |
| 67 | pcl::console::parse_argument (argc, argv, "-i", iter); |
| 68 | |
| 69 | bool nonLinear = false; |
| 70 | pcl::console::parse_argument (argc, argv, "-n", nonLinear); |
| 71 | |
| 72 | std::vector<int> pcd_indices; |
| 73 | pcd_indices = pcl::console::parse_file_extension_argument (argc, argv, ".pcd"); |
| 74 | |
| 75 | pcl::IterativeClosestPoint<PointType, PointType>::Ptr icp; |
| 76 | if (nonLinear) |
| 77 | { |
| 78 | std::cout << "Using IterativeClosestPointNonLinear" << std::endl; |
| 79 | icp.reset (new pcl::IterativeClosestPointNonLinear<PointType, PointType> ()); |
| 80 | } |
| 81 | else |
| 82 | { |
| 83 | std::cout << "Using IterativeClosestPoint" << std::endl; |
| 84 | icp.reset (new pcl::IterativeClosestPoint<PointType, PointType> ()); |
| 85 | } |
| 86 | icp->setMaximumIterations (iter); |
| 87 | icp->setMaxCorrespondenceDistance (dist); |
| 88 | icp->setRANSACOutlierRejectionThreshold (rans); |
| 89 | |
| 90 | pcl::registration::IncrementalRegistration<PointType> iicp; |
| 91 | iicp.setRegistration (icp); |
| 92 | |
| 93 | for (const int &pcd_index : pcd_indices) |
| 94 | { |
| 95 | CloudPtr data (new Cloud); |
| 96 | if (pcl::io::loadPCDFile (argv[pcd_index], *data) == -1) |
| 97 | { |
| 98 | std::cout << "Could not read file" << std::endl; |
| 99 | return -1; |
| 100 | } |
| 101 | pcl::Indices dummy_indices; |
| 102 | pcl::removeNaNFromPointCloud(*data, *data, dummy_indices); |
| 103 | |
| 104 | if (!iicp.registerCloud (data)) |
| 105 | { |
| 106 | std::cout << "Registration failed. Resetting transform" << std::endl; |
| 107 | iicp.reset (); |
| 108 | iicp.registerCloud (data); |
| 109 | }; |
| 110 | |
| 111 | CloudPtr tmp (new Cloud); |
| 112 | pcl::transformPointCloud (*data, *tmp, iicp.getAbsoluteTransform ()); |
| 113 | |
| 114 | std::cout << iicp.getAbsoluteTransform () << std::endl; |
nothing calls this directly
no test coverage detected