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
| class EuroNCAPScenarioGenerator: """ Euro NCAP场景生成器 """ def __init__(self): self.anyverse = AnyverseDataGenerator() self.scenarios = { 'distraction': [ {'type': 'phone_use', 'duration': 3}, {'type': 'radio_tuning', 'duration': 2}, {'type': 'side_window', 'duration': 2}, {'type': 'reading', 'duration': 4}, {'type': 'eating', 'duration': 3} ], 'fatigue': [ {'level': 'mild', 'perclos': 0.15}, {'level': 'moderate', 'perclos': 0.3}, {'level': 'severe', 'perclos': 0.5} ], 'cpd': [ {'age': 1, 'location': 'rear_left'}, {'age': 3, 'location': 'rear_right'}, {'age': 6, 'location': 'footwell'}, {'age': 0, 'location': 'child_seat'} ], 'oop': [ {'pose': 'forward', 'angle': 30}, {'pose': 'forward', 'angle': 45}, {'pose': 'side', 'angle': 45}, {'pose': 'reclined', 'angle': 60} ] } def generate_full_dataset(self): """ 生成完整数据集 """ full_dataset = {} for category, scenarios in self.scenarios.items(): category_data = [] for scenario in scenarios: for angle in [-15, 0, 15]: for lighting in ['day', 'night', 'sunset']: scenario['camera_angle'] = angle scenario['lighting'] = lighting data = self.anyverse.generate_dms_dataset( scenario, num_samples=100 ) category_data.extend(data) full_dataset[category] = category_data return full_dataset
|