1.安装PyGame(Apt方式):

sudo apt-get install python-pygame

2.安装PyGame(Pip方式):

pip install pygame

3.代码

import pygame
import pygame.camera
from pygame.locals import *  #引用

pygame.init()
pygame.camera.init()  #初始化

camera = pygame.camera.Camera("/dev/video0", (1280, 720))  #指定设备,设置宽度高度
camera.start()
image = camera.get_image()  #Get
pygame.image.save(image, "image.jpg")  #保存
camera.stop() 

标签: Raspberry Pi

添加新评论