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
| import numpy as np
class TI60GHzCPD: """ TI 60GHz雷达CPD检测 检测流程: 1. FMCW Chirp配置 2. 距离-多普勒FFT 3. 静态杂波去除 4. 目标检测(CFAR) 5. 生命体征提取 6. 儿童/成人分类 """ def __init__(self): self.config = TI60GHzRadarConfig() self.breathing_freq_range = (0.2, 0.5) self.child_breathing_freq = (0.4, 0.5) self.adult_breathing_freq = (0.2, 0.33) def process_radar_frame(self, adc_data: np.ndarray) -> dict: """ 处理单帧雷达数据 Args: adc_data: ADC数据, shape=(num_chirps, num_rx, num_adc_samples) Returns: result: {"detections", "vital_signs"} """ num_chirps, num_rx, num_adc = adc_data.shape range_fft = np.fft.fft(adc_data, axis=2) range_doppler = np.fft.fft(range_fft, axis=0) range_doppler_dynamic = self._remove_static_clutter(range_doppler) detections = self._cfar_detection(range_doppler_dynamic) vital_signs = self._extract_vital_signs(adc_data, detections) return { "detections": detections, "vital_signs": vital_signs } def _remove_static_clutter(self, range_doppler: np.ndarray) -> np.ndarray: """去除静态杂波""" mean_doppler = np.mean(range_doppler, axis=0, keepdims=True) range_doppler_dynamic = range_doppler - mean_doppler return range_doppler_dynamic def _cfar_detection(self, range_doppler: np.ndarray, threshold_factor: float = 3.0) -> list: """CFAR目标检测""" power = np.abs(range_doppler) ** 2 mean_power = np.mean(power) threshold = mean_power * threshold_factor detections = [] above_threshold = power > threshold for r_idx in range(power.shape[1]): for d_idx in range(power.shape[0]): if above_threshold[d_idx, r_idx]: detections.append({ "range_idx": r_idx, "doppler_idx": d_idx, "power": power[d_idx, r_idx] }) return detections def _extract_vital_signs(self, adc_data: np.ndarray, detections: list) -> dict: """提取生命体征""" phase = np.angle(adc_data[:, 0, :]) phase_diff = np.diff(phase, axis=0) spectrum = np.fft.fft(phase_diff, axis=0) freq = np.fft.fftfreq(phase_diff.shape[0], d=1/100) freq_mask = (freq >= self.breathing_freq_range[0]) & \ (freq <= self.breathing_freq_range[1]) breathing_spectrum = np.abs(spectrum[freq_mask, :]) breathing_freq = freq[freq_mask][np.argmax(np.mean(breathing_spectrum, axis=1))] breathing_rate = breathing_freq * 60 if breathing_rate > 24: target_type = "child" else: target_type = "adult" return { "breathing_rate": breathing_rate, "target_type": target_type, "confidence": 0.85 } def detect_child_presence(self, vital_signs: dict) -> dict: """ 检测儿童存在 Euro NCAP 2026要求: - 检测儿童年龄:0-6岁 - 呼吸频率:新生儿30bpm → 6岁18bpm Args: vital_signs: 生命体征 Returns: result: {"presence", "type", "breathing_rate"} """ if vital_signs.get("target_type") == "child": return { "presence": True, "type": "child", "breathing_rate": vital_signs["breathing_rate"], "confidence": vital_signs["confidence"] } else: return { "presence": True, "type": "adult", "breathing_rate": vital_signs["breathing_rate"], "confidence": vital_signs["confidence"] }
if __name__ == "__main__": cpd = TI60GHzCPD() num_chirps = 128 num_rx = 4 num_adc = 256 adc_data = np.random.randn(num_chirps, num_rx, num_adc) print("=== CPD检测流程 ===") result = cpd.process_radar_frame(adc_data) print(f"检测目标数: {len(result['detections'])}") print(f"生命体征: {result['vital_signs']}") child_result = cpd.detect_child_presence(result['vital_signs']) print(f"\n儿童存在: {child_result['presence']}") print(f"类型: {child_result['type']}") print(f"呼吸频率: {child_result['breathing_rate']:.1f} bpm")
|