首页 > 解决方案 > picamera:捕捉黑色图像

问题描述

我正在尝试使用我的 RaspiCam v2 捕获图像。我有一个非常具体的设置,并指定了获得良好图像质量所需的所有相机参数。我使用单独的 python 脚本用以下行捕获图像来计算它们: camera.capture('filename.jpg').

在我的实际程序中,我想不直接将图像捕获到文件中,而是作为BytesIO()流捕获。即使我保持所有参数相同,我也只得到黑色图像。

这是我的代码:

if self.camera is not None:
            buffer = BytesIO()
            self.camera.shutter_speed = shutter_speed_ms
            self.camera.iso = iso
            self.camera.resolution = resolution
            self.camera.brightness = brightness
            self.camera.contrast = contrast
            self.camera.sharpness = sharpness
            self.camera.saturation = saturation
            self.camera.awb_mode = awb_mode

            self.camera.capture(buffer, "jpeg")
            buffer.seek(0)
        else:
            raise RuntimeError("capture instance does not exist.")

捕获到文件或捕获到流时,相机参数之间是否存在差异?

标签: pythonraspberry-pipicamera

解决方案


推荐阅读