树莓派摄像头step by step

1、开启摄像头功能

sudo raspi-config

选择第5项interfacing option,选择P1 camera,选择yes/OK
重启树莓派
2、拍照

raspistill -t 5000 -o 1.jpg

3、视频预览
创建camera_test.py

from picamera import PiCamera 
from time import sleep
"""set camera""" 
camera = PiCamera() 
camera.resolution = (1920,1080) 
camera.framerate = 60 
# 打开预览 
camera.start_preview() 
#camera.capture('/home/pi/testme.jpg')
camera.annotate_text = "video Test"
sleep(10)
camera.stop_preview()
camera.close()

一定要调用close关闭摄像头,否则会出现一下问题

pi@raspberrypi:~ $ raspistill -t 5000 -o 1.jpg
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component couldn't be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates

你可能感兴趣的:(树莓派)