fork download
  1. import pygame, sys
  2. from pygame.locals import *
  3. import pygame.camera
  4. import time
  5.  
  6. pygame.init()
  7. pygame.camera.init
  8.  
  9. count = 0
  10. while count < 5:
  11. width = 640
  12. height = 480
  13. cam = pygame.camera.Camera("/dev/video0",(width,height))
  14. cam.start()
  15. pygame.display.set_caption("saved as /home/pi/" + str(count)+ '.jpg')
  16. windowSurfaceObj = pygame.display.set_mode((width,height))
  17. image = cam.get_image()
  18. catSurfaceObj = image
  19. windowSurfaceObj.blit(catSurfaceObj,(0,0))
  20. pygame.display.update()
  21. cam.stop()
  22. pygame.image.save(image,str(count ) +'.jpg')
  23.  
  24. time.sleep(1)
Runtime error #stdin #stdout #stderr 0.01s 23296KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 1, in <module>
ImportError: No module named pygame