@@ -9,57 +9,54 @@ 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> dfPointCloudPtrAfterTrans = std::make_shared<diffCheck::geometry::DFPointCloud>();
1312 std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrGroundTruthNoNormals = std::make_shared<diffCheck::geometry::DFPointCloud>();
1413 std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrGroundTruth = std::make_shared<diffCheck::geometry::DFPointCloud>();
1514 std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr = std::make_shared<diffCheck::geometry::DFMesh>();
1615
17- std::string pathCloud = R"( C:\Users\andre \Downloads\00_pt .ply)" ;
18- std::string pathMesh = R"( C:\Users\andre \Downloads\00_mesh .ply)" ;
16+ std::string pathCloud = R"( C:\Users\localuser \Downloads\04_pt .ply)" ;
17+ std::string pathMesh = R"( C:\Users\localuser \Downloads\04_mesh .ply)" ;
1918
2019 dfMeshPtr->LoadFromPLY (pathMesh);
2120 dfPointCloudPtr->LoadFromPLY (pathCloud);
22-
2321 // add noise to dfPointCloudPtr
2422 for (int i = 0 ; i < dfPointCloudPtr->Points .size (); i++)
2523 {
26- dfPointCloudPtr->Points [i] += Eigen::Vector3d::Random () * 0.1 ;
24+ dfPointCloudPtr->Points [i] += Eigen::Vector3d::Random () * 0.01 ;
2725 }
2826
2927 // populate the mesh with points and store it in dfPointCloudPtrGroundTruth
30- dfPointCloudPtrGroundTruthNoNormals->Cvt2DFPointCloud (dfMeshPtr->Cvt2O3DTriangleMesh ()->SamplePointsUniformly (10000 ));
28+ dfPointCloudPtrGroundTruthNoNormals->Cvt2DFPointCloud (dfMeshPtr->Cvt2O3DTriangleMesh ()->SamplePointsUniformly (1000 ));
3129 std::shared_ptr<open3d::geometry::PointCloud> pcd = dfPointCloudPtrGroundTruthNoNormals->Cvt2O3DPointCloud ();
3230 pcd->EstimateNormals ();
3331 dfPointCloudPtrGroundTruth->Cvt2DFPointCloud (pcd);
34-
32+
3533 // create a rigid rotation matrix
3634 Eigen::Matrix4d T = Eigen::Matrix4d::Identity ();
37- T.block <3 , 3 >(0 , 0 ) = Eigen::AngleAxisd (0. 3 , Eigen::Vector3d::UnitX ()).toRotationMatrix ();
38- T (0 , 3 ) = 5 ;
39- T (1 , 3 ) = -10 ;
40- T (2 , 3 ) = 10 ;
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 ;
4139 dfPointCloudPtr->ApplyTransformation (diffCheck::transformation::DFTransformation (T));
42- dfPointCloudPtrAfterTrans = dfPointCloudPtr;
40+ std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrCopy = std::make_shared<diffCheck::geometry::DFPointCloud>(* dfPointCloudPtr) ;
4341
4442 // test global registrations Fast and RANSAC-based
4543 std::vector<diffCheck::transformation::DFTransformation> registrationResults;
46-
4744 diffCheck::transformation::DFTransformation transformationA =
48- diffCheck::registrations::DFGlobalRegistrations::O3DFastGlobalRegistrationFeatureMatching (dfPointCloudPtr, dfPointCloudPtrAfterTrans );
49- std::cout << " Fast transformation: " << transformationA.TransformationMatrix << std::endl ;
50- dfPointCloudPtrAfterTrans ->ApplyTransformation (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 ;
47+ dfPointCloudPtr ->ApplyTransformation (transformationA);
5148 registrationResults.push_back (transformationA);
52-
5349 diffCheck::transformation::DFTransformation transformationB =
54- diffCheck::registrations::DFGlobalRegistrations::O3DRansacOnFeatureMatching (dfPointCloudPtr, dfPointCloudPtrAfterTrans );
50+ diffCheck::registrations::DFGlobalRegistrations::O3DRansacOnFeatureMatching (dfPointCloudPtrCopy, dfPointCloudPtrGroundTruth );
5551 std::cout << " Ransac transformation: " << transformationB.TransformationMatrix << std::endl;
56- dfPointCloudPtrAfterTrans ->ApplyTransformation (transformationB);
52+ dfPointCloudPtrCopy ->ApplyTransformation (transformationB);
5753 registrationResults.push_back (transformationB);
5854
5955 // visualize cloud
6056 std::shared_ptr<diffCheck::visualizer::Visualizer> visualizer = std::make_shared<diffCheck::visualizer::Visualizer>();
6157 visualizer->AddPointCloud (dfPointCloudPtr);
62- visualizer->AddPointCloud (dfPointCloudPtrAfterTrans);
58+ visualizer->AddPointCloud (dfPointCloudPtrCopy);
59+ visualizer->AddMesh (dfMeshPtr);
6360 visualizer->Run ();
6461
6562 return 0 ;
0 commit comments