Created
January 28, 2015 13:23
-
-
Save victorchee/2a8711c17ac2f6be3df3 to your computer and use it in GitHub Desktop.
Python控制摄像头获取当前图像。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
2 import pygame.camera | |
3 #from pygame.locals import * | |
4 | |
5 # initialize | |
6 pygame.init() | |
7 pygame.camera.init() | |
8 | |
9 camera = pygame.camera.Camera("/dev/video0", (640, 480)) | |
10 | |
11 def capture(): | |
12 # capture a picture | |
13 camera.start() | |
14 image = camera.get_image() | |
15 name = "image.jpg" | |
16 pygame.image.save(image, "static/"+name) | |
17 camera.stop() | |
18 | |
19 return name | |
20 | |
21 if __name__ == "__main__": | |
22 capture() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment