<s> """<STR_LIT>""" <EOL> import glob <EOL> import os <EOL> import sys <EOL> import select <EOL> import cv2 <EOL> import hardware <EOL> import config <EOL> import face <EOL> POSITIVE_FILE_PREFIX = '<STR_LIT>' <EOL> def is_letter_input ( letter ) : <EOL> if select . select ( [ sys . stdin , ] , [ ] , [ ] , <NUM_LIT:0.0> ) [ <NUM_LIT:0> ] : <EOL> input_char = sys . stdin . read ( <NUM_LIT:1> ) <EOL> return input_char . lower ( ) == letter . lower ( ) <EOL> return False <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> camera = config . get_camera ( ) <EOL> box = hardware . Box ( ) <EOL> if not os . path . exists ( config . POSITIVE_DIR ) : <EOL> os . makedirs ( config . POSITIVE_DIR ) <EOL> files = sorted ( glob . glob ( os . path . join ( config . POSITIVE_DIR , <EOL> POSITIVE_FILE_PREFIX + '<STR_LIT>' ) ) ) <EOL> count = <NUM_LIT:0> <EOL> if len ( files ) > <NUM_LIT:0> : <EOL> count = int ( files [ - <NUM_LIT:1> ] [ - <NUM_LIT:7> : - <NUM_LIT:4> ] ) + <NUM_LIT:1> <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> while True : <EOL> if box . is_button_up ( ) or is_letter_input ( '<STR_LIT:c>' ) : <EOL> print '<STR_LIT>' <EOL> image = camera . read ( ) <EOL> image = cv2 . cvtColor ( image , cv2 . COLOR_RGB2GRAY ) <EOL> result = face . detect_single ( image ) <EOL> if result is None : <EOL> print '<STR_LIT>' '<STR_LIT>' <EOL> continue <EOL> x , y , w , h = result <EOL> crop = face . crop ( image , x , y , w , h ) <EOL> filename = os . path . join ( config . POSITIVE_DIR , POSITIVE_FILE_PREFIX + '<STR_LIT>' % count ) <EOL> cv2 . imwrite ( filename , crop ) <EOL> print '<STR_LIT>' , filename <EOL> count += <NUM_LIT:1> </s>
