bro
This commit is contained in:
1 parent
de41a02749
commit
9af09cebd3
764 files changed
+54218
-78859
No files matched your search
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
"""pygame.examples.camera
|
||||
""" pygame.examples.camera
|
||||
|
||||
Basic image capturing and display using pygame.camera
|
||||
|
||||
@@ -11,8 +11,7 @@ Keyboard controls
|
||||
- 9, start camera 9.
|
||||
- 10, start camera... wait a minute! There's not 10 key!
|
||||
"""
|
||||
|
||||
import pygame
|
||||
import pygame as pg
|
||||
import pygame.camera
|
||||
|
||||
|
||||
@@ -24,7 +23,7 @@ class VideoCapturePlayer:
|
||||
super().__init__(**argd)
|
||||
|
||||
# create a display surface. standard pygame stuff
|
||||
self.display = pygame.display.set_mode(self.size)
|
||||
self.display = pg.display.set_mode(self.size)
|
||||
self.init_cams(0)
|
||||
|
||||
def init_cams(self, which_cam_idx):
|
||||
@@ -47,11 +46,11 @@ class VideoCapturePlayer:
|
||||
# starts the camera
|
||||
self.camera.start()
|
||||
|
||||
self.clock = pygame.Clock()
|
||||
self.clock = pg.time.Clock()
|
||||
|
||||
# create a surface to capture to. for performance purposes, you want the
|
||||
# bit depth to be the same as that of the display surface.
|
||||
self.snapshot = pygame.surface.Surface(self.size, 0, self.display)
|
||||
self.snapshot = pg.surface.Surface(self.size, 0, self.display)
|
||||
# return the name of the camera being used, to be included in the window name
|
||||
return cam_id
|
||||
|
||||
@@ -78,7 +77,7 @@ class VideoCapturePlayer:
|
||||
# self.snapshot = self.camera.get_image(self.display)
|
||||
# # self.display.blit(self.snapshot, (0,0))
|
||||
|
||||
pygame.display.flip()
|
||||
pg.display.flip()
|
||||
|
||||
def main(self):
|
||||
# get the camera list. If there are no cameras, raise a value error.
|
||||
@@ -98,15 +97,13 @@ class VideoCapturePlayer:
|
||||
|
||||
going = True
|
||||
while going:
|
||||
events = pygame.event.get()
|
||||
events = pg.event.get()
|
||||
for e in events:
|
||||
if e.type == pygame.QUIT or (
|
||||
e.type == pygame.KEYDOWN and e.key == pygame.K_ESCAPE
|
||||
):
|
||||
if e.type == pg.QUIT or (e.type == pg.KEYDOWN and e.key == pg.K_ESCAPE):
|
||||
going = False
|
||||
if e.type == pygame.KEYDOWN:
|
||||
if e.key in range(pygame.K_0, pygame.K_0 + 10):
|
||||
camera = self.init_cams(e.key - pygame.K_0)
|
||||
if e.type == pg.KEYDOWN:
|
||||
if e.key in range(pg.K_0, pg.K_0 + 10):
|
||||
camera = self.init_cams(e.key - pg.K_0)
|
||||
|
||||
self.get_and_flip()
|
||||
self.clock.tick()
|
||||
@@ -114,10 +111,10 @@ class VideoCapturePlayer:
|
||||
|
||||
|
||||
def main():
|
||||
pygame.init()
|
||||
pg.init()
|
||||
pygame.camera.init()
|
||||
VideoCapturePlayer().main()
|
||||
pygame.quit()
|
||||
pg.quit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user