Skip to content

Instantly share code, notes, and snippets.

@velolala
Created February 17, 2021 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velolala/328a31f2b4b27684dcce848cd494b7ee to your computer and use it in GitHub Desktop.
Save velolala/328a31f2b4b27684dcce848cd494b7ee to your computer and use it in GitHub Desktop.
Test Webcam on EYESY
import pygame
import pygame.camera
import time
import sys
pygame.camera.init()
CAM = ((pygame.camera.list_cameras() or [""])[0], (160, 120))
camera = pygame.camera.Camera(*CAM)
camera.start()
snapshot = pygame.surface.Surface(CAM[-1], 0)
time.sleep(1)
if camera.query_image():
snapshot = camera.get_image(snapshot)
print "camera is '%s' resolution '%s'" % CAM
else:
print "could not get an image"
camera.stop()
print "camera stop"
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment