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
| class CPDScenarioGenerator: """ CPD儿童存在检测场景生成器 Euro NCAP 2026要求 """ CPD_SCENARIOS = { 'CPD-01': { 'name': '婴儿后向座椅', 'occupant_type': 'infant', 'seat_type': 'rear_facing_car_seat', 'age_months': [0, 6, 12], 'locations': ['rear_left', 'rear_right', 'front_passenger'] }, 'CPD-02': { 'name': '幼儿前向座椅', 'occupant_type': 'toddler', 'seat_type': 'forward_facing_car_seat', 'age_months': [12, 24, 36], 'locations': ['rear_left', 'rear_right'] }, 'CPD-03': { 'name': '儿童增高座椅', 'occupant_type': 'child', 'seat_type': 'booster_seat', 'age_years': [4, 6, 8], 'locations': ['rear_left', 'rear_right'] }, 'CPD-04': { 'name': '儿童单独后排', 'occupant_type': 'child', 'seat_type': 'none', 'age_years': [6, 8, 10], 'locations': ['rear_left', 'rear_right', 'rear_center'] }, 'CPD-05': { 'name': '宠物检测', 'occupant_type': 'pet', 'pet_type': ['dog_small', 'dog_large', 'cat'], 'locations': ['rear_seat', 'front_passenger'] }, 'CPD-06': { 'name': '空座', 'occupant_type': 'none', 'locations': ['all_seats'] } } def generate_cpd_multimodal( self, scenario_id: str, num_samples: int ) -> dict: """ 生成CPD多模态数据集 包含:RGB + IR + Radar """ scenario = self.CPD_SCENARIOS[scenario_id] dataset = { 'scenario_id': scenario_id, 'samples': [], 'modalities': ['rgb', 'ir', 'radar'] } for i in range(num_samples): sample = { 'sample_id': f"{scenario_id}_{i:05d}", 'rgb': { 'image_path': f"rgb/{scenario_id}_{i:05d}.png", 'resolution': [1920, 1080] }, 'ir': { 'image_path': f"ir/{scenario_id}_{i:05d}.png", 'wavelength_nm': 940, 'resolution': [640, 480] }, 'radar': { 'data_path': f"radar/{scenario_id}_{i:05d}.npy", 'type': 'range_doppler', 'config': { 'frequency_ghz': 60, 'num_chirps': 128, 'num_samples': 256 } }, 'annotations': { 'occupant_type': scenario['occupant_type'], 'location': np.random.choice(scenario.get('locations', ['rear_seat'])), 'vital_signs': self._simulate_vital_signs(scenario), 'bounding_box_3d': self._generate_3d_bbox(scenario) } } dataset['samples'].append(sample) return dataset def _simulate_vital_signs(self, scenario: dict) -> dict: """模拟生命体征""" if scenario['occupant_type'] == 'none': return {'heart_rate': 0, 'breathing_rate': 0} if 'age_months' in scenario: age_months = np.random.choice(scenario['age_months']) heart_rate = np.random.uniform(100, 160) if age_months < 12 else np.random.uniform(80, 120) breathing_rate = np.random.uniform(25, 40) if age_months < 12 else np.random.uniform(18, 30) elif 'age_years' in scenario: heart_rate = np.random.uniform(70, 100) breathing_rate = np.random.uniform(16, 25) else: heart_rate = np.random.uniform(60, 100) breathing_rate = np.random.uniform(12, 20) return { 'heart_rate': heart_rate, 'breathing_rate': breathing_rate, 'confidence': np.random.uniform(0.8, 1.0) } def _generate_3d_bbox(self, scenario: dict) -> dict: """生成3D边界框""" return { 'center': {'x': 0.5, 'y': 1.0, 'z': 0.4}, 'size': {'x': 0.3, 'y': 0.5, 'z': 0.6}, 'rotation': {'yaw': 0, 'pitch': 0, 'roll': 0} }
|