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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
| """ NVIDIA Omniverse Replicator 座舱数据合成管线 参考: NVIDIA Omniverse + Cosmos 工具链
生成内容: - 驾驶员行为图像 (分心/疲劳/正常) - 带标注: 2D BBox, 语义分割, 深度图, 关键点 - 场景随机化: 光照/角度/服装/姿势
运行方式: Isaac Sim / Omniverse Kit / Cloud API """
class CabinDataGenerator: """ 座舱合成数据生成器 目标: 生成 10,000+ 张带标注的驾驶员行为图像 用于: IMS DMS 模型训练 """ BEHAVIORS = [ 'normal_driving', 'phone_call', 'phone_text', 'eating', 'drinking', 'smoking', 'drowsy', 'looking_left', 'looking_right', 'reaching_passenger', 'adjusting_radio', 'talking_passenger', 'yawning', ] def __init__(self, num_samples=10000): self.num_samples = num_samples self.output_path = "/data/cabin_synth" def generate(self): """生成完整数据集""" for i in range(self.num_samples): behavior = np.random.choice(self.BEHAVIORS) params = self._randomize_params(behavior) self._setup_scene(params) data = self._render_and_annotate() self._save_sample(i, behavior, data) def _randomize_params(self, behavior): """随机化场景参数""" return { 'sun_angle': np.random.uniform(0, 360), 'sun_intensity': np.random.uniform(100, 1000), 'interior_light': np.random.uniform(50, 200), 'tunnel_mode': np.random.random() < 0.1, 'cam_position': self._random_cam_pos(), 'cam_fov': np.random.uniform(60, 90), 'cam_resolution': (1920, 1200), 'metahuman_id': np.random.randint(0, 50), 'clothing': np.random.choice(['casual', 'formal', 'winter']), 'glasses': np.random.random() < 0.3, 'hat': np.random.random() < 0.1, 'behavior': behavior, 'head_pose': self._behavior_head_pose(behavior), 'hand_position': self._behavior_hand_pose(behavior), 'gaze_direction': self._behavior_gaze(behavior), 'eye_openness': self._behavior_eye(behavior), 'vehicle_type': np.random.choice(['sedan', 'suv', 'truck']), 'time_of_day': np.random.choice(['day', 'sunset', 'night']), 'weather': np.random.choice(['clear', 'cloudy', 'rain']), } def _random_cam_pos(self): """随机相机位置 (方向盘上方)""" return { 'x': np.random.uniform(-0.1, 0.1), 'y': np.random.uniform(0.3, 0.5), 'z': np.random.uniform(1.1, 1.3), 'roll': np.random.uniform(-5, 5), 'pitch': np.random.uniform(-10, 10), 'yaw': np.random.uniform(-5, 5), } def _behavior_head_pose(self, behavior): """行为对应头部姿态""" poses = { 'normal_driving': (0, 0, 0), 'phone_call': (15, -20, 5), 'phone_text': (25, -30, 10), 'eating': (20, -15, 0), 'drinking': (15, -10, 0), 'smoking': (10, -15, -5), 'drowsy': (5, 0, 0), 'looking_left': (0, 30, 0), 'looking_right': (0, -30, 0), 'reaching_passenger': (20, 40, 15), 'adjusting_radio': (10, -25, 0), 'talking_passenger': (5, 20, 0), 'yawning': (10, 0, 0), } base = poses.get(behavior, (0, 0, 0)) return tuple(b + np.random.uniform(-3, 3) for b in base) def _behavior_hand_pose(self, behavior): """行为对应手部位置""" return { 'normal_driving': 'steering_wheel', 'phone_call': 'right_ear', 'phone_text': 'lower_left', 'eating': 'mouth', 'drinking': 'mouth', 'smoking': 'mouth', 'drowsy': 'lap', 'adjusting_radio': 'center_console', }.get(behavior, 'steering_wheel') def _behavior_gaze(self, behavior): """行为对应视线方向""" return { 'normal_driving': (0, -5, 0), 'phone_call': (15, -25, 5), 'phone_text': (25, -35, 10), 'drowsy': (5, 0, 0), 'looking_left': (0, 35, 0), 'looking_right': (0, -35, 0), }.get(behavior, (0, 0, 0)) def _behavior_eye(self, behavior): """行为对应眼部状态""" if behavior == 'drowsy': return np.random.uniform(0.1, 0.3) elif behavior == 'yawning': return np.random.uniform(0.2, 0.4) else: return np.random.uniform(0.6, 1.0) def _setup_scene(self, params): """构建 Omniverse 场景""" pass def _render_and_annotate(self): """渲染并采集标注""" return { 'image': None, 'bbox': None, 'seg': None, 'depth': None, 'normals': None, } def _save_sample(self, idx, behavior, data): """保存样本""" import json import os sample_dir = os.path.join(self.output_path, f"{idx:06d}") os.makedirs(sample_dir, exist_ok=True) annotation = { 'id': idx, 'behavior': behavior, 'bbox': data['bbox'], 'segmentation': data['seg'], } with open(os.path.join(sample_dir, 'labels.json'), 'w') as f: json.dump(annotation, f)
class DataQualityComparison: """合成数据 vs 真实数据质量对比""" COMPARISON = { '数据量': { '真实采集': '10K-50K帧', '合成生成': '100K-1M帧', '优势': '合成(10-20x)' }, '标注成本': { '真实采集': '$0.5-2/帧 (人工)', '合成生成': '$0 (自动)', '优势': '合成' }, '多样性': { '真实采集': '受限于采集条件', '合成生成': '无限组合', '优势': '合成' }, '真实性': { '真实采集': '100%真实分布', '合成生成': '85-95% (domain gap)', '优势': '真实' }, '极端场景': { '真实采集': '危险/罕见场景难获取', '合成生成': '任意生成', '优势': '合成' }, '隐私': { '真实采集': '需知情同意', '合成生成': '无隐私问题', '优势': '合成' }, '时间成本': { '真实采集': '数月采集+标注', '合成生成': '数小时生成', '优势': '合成' }, }
if __name__ == "__main__": print("=" * 60) print("Omniverse 座舱合成数据生成器") print("=" * 60) gen = CabinDataGenerator(num_samples=10000) for behavior in ['normal_driving', 'phone_text', 'drowsy']: params = gen._randomize_params(behavior) print(f"\n行为: {behavior}") print(f" 头部姿态: {params['head_pose']}") print(f" 手部位置: {params['hand_position']}") print(f" 视线方向: {params['gaze_direction']}") print(f" 眼部开度: {params['eye_openness']:.2f}") print(f" 光照: {params['sun_intensity']:.0f} lux") print(f" 时段: {params['time_of_day']}") print("\n" + "=" * 60) print("合成 vs 真实数据对比") print("=" * 60) comp = DataQualityComparison() for dim, values in comp.COMPARISON.items(): print(f"\n{dim}:") print(f" 真实: {values['真实采集']}") print(f" 合成: {values['合成生成']}") print(f" 优势: {values['优势']}")
|