def main(): # Load the database of items we know about. global db db = ImageDatabase(options) # Initialize the camera object we'll use to take pictures. global camera camera = Camera(options.video_source, options.video_width, options.video_height, options.video_fps) with open(get_sound('shutter.raw'), 'rb') as f: global SHUTTER_TONE SHUTTER_TONE = f.read() # Set up the audio devices if they are configured if options.audio_out_device: audioutils.ALSA_SPEAKER = options.audio_out_device if options.audio_in_device: audioutils.ALSA_MICROPHONE = options.audio_in_device # If log path is set, make sure the corresponding directory exists. if options.log_path and not os.path.isdir(options.log_path): os.makedirs(options.log_path) # If --web-server was specified, run a web server in a separate process # to expose the files in that directory. # Note that we're using port 80, assuming we'll always run as root. if options.web_server: subprocess.Popen(['python', '-m', 'SimpleHTTPServer', '80'], cwd=options.web_server_root) # Monitor the button for events global eventloop eventloop = EventLoop() eventloop.monitor_gpio_button(options.gpio_pin, button_handler, doubleclick_speed=0) # If you don't have a button, use --cmd-ui to monitor the keyboard instead. if options.cmd_ui: # Print instructions. keyboard_handler() # Monitor it on the event loop. eventloop.monitor_console(keyboard_handler, prompt="Command: ") # Let the user know we're ready ready() # Run the event loop forever eventloop.loop()