@@ -9,53 +9,57 @@ int main()
99{
1010 // import clouds
1111 std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr = std::make_shared<diffCheck::geometry::DFPointCloud>();
12- std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrGroundTruthNoNormals = std::make_shared<diffCheck::geometry::DFPointCloud>();
1312 std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrGroundTruth = std::make_shared<diffCheck::geometry::DFPointCloud>();
13+ std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrGroundTruthFromMesh = std::make_shared<diffCheck::geometry::DFPointCloud>();
1414 std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr = std::make_shared<diffCheck::geometry::DFMesh>();
1515
16- std::string pathCloud = R"( C:\Users\localuser\Downloads\04_pt .ply)" ;
17- std::string pathMesh = R"( C:\Users\localuser\Downloads\04_mesh .ply)" ;
16+ std::string pathCloud = R"( C:\Users\localuser\Downloads\00_pt .ply)" ;
17+ std::string pathMesh = R"( C:\Users\localuser\Downloads\00_mesh .ply)" ;
1818
1919 dfMeshPtr->LoadFromPLY (pathMesh);
2020 dfPointCloudPtr->LoadFromPLY (pathCloud);
21+ dfPointCloudPtrGroundTruth->LoadFromPLY (pathCloud);
22+
2123 // add noise to dfPointCloudPtr
24+ std::vector<Eigen::Vector3d> boundingBoxPoints = dfPointCloudPtr->ComputeBoundingBox ();
25+ double meanInterval = (boundingBoxPoints[0 ] - boundingBoxPoints[1 ]).norm ();
2226 for (int i = 0 ; i < dfPointCloudPtr->Points .size (); i++)
2327 {
24- dfPointCloudPtr->Points [i] += Eigen::Vector3d::Random () * 0.01 ;
28+ dfPointCloudPtr->Points [i] += Eigen::Vector3d::Random () * 0.002 * meanInterval ;
2529 }
26-
27- // populate the mesh with points and store it in dfPointCloudPtrGroundTruth
28- dfPointCloudPtrGroundTruthNoNormals->Cvt2DFPointCloud (dfMeshPtr->Cvt2O3DTriangleMesh ()->SamplePointsUniformly (1000 ));
29- std::shared_ptr<open3d::geometry::PointCloud> pcd = dfPointCloudPtrGroundTruthNoNormals->Cvt2O3DPointCloud ();
30- pcd->EstimateNormals ();
31- dfPointCloudPtrGroundTruth->Cvt2DFPointCloud (pcd);
30+
31+ // populate the mesh with points and store it in dfPointCloudPtrGroundTruthFromMesh
32+ std::shared_ptr<open3d::geometry::PointCloud> pcd_1 = dfMeshPtr->Cvt2O3DTriangleMesh ()->SamplePointsUniformly (50000 );
33+ dfPointCloudPtrGroundTruthFromMesh->Cvt2DFPointCloud (pcd_1);
3234
3335 // create a rigid rotation matrix
3436 Eigen::Matrix4d T = Eigen::Matrix4d::Identity ();
35- T.block <3 , 3 >(0 , 0 ) = Eigen::AngleAxisd (3 , Eigen::Vector3d::UnitX ()).toRotationMatrix ();
36- T (0 , 3 ) = 50 ;
37- T (1 , 3 ) = -100 ;
38- T (2 , 3 ) = 100 ;
37+ T.block <3 , 3 >(0 , 0 ) = Eigen::AngleAxisd (1.57 , Eigen::Vector3d::UnitX ()).toRotationMatrix ();
38+ T (0 , 3 ) = 5 ;
39+ T (1 , 3 ) = -10 ;
40+ T (2 , 3 ) = 10 ;
3941 dfPointCloudPtr->ApplyTransformation (diffCheck::transformation::DFTransformation (T));
42+
43+ // create a copy of the point cloud so we can test both global registrations
4044 std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrCopy = std::make_shared<diffCheck::geometry::DFPointCloud>(*dfPointCloudPtr);
4145
4246 // test global registrations Fast and RANSAC-based
4347 std::vector<diffCheck::transformation::DFTransformation> registrationResults;
4448 diffCheck::transformation::DFTransformation transformationA =
45- diffCheck::registrations::DFGlobalRegistrations::O3DFastGlobalRegistrationFeatureMatching (dfPointCloudPtr, dfPointCloudPtrGroundTruth, true , 0.01 , 1 , 50 , 1 , 500 , 500 );
46- std::cout << " Fast transformation: " << transformationA.TransformationMatrix << std::flush ;
49+ diffCheck::registrations::DFGlobalRegistrations::O3DFastGlobalRegistrationFeatureMatching (dfPointCloudPtr, dfPointCloudPtrGroundTruth);
50+ std::cout << " Fast transformation: " << transformationA.TransformationMatrix << std::endl ;
4751 dfPointCloudPtr->ApplyTransformation (transformationA);
4852 registrationResults.push_back (transformationA);
4953 diffCheck::transformation::DFTransformation transformationB =
50- diffCheck::registrations::DFGlobalRegistrations::O3DRansacOnFeatureMatching (dfPointCloudPtrCopy, dfPointCloudPtrGroundTruth );
54+ diffCheck::registrations::DFGlobalRegistrations::O3DRansacOnFeatureMatching (dfPointCloudPtrCopy, dfPointCloudPtrGroundTruthFromMesh );
5155 std::cout << " Ransac transformation: " << transformationB.TransformationMatrix << std::endl;
5256 dfPointCloudPtrCopy->ApplyTransformation (transformationB);
5357 registrationResults.push_back (transformationB);
5458
5559 // visualize cloud
5660 std::shared_ptr<diffCheck::visualizer::Visualizer> visualizer = std::make_shared<diffCheck::visualizer::Visualizer>();
57- visualizer->AddPointCloud (dfPointCloudPtr);
5861 visualizer->AddPointCloud (dfPointCloudPtrCopy);
62+ visualizer->AddPointCloud (dfPointCloudPtr);
5963 visualizer->AddMesh (dfMeshPtr);
6064 visualizer->Run ();
6165
0 commit comments