<s> import os <EOL> import pygame <EOL> import pygame . camera <EOL> import time <EOL> from guild . actor import * <EOL> pygame . camera . init ( ) <EOL> class Camera ( Actor ) : <EOL> def gen_process ( self ) : <EOL> camera = pygame . camera . Camera ( pygame . camera . list_cameras ( ) [ <NUM_LIT:0> ] ) <EOL> camera . start ( ) <EOL> while True : <EOL> yield <NUM_LIT:1> <EOL> frame = camera . get_image ( ) <EOL> self . output ( frame ) <EOL> time . sleep ( <NUM_LIT:1.0> / <NUM_LIT:50> ) <EOL> class Display ( Actor ) : <EOL> def __init__ ( self , size ) : <EOL> super ( Display , self ) . __init__ ( ) <EOL> self . size = size <EOL> def process_start ( self ) : <EOL> self . display = pygame . display . set_mode ( self . size ) <EOL> @ actor_method <EOL> def show ( self , frame ) : <EOL> self . display . blit ( frame , ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> pygame . display . flip ( ) <EOL> input = show <EOL> class FrameStore ( Actor ) : <EOL> def __init__ ( self , directory = '<STR_LIT>' , base = '<STR_LIT>' ) : <EOL> super ( FrameStore , self ) . __init__ ( ) <EOL> self . directory = directory <EOL> self . base = base <EOL> self . count = <NUM_LIT:0> <EOL> def process_start ( self ) : <EOL> try : <EOL> os . makedirs ( self . directory ) <EOL> except OSError , e : <EOL> if e . errno != <NUM_LIT> : <EOL> raise <EOL> @ actor_method <EOL> def input ( self , frame ) : <EOL> self . count += <NUM_LIT:1> <EOL> now = time . strftime ( "<STR_LIT>" , time . localtime ( ) ) <EOL> filename = "<STR_LIT>" % ( self . directory , <EOL> self . base , now , <EOL> self . count ) <EOL> pygame . image . save ( frame , filename ) <EOL> self . output ( frame ) <EOL> camera = Camera ( ) . go ( ) <EOL> display = Display ( ( <NUM_LIT> , <NUM_LIT> ) ) . go ( ) <EOL> framestore = FrameStore ( ) . go ( ) <EOL> pipeline ( camera , framestore , display ) <EOL> while <NUM_LIT:1> : <EOL> time . sleep ( <NUM_LIT:30> ) <EOL> stop ( camera , framestore , display ) <EOL> wait_for ( camera , framestore , display ) </s>
