shin0624 commited on
Commit
fdca661
ยท
verified ยท
1 Parent(s): 58b4ac9

Update detector/yolo_pipeline.py

Browse files
Files changed (1) hide show
  1. detector/yolo_pipeline.py +20 -4
detector/yolo_pipeline.py CHANGED
@@ -13,16 +13,32 @@ class YOLO3DReconstructor:
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
 
 
 
 
 
 
 
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
+ img = cv2.imread(frame_path)
21
+ if img is None:
22
+ continue
23
+
24
+ results = self.model(img)[0]
25
+ for box in results.boxes.xywh.cpu().numpy():
26
+ cls_id = int(box[5])
27
+ if cls_id in self.class_mapping:
28
+ x, y, w, h = box[:4]
29
+ # ๊ฐ„๋‹จํ•œ 3D ๋ณ€ํ™˜ (ํ”„๋ ˆ์ž„ ์ธ๋ฑ์Šค๋ฅผ Z์ถ•์œผ๋กœ ์‚ฌ์šฉ)
30
+ point_cloud.append([x, y, frame_idx * 50])
31
+
32
  # ํฌ์ธํŠธ ํด๋ผ์šฐ๋“œ ํ›„์ฒ˜๋ฆฌ ์ถ”๊ฐ€
33
  if point_cloud:
34
  points = np.array(point_cloud)
35
  points = PointCloudProcessor.filter_outliers(points)
36
  points = PointCloudProcessor.normalize_points(points)
37
 
38
+ return PointCloudProcessor.create_mesh(points) if len(points) > 0 else None
39
+
40
+ if not point_cloud:
41
+ return None
42
+
43
+ mesh = trimesh.points.PointCloud(np.array(point_cloud))
44
+ return mesh