Skip to content

Instantly share code, notes, and snippets.

@maltzsama
Created August 3, 2015 19:46
Show Gist options
  • Select an option

  • Save maltzsama/015793d6f60cb7794624 to your computer and use it in GitHub Desktop.

Select an option

Save maltzsama/015793d6f60cb7794624 to your computer and use it in GitHub Desktop.
Get image from webcam
import pygame
from pygame import camera
pygame.init()
pygame.camera.init()
camList = pygame.camera.list_cameras()
if camList:
#for camComponent in camList:
cam = pygame.camera.Camera(camList[0], (1280, 720))
cam.start()
kind = ['RGB', 'YUV', 'HSV']
for n in kind:
img = cam.get_image()
pygame.image.save(img, n+".png")
cam.stop()
else:
print ('no camera found')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment