@@ -14,6 +14,7 @@ int main()
1414 std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr = std::make_shared<diffCheck::geometry::DFPointCloud>();
1515 std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrAfterTrans = std::make_shared<diffCheck::geometry::DFPointCloud>();
1616 std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrAfterReg = std::make_shared<diffCheck::geometry::DFPointCloud>();
17+ std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrGroundTruth = std::make_shared<diffCheck::geometry::DFPointCloud>();
1718 std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr = std::make_shared<diffCheck::geometry::DFMesh>();
1819
1920 std::string pathCloud = R"( C:\Users\localuser\Downloads\04_pt.ply)" ;
@@ -23,6 +24,9 @@ int main()
2324 dfMeshPtr->LoadFromPLY (pathMesh);
2425 dfPointCloudPtr->LoadFromPLY (pathCloud);
2526
27+ // populate the mesh with points and store it in dfPointCloudPtrGroundTruth
28+ dfPointCloudPtrGroundTruth->Cvt2DFPointCloud (dfMeshPtr->Cvt2O3DTriangleMesh ()->SamplePointsUniformly (100000 ));
29+
2630 // create a rigid rotation matrix
2731 Eigen::Matrix4d T = Eigen::Matrix4d::Identity ();
2832 T.block <3 , 3 >(0 , 0 ) = Eigen::AngleAxisd (3 , Eigen::Vector3d::UnitZ ()).toRotationMatrix (); // Yes, Pi = 3 in this world
@@ -33,17 +37,18 @@ int main()
3337 dfPointCloudPtrAfterTrans->Cvt2DFPointCloud (o3DPointCloudAfterTrans);
3438
3539 std::shared_ptr<diffCheck::registration::Registration> reg = std::make_shared<diffCheck::registration::Registration>();
36- auto result = reg->O3DFastGlobalRegistrationFeatureMatching (dfPointCloudPtrAfterTrans, dfPointCloudPtr);
37- // auto result = reg->O3DFastGlobalRegistrationBasedOnCorrespondence(dfPointCloudPtrAfterTrans, dfPointCloudPtr);
40+ // auto result = reg->O3DFastGlobalRegistrationFeatureMatching(dfPointCloudPtrAfterTrans, dfPointCloudPtr);
41+ auto result = reg->O3DFastGlobalRegistrationBasedOnCorrespondence (dfPointCloudPtrAfterTrans, dfPointCloudPtr);
3842
3943 // apply the transformation to the source point cloud
4044 Eigen::Matrix<double , 4 , 4 > transformation = result.transformation_ ;
4145 std::shared_ptr<open3d::geometry::PointCloud> o3DPointCloudPtrAfterReg = std::make_shared<open3d::geometry::PointCloud>(dfPointCloudPtrAfterTrans->Cvt2O3DPointCloud ()->Transform (transformation));
4246 dfPointCloudPtrAfterReg->Cvt2DFPointCloud (o3DPointCloudPtrAfterReg);
43-
47+ std::vector<double > errors = reg->ComputeP2PDistance (dfPointCloudPtrAfterReg, dfPointCloudPtrGroundTruth);
48+ std::cout << " Mean distance: " << std::accumulate (errors.begin (), errors.end (), 0.0 ) / errors.size () << std::endl;
4449
4550 std::shared_ptr<diffCheck::visualizer::Visualizer> vis = std::make_shared<diffCheck::visualizer::Visualizer>();
46- vis->AddPointCloud (dfPointCloudPtrAfterTrans );
51+ vis->AddPointCloud (dfPointCloudPtrGroundTruth );
4752 vis->AddPointCloud (dfPointCloudPtrAfterReg);
4853 vis->AddMesh (dfMeshPtr);
4954 vis->Run ();
0 commit comments