1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| class OOPDetection: """ 使用AF0130深度数据进行OOP检测 优势: 1. 深度信息直接获取(无需立体视觉估计) 2. 全局快门适合运动姿态 3. 穿透衣物检测(配合IR) """ def __init__(self): self.depth_resolution = (1280, 960) self.fov = (65, 50) def detect_posture(self, depth_map): """ 从深度图检测乘员姿态 Args: depth_map: 深度图 (1280x960) Returns: posture: 姿态分类 """ seat_region = self._segment_seat(depth_map) silhouette = self._extract_silhouette(depth_map, seat_region) keypoints = self._estimate_keypoints(depth_map, silhouette) posture = self._classify_posture(keypoints) return posture def _classify_posture(self, kp): """基于关键点深度分类姿态""" head_z = kp.get("head", {}).get("z", 0) shoulder_z = kp.get("shoulder", {}).get("z", 0) hip_z = kp.get("hip", {}).get("z", 0) if head_z < shoulder_z - 0.15: return {"posture": "forward_lean", "severity": "moderate"} elif head_z < shoulder_z - 0.30: return {"posture": "forward_lean", "severity": "severe"} if abs(kp.get("head", {}).get("x", 0) - hip_z) > 0.3: return {"posture": "side_lean", "severity": "moderate"} return {"posture": "normal", "severity": "none"}
|