Skip to main content
 首页 » 编程设计

python之PiCamera 图片不一致

2025年01月19日13tuyile006

我正在使用带有摄像头模块(Raspberry pi Camera)的 Raspberry pi 无人机安装在无人机上,并编程为在固定间隔后拍照。然而,图像似乎有点不一致,如下所示 .

与其他图片相比,图片 4 和图片 8 的“色彩”略多一些,饱和度也更高。但是,由于默认饱和度为 0 并且我的代码没有更改它,所以我相信这是另外一回事。我的 python 脚本如下所示

def calibrate(t): 
    with picamera.PiCamera() as camera: 
       time.sleep(t) 
       camera.shutter_speed = camera.exposure_speed 
       ss=camera.shutter_speed 
       camera.still_stats = 'true' 
       camera.exposure_mode = 'off' 
       g = camera.awb_gains 
       camera.awb_mode = 'off' 
       camera.awb_gains = g 
       camera.close() 
       return ss,g 
 
def capture(ss,g,stream): 
    with picamera.PiCamera() as camera:            
       camera.resolution = (3280,2464)        
       camera.shutter_speed = ss 
       camera.still_stats 
       camera.exposure_mode = 'off' 
       camera.awb_mode = 'off' 
       camera.awb_gains = g 
       camera.still_stats = 'true' 
       camera.capture(stream,format='jpeg') 
       camera.close() 

我在拍摄校准相机的任何照片之前调用校准函数。校准后,我拍照并遇到了这个问题。有谁知道如何解决这个问题?

请您参考如下方法:

来自 the docs :

Enabling the still statistics pass will override fixed white balance gains (set via awb_gains and awb_mode).

我敢打赌,当您更改 still_stats 时,awb_mode 会设置回 off 以外的值。似乎报告了完全相同的问题 here .