Python中的picamera模块是用来操作树莓派摄像头的。
更多API请查看:http://picamera.readthedocs.org/en/release-1.2/api.html
[codesyntax lang="python"]
!/usr/bin/python
# from http://surenpi.com
# raspberry camera python example
import picamera
import time
cam = picamera.PiCamera()
cam.vflip = True
cam.capture('a.jpg')
cam.close()
print 'capture done.'
[/codesyntax]
可以将视频保存到文件中或者其他地方,默认录制的时候是不会有预览的,可以通过调用start_preview函数来预览 [codesyntax lang="python"]
import picamera
with picamera.PiCamera() as camera:
camera.resolution = (640, 480)
camera.start_preview()
camera.start_recording('suren.h264', format='h264', quantization=23, resize=(1024, 768))
camera.wait_recording(60)