Spaces:
Sleeping
Sleeping
Update detector/yolo_pipeline.py
Browse files- detector/yolo_pipeline.py +10 -17
detector/yolo_pipeline.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from ultralytics import YOLO
|
|
|
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
| 4 |
import trimesh
|
|
@@ -12,24 +13,16 @@ class YOLO3DReconstructor:
|
|
| 12 |
63: 'conveyor' # ์ปค์คํ
๋งคํ (COCO์๋ ์์)
|
| 13 |
}
|
| 14 |
|
| 15 |
-
|
| 16 |
point_cloud = []
|
| 17 |
|
| 18 |
for frame_idx, frame_path in enumerate(frame_paths):
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
if cls_id in self.class_mapping:
|
| 27 |
-
x, y, w, h = box[:4]
|
| 28 |
-
# ๊ฐ๋จํ 3D ๋ณํ (ํ๋ ์ ์ธ๋ฑ์ค๋ฅผ Z์ถ์ผ๋ก ์ฌ์ฉ)
|
| 29 |
-
point_cloud.append([x, y, frame_idx * 50])
|
| 30 |
-
|
| 31 |
-
if not point_cloud:
|
| 32 |
-
return None
|
| 33 |
|
| 34 |
-
|
| 35 |
-
return mesh
|
|
|
|
| 1 |
from ultralytics import YOLO
|
| 2 |
+
from utils.pointcloud_tools import PointCloudProcessor # ์ถ๊ฐ
|
| 3 |
import cv2
|
| 4 |
import numpy as np
|
| 5 |
import trimesh
|
|
|
|
| 13 |
63: 'conveyor' # ์ปค์คํ
๋งคํ (COCO์๋ ์์)
|
| 14 |
}
|
| 15 |
|
| 16 |
+
def process_frames(self, frame_paths):
|
| 17 |
point_cloud = []
|
| 18 |
|
| 19 |
for frame_idx, frame_path in enumerate(frame_paths):
|
| 20 |
+
# ... ๊ฐ์ฒด ๊ฐ์ง ์ฝ๋ ...
|
| 21 |
+
|
| 22 |
+
# ํฌ์ธํธ ํด๋ผ์ฐ๋ ํ์ฒ๋ฆฌ ์ถ๊ฐ
|
| 23 |
+
if point_cloud:
|
| 24 |
+
points = np.array(point_cloud)
|
| 25 |
+
points = PointCloudProcessor.filter_outliers(points)
|
| 26 |
+
points = PointCloudProcessor.normalize_points(points)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
return PointCloudProcessor.create_mesh(points) if len(points) > 0 else None
|
|
|