Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import os
  2.  
  3. import pygame, sys
  4.  
  5.  
  6.  
  7. from pygame.locals import *
  8.  
  9. import pygame.camera
  10.  
  11.  
  12.  
  13. width = 320
  14.  
  15. height = 240
  16.  
  17.  
  18.  
  19. # initialise PyGame
  20.  
  21. pygame.init()
  22.  
  23. pygame.camera.init()
  24.  
  25. cam = pygame.camera.Camera("/dev/video0",(width,height))
  26.  
  27. cam.start()
  28.  
  29. # Setup a window for displaying the captured images
  30.  
  31. windowSurfaceObj = pygame.display.set_mode((width,height),1,16)
  32.  
  33. pygame.display.set_caption('Camera')
  34.  
  35. # Take a picture
  36.  
  37. image = cam.get_image()
  38.  
  39. # Display the picture
  40.  
  41. catSurfaceObj = image
  42.  
  43. windowSurfaceObj.blit(catSurfaceObj,(0,0))
  44.  
  45. pygame.display.update()
  46.  
  47. pygame.image.save(windowSurfaceObj, './test_picture' + str(k) + '.jpg')
  48. cam.stop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement