python - 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.")
捕获到文件或捕获到流时,相机参数之间是否存在差异?
解决方案
推荐阅读
- java - 在Java中使用子字符串删除部分字符串
- python - 来自邻接矩阵的 Gurobi、python 和 tsp
- elasticsearch - Elasticsearch没有multi_match的结果
- react-native - 将照片从 React Native 应用程序上传到 Strapi api
- matlab - Matlab:用名称保存文件
- postgresql - 在 postgresql 中修改 UNIQUE
- r - 加密R中的输入文本
- python - 给定两个长度相同的 NumPy 数组 x 和 y,我如何选择所有对 (x,y) 以使 x 介于 x_min 和 x_max 之间?
- kubernetes - Kubernetes Helm 卡在正在进行的更新中
- r - 堆积面积累积和图