Spaces:
Sleeping
Sleeping
Update utils/pointcloud_tools.py
Browse files- utils/pointcloud_tools.py +15 -4
utils/pointcloud_tools.py
CHANGED
|
@@ -13,20 +13,31 @@ class PointCloudProcessor:
|
|
| 13 |
# Z-score ์ ๊ทํ
|
| 14 |
mean = np.mean(points, axis=0)
|
| 15 |
std = np.std(points, axis=0)
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
@staticmethod
|
| 19 |
def filter_outliers(points: np.ndarray, z_thresh=3.0) -> np.ndarray:
|
| 20 |
"""์ด์์น ์ ๊ฑฐ"""
|
| 21 |
if len(points) == 0:
|
| 22 |
return points
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
return points[(z_scores < z_thresh).all(axis=1)]
|
| 26 |
|
| 27 |
@staticmethod
|
| 28 |
def create_mesh(points: np.ndarray) -> trimesh.Trimesh:
|
| 29 |
-
"""ํฌ์ธํธ ํด๋ผ์ฐ๋์์ ๋ฉ
|
| 30 |
return trimesh.points.PointCloud(points)
|
| 31 |
|
| 32 |
@staticmethod
|
|
|
|
| 13 |
# Z-score ์ ๊ทํ
|
| 14 |
mean = np.mean(points, axis=0)
|
| 15 |
std = np.std(points, axis=0)
|
| 16 |
+
# ํ์คํธ์ฐจ๊ฐ 0์ธ ๊ฒฝ์ฐ ๋๋น
|
| 17 |
+
std = np.where(std < 1e-8, 1, std)
|
| 18 |
+
return (points - mean) / std
|
| 19 |
|
| 20 |
@staticmethod
|
| 21 |
def filter_outliers(points: np.ndarray, z_thresh=3.0) -> np.ndarray:
|
| 22 |
"""์ด์์น ์ ๊ฑฐ"""
|
| 23 |
if len(points) == 0:
|
| 24 |
return points
|
| 25 |
+
|
| 26 |
+
if len(points) <= 3: # ํฌ์ธํธ๊ฐ ๋๋ฌด ์ ์ผ๋ฉด ํํฐ๋ง ์๋ต
|
| 27 |
+
return points
|
| 28 |
+
|
| 29 |
+
z_scores = np.abs(points - np.mean(points, axis=0)) / (np.std(points, axis=0) + 1e-8)
|
| 30 |
+
mask = (z_scores < z_thresh).all(axis=1)
|
| 31 |
+
|
| 32 |
+
# ๋ชจ๋ ํฌ์ธํธ๊ฐ ํํฐ๋ง๋์ง ์๋๋ก ๋ณดํธ
|
| 33 |
+
if not np.any(mask):
|
| 34 |
+
return points
|
| 35 |
|
| 36 |
+
return points[mask]
|
|
|
|
| 37 |
|
| 38 |
@staticmethod
|
| 39 |
def create_mesh(points: np.ndarray) -> trimesh.Trimesh:
|
| 40 |
+
"""ํฌ์ธํธ ํด๋ผ์ฐ๋์์ ๋ฉ์ฌ ์์ฑ"""
|
| 41 |
return trimesh.points.PointCloud(points)
|
| 42 |
|
| 43 |
@staticmethod
|