|
12 | 12 | int main() |
13 | 13 | { |
14 | 14 | std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr = std::make_shared<diffCheck::geometry::DFPointCloud>(); |
| 15 | + std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrAfterTrans = std::make_shared<diffCheck::geometry::DFPointCloud>(); |
| 16 | + std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrAfterReg = std::make_shared<diffCheck::geometry::DFPointCloud>(); |
15 | 17 | std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr = std::make_shared<diffCheck::geometry::DFMesh>(); |
16 | 18 |
|
17 | | - std::string pathCloud = R"(C:\Users\andre\Downloads\scan_data_normals.ply\scan_data_normals.ply)"; |
18 | | - std::string pathMesh = R"(F:\diffCheck\assets\dataset\mesh_fromRh_unfixedLength.ply)"; |
| 19 | + std::string pathCloud = R"(C:\Users\localuser\Downloads\00_pt.ply)"; |
| 20 | + std::string pathMesh = R"(C:\Users\localuser\Downloads\00_mesh.ply)"; |
19 | 21 | // std::string pathMesh = R"(F:\diffCheck\temp\03_mesh.ply)"; |
20 | 22 |
|
21 | | - // create a sphere from o3d |
22 | | - auto mesh = open3d::geometry::TriangleMesh::CreateSphere(1.0, 4); |
23 | 23 | dfMeshPtr->LoadFromPLY(pathMesh); |
| 24 | + dfPointCloudPtr->LoadFromPLY(pathCloud); |
24 | 25 |
|
| 26 | + // create a rigid rotation matrix |
| 27 | + Eigen::Matrix4d T = Eigen::Matrix4d::Identity(); |
| 28 | + T.block<3, 3>(0, 0) = Eigen::AngleAxisd(3 , Eigen::Vector3d::UnitZ()).toRotationMatrix(); // Yes, Pi = 3 in this case |
| 29 | + T(0, 3) = 1; |
| 30 | + T(1, 3) = 4; |
25 | 31 |
|
26 | | - dfMeshPtr->Cvt2DFMesh(mesh); |
| 32 | + std::shared_ptr<open3d::geometry::PointCloud> o3DPC = std::make_shared<open3d::geometry::PointCloud>(dfPointCloudPtr->Cvt2O3DPointCloud()->Transform(T)); |
| 33 | + dfPointCloudPtrAfterTrans->Cvt2DFPointCloud(o3DPC); |
| 34 | + |
| 35 | + std::shared_ptr<diffCheck::registration::Registration> reg = std::make_shared<diffCheck::registration::Registration>(); |
| 36 | + auto result = reg->o3dFastGlobalRegistrationFeatureMatching(dfPointCloudPtrAfterTrans, dfPointCloudPtr); |
| 37 | + |
| 38 | + // apply the transformation to the source point cloud |
| 39 | + Eigen::Matrix |
| 40 | + <double, 4, 4> transformation = result.transformation_; |
| 41 | + std::shared_ptr<open3d::geometry::PointCloud> o3DPCReg = std::make_shared<open3d::geometry::PointCloud>(dfPointCloudPtrAfterTrans->Cvt2O3DPointCloud()->Transform(transformation)); |
| 42 | + dfPointCloudPtrAfterReg->Cvt2DFPointCloud(o3DPCReg); |
27 | 43 |
|
28 | | - // dfPointCloudPtr->LoadFromPLY(pathCloud); |
29 | 44 |
|
30 | 45 | std::shared_ptr<diffCheck::visualizer::Visualizer> vis = std::make_shared<diffCheck::visualizer::Visualizer>(); |
31 | | - // vis->AddPointCloud(dfPointCloudPtr); |
| 46 | + //vis->AddPointCloud(dfPointCloudPtrAfterTrans); |
| 47 | + vis->AddPointCloud(dfPointCloudPtrAfterReg); |
32 | 48 | vis->AddMesh(dfMeshPtr); |
33 | 49 | vis->Run(); |
34 | 50 |
|
|
0 commit comments