Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import pygame, sys
- from pygame.locals import *
- import pygame.camera
- width = 320
- height = 240
- # initialise PyGame
- pygame.init()
- pygame.camera.init()
- cam = pygame.camera.Camera("/dev/video0",(width,height))
- cam.start()
- # Setup a window for displaying the captured images
- windowSurfaceObj = pygame.display.set_mode((width,height),1,16)
- pygame.display.set_caption('Camera')
- # Take a picture
- image = cam.get_image()
- # Display the picture
- catSurfaceObj = image
- windowSurfaceObj.blit(catSurfaceObj,(0,0))
- pygame.display.update()
- pygame.image.save(windowSurfaceObj, './test_picture' + str(k) + '.jpg')
- cam.stop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement