def init_cams(self, which_cam_idx):
# gets a list of available cameras.
self.clist = pygame.camera.list_cameras()
print (self.clist)
if not self.clist:
raise ValueError("Sorry, no cameras detected.")
try:
cam_id = self.clist[which_cam_idx]
except IndexError:
cam_id = self.clist[0]
# creates the camera of the specified size and in RGB colorspace
self.camera = pygame.camera.Camera(cam_id, self.size, "RGB")
# starts the camera
self.camera.start()
self.clock = pygame.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)
评论列表
文章目录