-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a406c3
commit 5b0920c
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ | |
moving_least_squares, | ||
radius_outlier_removal, | ||
octree_voxel_centroid, | ||
fit, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pytest | ||
import os | ||
import numpy as np | ||
from math import cos, sin, pi | ||
|
||
from pclpy import pcl | ||
import pclpy | ||
|
||
|
||
def test_data(*args): | ||
return os.path.join("test_data", *args) | ||
|
||
|
||
def test_fit_line(): | ||
line = np.array([(1, 2, 3), (2, 4, 6), (3, 7, 9), (5, 10, 15)]) | ||
pc = pcl.PointCloud.PointXYZ(line) | ||
inliers, coefficients = pclpy.fit(pc, "line", distance=0.1) | ||
assert len(inliers.indices) == 3 | ||
assert np.allclose(coefficients.values, pcl.vectors.Float([2.66667, 5.33333, 8, 0.267261, 0.534522, 0.801784])) | ||
|
||
|
||
def test_fit_cylinder(): | ||
points = np.array([(cos(a), sin(a), z) for z in np.linspace(0, 5, num=10) for a in np.linspace(0, 2 * pi, num=20)]) | ||
points = np.vstack((np.array([10, 10, 10]), points)) | ||
pc = pcl.PointCloud.PointXYZ(points) | ||
inliers, coefficients = pclpy.fit(pc, "circle2d", distance=0.01, indices=np.arange(100)) | ||
assert 0 not in inliers.indices | ||
assert len(inliers.indices) == 99 | ||
assert np.allclose(coefficients.values, [0., 0., 1.], atol=0.00001) |