shin0624 commited on
Commit
4fb583f
ยท
verified ยท
1 Parent(s): 1bbe3ef

Update detector/yolo_pipeline.py

Browse files
Files changed (1) hide show
  1. 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
- def process_frames(self, frame_paths):
16
  point_cloud = []
17
 
18
  for frame_idx, frame_path in enumerate(frame_paths):
19
- img = cv2.imread(frame_path)
20
- if img is None:
21
- continue
22
-
23
- results = self.model(img)[0]
24
- for box in results.boxes.xywh.cpu().numpy():
25
- cls_id = int(box[5])
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
- mesh = trimesh.points.PointCloud(np.array(point_cloud))
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