【发布时间】:2016-06-20 15:24:15
【问题描述】:
我正在尝试将 MS Lifecam 与我的 raspberry-pi-3 一起使用。当我键入以下命令时,它可以在命令行上运行:
$ fswebcam img.jpg
Trying source module v4l2...
/dev/video0 opened.
...
Writing JPEG image to 'img.jpg' # this works fine
现在我想通过 python 代码运行相机:
import pygame
import pygame.camera
from pygame.locals import *
DEVICE = '/dev/video0'
SIZE = (640, 480) # I also tried with img size (384,288), same error
FILENAME = 'capture.jpg'
pygame.init()
pygame.camera.init()
camera = pygame.camera.Camera(DEVICE, SIZE)
camera.start() # error on executing this line
pygame.image.save(screen, FILENAME)
camera.stop()
报告的错误是:
SystemError: ioctl(VIDIOC_S_FMT) failure: no supported formats
我在这里感到困惑。相机由 rasp-pi 支持,所以看起来我的 python 代码必须在某个地方更新。你能帮忙吗?
【问题讨论】:
标签: python raspberry-pi webcam raspberry-pi3