# -*- coding: utf-8 -*- import cv2 import numpy as np def auto_exposure_adjust(frame, current_exp): """ 根据画面亮度自动降低曝光 Args: frame: BGR格式的图像 current_exp: 当前曝光时间(微秒) Returns: new_exp: 新的曝光时间(微秒) adjusted: 是否进行了调整 """ mean_val = np.mean(cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)) if mean_val > 250 and current_exp > 1000: new_exp = max(100, current_exp * 0.8) # 降低20% return int(new_exp), True return current_exp, False