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
| class TI_CPD_Algorithm: """ TI CPD算法 基于60GHz雷达的儿童存在检测 """ def __init__(self): self.detection_params = { 'presence_threshold': -60, 'movement_threshold': 0.05, 'breathing_threshold': 0.02, 'scan_interval': 1, 'confirmation_time': 15 } def detect_child(self, radar_data): """ 检测儿童 Args: radar_data: 雷达原始数据 Returns: result: { 'child_present': bool, 'position': (range, azimuth, elevation), 'vital_signs': {'breathing_rate': float}, 'confidence': float } """ point_cloud = self.generate_point_cloud(radar_data) moving_targets = self.detect_movement(point_cloud) vital_signs = self.extract_vital_signs(point_cloud) classification = self.classify_target( moving_targets, vital_signs ) result = { 'child_present': classification['type'] == 'child', 'position': moving_targets[0]['position'] if moving_targets else None, 'vital_signs': vital_signs, 'confidence': classification['confidence'] } return result def extract_vital_signs(self, point_cloud): """ 提取生命体征(呼吸、心跳) 使用多普勒频移分析 """ phase_sequence = self.extract_phase(point_cloud) spectrum = np.fft.fft(phase_sequence) frequencies = np.fft.fftfreq(len(phase_sequence), 1/self.frame_rate) breathing_band = (frequencies >= 0.1) & (frequencies <= 0.5) breathing_spectrum = np.abs(spectrum[breathing_band]) breathing_rate = frequencies[breathing_band][np.argmax(breathing_spectrum)] heartbeat_band = (frequencies >= 0.8) & (frequencies <= 2.0) heartbeat_spectrum = np.abs(spectrum[heartbeat_band]) heartbeat_rate = frequencies[heartbeat_band][np.argmax(heartbeat_spectrum)] return { 'breathing_rate': breathing_rate * 60, 'heartbeat_rate': heartbeat_rate * 60 }
|