Skip to content

Commit 4ada8de

Browse files
feat: add test for RANSAC plane fitting
1 parent f0d0a23 commit 4ada8de

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/unit_tests/DFPointCloudTest.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,12 @@ TEST_F(DFPointCloudTestFixture, Transform) {
221221
// Others
222222
//-------------------------------------------------------------------------
223223

224-
// TEST_F(DFPointCloudTestFixture, KMeansClusteringOfNormals) {
225-
// std::string path = diffCheck::io::GetTwoConnectedPlanesPlyPath();
226-
// diffCheck::geometry::DFPointCloud dfPointCloud2Planes;
227-
// dfPointCloud2Planes.LoadFromPLY(path);
228-
// std::vector<Eigen::Vector3d> axes = dfPointCloud2Planes.GetPrincipalAxes(2);
229-
// EXPECT_TRUE((axes[0] - Eigen::Vector3d(0, 0, 1)).norm() < 1e-2 || (axes[1] - Eigen::Vector3d(0, 0, 1)).norm() < 1e-2);
230-
// }
224+
TEST_F(DFPointCloudTestFixture, FitPlaneRANSAC) {
225+
std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPlane = std::make_shared<diffCheck::geometry::DFPointCloud>();
226+
dfPointCloudPlane->LoadFromPLY(diffCheck::io::GetPlanePCWithOneOutliers());
227+
Eigen::Vector3d planeNormal = dfPointCloudPlane->FitPlaneRANSAC(0.01, 3, 100);
228+
// plane model should be close to (0, 0, 1, d)
229+
EXPECT_NEAR(planeNormal[0], 0.0, 1e-2);
230+
EXPECT_NEAR(planeNormal[1], 0.0, 1e-2);
231+
EXPECT_NEAR(std::abs(planeNormal[2]), 1.0, 1e-2);
232+
}

0 commit comments

Comments
 (0)