Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #!/usr/bin/python import os
  2. import pygame, sys
  3. from pygame.locals import *
  4. import pygame.camera
  5.  
  6. width = 640
  7. height = 480
  8.  
  9. #initialise pygame
  10. pygame.init()
  11. pygame.camera.init()
  12. cam = pygame.camera.Camera("/dev/video0",(width,height))
  13. cam.start()
  14.  
  15. #setup window
  16. windowSurfaceObj = pygame.display.set_mode((width,height),1,16)
  17. pygame.display.set_caption('Camera')
  18.  
  19. #take a picture
  20. image = cam.get_image()
  21. cam.stop()
  22.  
  23. #display the picture/
  24. catSurfaceObj = image
  25. windowSurfaceObj.blit(catSurfaceObj,(0,0))
  26. pygame.display.update()
  27.  
  28. #save picture
  29.  
  30. pygame.image.save(windowSurfaceObj,'picture.jpg')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement