1、摄像头预览
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
sleep(10)
camera.stop_preview()
2、如果图像时上下颠倒的,可以用一下代码实现翻转
camera.rotation = 180
camera.start_preview()
sleep(10)
camera.stop_preview()
可以设置旋转的度数为90,180或270,也可以设置为0
3、通过改变alpha的值,可以修改摄像头拍摄图像的透明度
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview(alpha=200)
sleep(10)
camera.stop_preview()
4、拍照片
camera.start_preview()
sleep(5)
camera.capture('/home/pi/Desktop/image.jpg')
camera.stop_preview()
5、增加一个循环就能实现连拍,每隔5秒拍一张,拍完后预览关闭,桌面上就有五张图了
camera.start_preview()
for i in range(5):
sleep(5)
camera.capture('/home/pi/Desktop/image%s.jpg' % i)
camera.stop_preview()
树莓派3b连接摄像头模块并用python编程拍照和录像