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
| class CPD_Detector: """ 儿童遗留检测(CPD)模块 使用 60GHz FMCW 雷达检测: - 呼吸运动(胸腔起伏) - 心跳运动 - 微小位移 """ def __init__(self, radar_config): self.radar = FMCWRadar(radar_config) self.breathing_detector = BreathingDetector() self.heartbeat_detector = HeartbeatDetector() def detect_child_presence(self, radar_frames): """ 检测儿童遗留 Args: radar_frames: 雷达帧数据(多帧累积) Returns: detection: { 'child_detected': bool, 'location': (x, y, z), 'vital_signs': { 'breathing_rate': int, # 呼吸频率(次/分) 'heart_rate': int # 心率(次/分) }, 'confidence': float } """ range_profile = self._range_fft(radar_frames) doppler_profile = self._doppler_fft(radar_frames) micro_motion = self._detect_micro_motion(doppler_profile) breathing_rate = self.breathing_detector.extract(micro_motion) heart_rate = self.heartbeat_detector.extract(micro_motion) child_detected = False if breathing_rate > 0: child_detected = True return { 'child_detected': child_detected, 'vital_signs': { 'breathing_rate': breathing_rate, 'heart_rate': heart_rate }, 'confidence': 0.95 } def _range_fft(self, frames): """ Range FFT 将时域信号转换为距离维信息 """ range_fft = np.fft.fft(frames, axis=-1) return np.abs(range_fft) def _doppler_fft(self, frames): """ Doppler FFT 将多帧数据进行 FFT,提取速度信息 """ doppler_fft = np.fft.fft(frames, axis=0) return np.abs(doppler_fft) def _detect_micro_motion(self, doppler_profile): """ 检测微动(呼吸、心跳) 呼吸:胸腔起伏 ~0.5-2mm,频率 12-30 次/分 心跳:胸壁振动 ~0.1-0.5mm,频率 60-150 次/分 """ low_doppler = doppler_profile[:10, :] time_signal = np.mean(low_doppler, axis=0) return time_signal
|