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
| """ 认知分心检测系统
多指标融合判断 """
class CognitiveDistractionDetector: """ 认知分心检测器 """ def __init__(self): self.baseline = { 'fixation_duration_mean': 400.0, 'fixation_duration_std': 100.0, 'saccade_amplitude_mean': 8.0, 'saccade_amplitude_std': 3.0, 'scanpath_regularity': 0.6 } self.window_size = 10.0 def detect( self, gaze_points: np.ndarray, timestamps: np.ndarray ) -> dict: """ 检测认知分心 Args: gaze_points: (N, 2) 视线点序列 timestamps: (N,) 时间戳序列 Returns: { 'is_distracted': bool, 'fixation_score': float, 'saccade_score': float, 'regularity_score': float, 'confidence': float } """ fixation_durations = calculate_fixation_duration(gaze_points, timestamps) saccade_amplitudes = calculate_saccade_amplitude(gaze_points, timestamps) regularity = calculate_scanpath_regularity(gaze_points) fixation_mean = np.mean(fixation_durations) fixation_score = 1 - fixation_mean / self.baseline['fixation_duration_mean'] saccade_mean = np.mean(saccade_amplitudes) saccade_score = 1 - saccade_mean / self.baseline['saccade_amplitude_mean'] regularity_score = 1 - regularity / self.baseline['scanpath_regularity'] combined_score = (fixation_score + saccade_score + regularity_score) / 3 is_distracted = combined_score > 0.25 return { 'is_distracted': is_distracted, 'fixation_score': fixation_score, 'saccade_score': saccade_score, 'regularity_score': regularity_score, 'confidence': abs(combined_score) }
|