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
| class MultiViewSpaceChannelFusion: """ 多视角空间通道特征融合 """ def __init__(self): self.views = ['front', 'side', 'rear'] self.channels = ['gaze_x', 'gaze_y', 'pupil_size', 'blink_rate'] def extract_spatial_features(self, gaze_data): """ 提取空间特征 """ features = { 'gaze_dispersion': 0, 'fixation_duration': 0, 'saccade_amplitude': 0, 'scan_pattern': None } gaze_points = gaze_data['gaze_points'] features['gaze_dispersion'] = self.compute_dispersion(gaze_points) features['fixation_duration'] = self.compute_fixation_duration(gaze_points) features['saccade_amplitude'] = self.compute_saccade_amplitude(gaze_points) features['scan_pattern'] = self.identify_scan_pattern(gaze_points) return features def extract_temporal_features(self, gaze_data): """ 提取时序特征 """ features = { 'prc': 0, 'blink_frequency': 0, 'gaze_velocity': 0, 'rhythmicity': 0 } features['prc'] = self.compute_prc(gaze_data['pupil_size']) features['blink_frequency'] = self.compute_blink_frequency(gaze_data['blink_events']) features['gaze_velocity'] = self.compute_gaze_velocity(gaze_data['gaze_points']) features['rhythmicity'] = self.compute_rhythmicity(gaze_data['gaze_points']) return features def extract_channel_features(self, gaze_data): """ 提取通道特征 """ features = {} for channel in self.channels: if channel in gaze_data: features[channel] = { 'mean': np.mean(gaze_data[channel]), 'std': np.std(gaze_data[channel]), 'max': np.max(gaze_data[channel]), 'min': np.min(gaze_data[channel]) } return features def fuse_features(self, spatial, temporal, channel): """ 融合特征 """ spatial_flat = self.flatten_features(spatial) temporal_flat = self.flatten_features(temporal) channel_flat = self.flatten_features(channel) fused = np.concatenate([spatial_flat, temporal_flat, channel_flat]) selected = self.feature_selection(fused) return selected
|