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
| """ 多模态认知负荷融合 """ class CognitiveLoadFusion: """ 多模态认知负荷评估 输入模态: 1. 瞳孔直径 (DMS IR) 2. 眨眼模式 (DMS) 3. rPPG心率变异 (DMS RGB) 4. 驾驶行为 (CAN总线) 输出: - cognitive_load: 0-100 - level: low/medium/high/overload - recommendation: 交互策略建议 """ def __init__(self): self.weights = { 'pupil': 0.25, 'blink': 0.20, 'hrv': 0.25, 'behavior': 0.30 } def assess(self, metrics: dict) -> dict: pupil_load = metrics.get('pupil_load', 50) blink_rate = metrics.get('blink_rate', 15) blink_duration = metrics.get('blink_duration', 0.1) if blink_rate < 8 or blink_duration < 0.05: blink_load = 80 elif blink_rate < 12: blink_load = 60 else: blink_load = 30 hrv = metrics.get('hrv', 50) if hrv < 30: hrv_load = 80 elif hrv < 50: hrv_load = 60 else: hrv_load = 30 steering_entropy = metrics.get('steering_entropy', 0.3) lane_deviation = metrics.get('lane_deviation', 0.2) behavior_load = int(min(100, (steering_entropy * 100 + lane_deviation * 100) / 2)) total = (pupil_load * self.weights['pupil'] + blink_load * self.weights['blink'] + hrv_load * self.weights['hrv'] + behavior_load * self.weights['behavior']) if total >= 80: level = 'overload' recommendation = 'minimize_UI + voice_only + delay_non_critical' elif total >= 60: level = 'high' recommendation = 'simplify_HUD + audio_only + delay_media' elif total >= 40: level = 'medium' recommendation = 'normal + monitor' else: level = 'low' recommendation = 'normal_interaction' return { 'cognitive_load': round(total, 1), 'level': level, 'recommendation': recommendation, 'component_scores': { 'pupil': pupil_load, 'blink': blink_load, 'hrv': hrv_load, 'behavior': behavior_load } }
if __name__ == "__main__": fusion = CognitiveLoadFusion() result = fusion.assess({ 'pupil_load': 20, 'blink_rate': 18, 'blink_duration': 0.12, 'hrv': 55, 'steering_entropy': 0.2, 'lane_deviation': 0.15 }) print(f"正常: load={result['cognitive_load']}, level={result['level']}") print(f" 建议: {result['recommendation']}") result = fusion.assess({ 'pupil_load': 75, 'blink_rate': 8, 'blink_duration': 0.06, 'hrv': 25, 'steering_entropy': 0.6, 'lane_deviation': 0.4 }) print(f"\n高负荷: load={result['cognitive_load']}, level={result['level']}") print(f" 建议: {result['recommendation']}")
|