Created
April 10, 2019 22:12
-
-
Save ahmedfgad/26ee739c62aa879d7eac797193473436 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment