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 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
| """ 60GHz雷达CPD信号处理流程 基于TI AWRL6844的参考实现
处理步骤: 1. 数据采集(ADC) 2. 距离-多普勒FFT 3. 微多普勒特征提取 4. 生命体征检测(呼吸/心跳) 5. 目标分类(儿童/成人/物体) """
import numpy as np from scipy import signal from typing import Tuple, Dict, List
class RadarCPDProcessor: """ 60GHz雷达CPD处理器 核心功能: - 生命体征检测(呼吸0.1-0.5Hz,心跳1-2Hz) - 儿童存在检测 - 目标分类 示例: >>> processor = RadarCPDProcessor() >>> adc_data = np.random.randn(256, 128) # 模拟ADC数据 >>> result = processor.process(adc_data) >>> print(f"检测结果: {result['detection']}") >>> print(f"置信度: {result['confidence']:.2f}") """ def __init__( self, num_rx_antennas: int = 4, num_chirps: int = 128, num_samples: int = 256, range_resolution: float = 0.05, velocity_resolution: float = 0.1 ): self.num_rx = num_rx_antennas self.num_chirps = num_chirps self.num_samples = num_samples self.range_resolution = range_resolution self.velocity_resolution = velocity_resolution self.breathing_band = (0.1, 0.5) self.heartbeat_band = (1.0, 2.0) self.breathing_threshold = 0.3 self.confidence_threshold = 0.8 def range_fft(self, adc_data: np.ndarray) -> np.ndarray: """ 距离FFT(1D-FFT) 输入:[num_rx, num_chirps, num_samples] 输出:[num_rx, num_chirps, num_range_bins] """ range_fft = np.fft.fft(adc_data, axis=-1) range_fft = np.abs(range_fft) / self.num_samples return range_fft def doppler_fft(self, range_fft: np.ndarray) -> np.ndarray: """ 多普勒FFT(2D-FFT) 输入:[num_rx, num_chirps, num_range_bins] 输出:[num_rx, num_doppler_bins, num_range_bins] """ doppler_fft = np.fft.fft(range_fft, axis=1) doppler_fft = np.abs(doppler_fft) / self.num_chirps doppler_fft = np.fft.fftshift(doppler_fft, axes=1) return doppler_fft def extract_micro_doppler(self, doppler_data: np.ndarray) -> np.ndarray: """ 提取微多普勒特征(生命体征) 方法: 1. 选择包含目标的距离门 2. 对多普勒谱做时间序列分析 3. 带通滤波提取呼吸和心跳频率 输入:[num_rx, num_doppler_bins, num_range_bins] 输出:[num_time_frames] 生命体征信号 """ range_energy = np.sum(doppler_data, axis=(0, 1)) target_range_bin = np.argmax(range_energy) micro_doppler = doppler_data[:, :, target_range_bin] time_signal = np.sum(micro_doppler, axis=0) return time_signal def detect_vital_signs( self, time_signal: np.ndarray, sample_rate: float = 20.0 ) -> Tuple[float, float, Dict]: """ 检测生命体征(呼吸和心跳频率) 方法: 使用带通滤波提取特定频率范围的特征 Args: time_signal: 时间信号 sample_rate: 采样率 Returns: breathing_freq: 呼吸频率(Hz) heartbeat_freq: 心跳频率(Hz) metrics: 其他指标 """ b_breath, a_breath = signal.butter( 4, [self.breathing_band[0] / (sample_rate / 2), self.breathing_band[1] / (sample_rate / 2)], btype='band' ) b_heart, a_heart = signal.butter( 4, [self.heartbeat_band[0] / (sample_rate / 2), self.heartbeat_band[1] / (sample_rate / 2)], btype='band' ) breathing_signal = signal.filtfilt(b_breath, a_breath, time_signal) heartbeat_signal = signal.filtfilt(b_heart, a_heart, time_signal) freq = np.fft.fftfreq(len(time_signal), 1/sample_rate) breathing_spectrum = np.abs(np.fft.fft(breathing_signal)) heartbeat_spectrum = np.abs(np.fft.fft(heartbeat_signal)) pos_freq = freq[:len(freq)//2] breathing_spectrum = breathing_spectrum[:len(breathing_spectrum)//2] heartbeat_spectrum = heartbeat_spectrum[:len(heartbeat_spectrum)//2] breathing_freq = pos_freq[np.argmax(breathing_spectrum)] heartbeat_freq = pos_freq[np.argmax(heartbeat_spectrum)] breathing_power = np.max(breathing_spectrum) heartbeat_power = np.max(heartbeat_spectrum) metrics = { 'breathing_power': breathing_power, 'heartbeat_power': heartbeat_power, 'snr': (breathing_power + heartbeat_power) / (np.std(time_signal) + 1e-6) } return breathing_freq, heartbeat_freq, metrics def classify_target( self, breathing_freq: float, heartbeat_freq: float, metrics: Dict ) -> Tuple[str, float]: """ 分类目标类型 判定逻辑: 1. 生命体征频率在合理范围 → 活体 2. 信号强度 > 阈值 → 儿童 3. 其他 → 无目标/成人 Returns: target_type: 'child', 'adult', 'object', 'none' confidence: 置信度[0-1] """ has_breathing = (self.breathing_band[0] <= breathing_freq <= self.breathing_band[1]) has_heartbeat = (self.heartbeat_band[0] <= heartbeat_freq <= self.heartbeat_band[1]) if not (has_breathing or has_heartbeat): return 'object', 0.3 breathing_power = metrics['breathing_power'] heartbeat_power = metrics['heartbeat_power'] snr = metrics['snr'] if breathing_power > self.breathing_threshold and snr > 2.0: if heartbeat_freq > 1.5: return 'child', 0.9 else: return 'adult', 0.85 elif breathing_power > 0.1: return 'child', 0.7 else: return 'object', 0.4 def process(self, adc_data: np.ndarray) -> Dict: """ 完整处理流程 Args: adc_data: [num_rx, num_chirps, num_samples] ADC数据 Returns: result: 包含检测结果、置信度、生命体征等信息的字典 """ range_fft = self.range_fft(adc_data) doppler_fft = self.doppler_fft(range_fft) micro_doppler = self.extract_micro_doppler(doppler_fft) breathing_freq, heartbeat_freq, metrics = self.detect_vital_signs(micro_doppler) target_type, confidence = self.classify_target( breathing_freq, heartbeat_freq, metrics ) result = { 'detection': target_type in ['child', 'adult'], 'target_type': target_type, 'confidence': confidence, 'breathing_freq': breathing_freq, 'heartbeat_freq': heartbeat_freq, 'metrics': metrics, 'range_fft': range_fft, 'doppler_fft': doppler_fft } return result
if __name__ == "__main__": processor = RadarCPDProcessor( num_rx_antennas=4, num_chirps=128, num_samples=256 ) num_rx, num_chirps, num_samples = 4, 128, 256 t = np.linspace(0, 1, num_chirps) breathing = 0.5 * np.sin(2 * np.pi * 0.3 * t) heartbeat = 0.2 * np.sin(2 * np.pi * 1.5 * t) adc_data = np.zeros((num_rx, num_chirps, num_samples)) for i in range(num_rx): adc_data[i] = ( np.outer(breathing + heartbeat, np.ones(num_samples)) + 0.1 * np.random.randn(num_chirps, num_samples) ) result = processor.process(adc_data) print("=" * 60) print("60GHz雷达CPD检测结果") print("=" * 60) print(f"检测结果: {result['target_type']}") print(f"置信度: {result['confidence']:.2f}") print(f"呼吸频率: {result['breathing_freq']:.2f} Hz") print(f"心跳频率: {result['heartbeat_freq']:.2f} Hz") print(f"信噪比: {result['metrics']['snr']:.2f}") if result['detection'] and result['confidence'] >= 0.8: print("\n✅ 满足Euro NCAP CPD检测要求") else: print("\n⚠️ 未达到Euro NCAP要求,需要优化")
|