-
Notifications
You must be signed in to change notification settings - Fork 0
/
photobooth.py
61 lines (53 loc) · 2.41 KB
/
photobooth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import argparse
import threading
import pygame
import fborx
from app.http_server import app
from config import current_config
from photo.photo_name_generator import NameGenerator
from processor_pillow import Processor
from window import GameWindow
parser = argparse.ArgumentParser(description='Photobooth.')
parser.add_argument('-f', '--full_screen', action='store_true', default=False)
parser.add_argument('-x', type=int, default=720)
parser.add_argument('-y', type=int, default=576)
parser.add_argument('-s', '--style', default='blanco_negro')
parser.add_argument('-b', '--border', default=0)
parser.add_argument('-tca', '--test_click_area', action='store_true', default=False)
parser.add_argument('-ti', '--test-image', action='store_true', default=False)
parser.add_argument('--logging', action='store_true', default=False)
parser.add_argument('--prefix', default='test_session')
parser.add_argument('--output_path', default=current_config.ROOT_DIR)
parser.add_argument('--process', choices=('single', 'dual', 'dual_sepia', 'four', 'four_album'))
parser.add_argument('-ws', '--web_server', action='store_true', default=False)
parser.add_argument('--win_env', action='store_true', default=False)
parser.add_argument('-tp', '--thread_processing', action='store_true', default=False)
args = parser.parse_args()
SIZE = (args.x, args.y)
RES_AREA = None
main_screen = fborx.get_screen(SIZE, args.full_screen)
current_config.update_globals(main_screen.get_size(), args)
generator = NameGenerator(current_config)
if current_config.args.web_server:
app.config.generator = generator
app.config.profile = current_config.args.prefix
t = threading.Thread(target=app.run, args=('0.0.0.0',))
t.daemon = True
t.start()
gw = GameWindow(main_screen, generator, Processor(generator.banner_path, current_config.args.process,
current_config.args.win_env))
pygame.time.set_timer(current_config.COUNT_DOWN_EVENT, 1000)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
running = False
if current_config.args.logging:
print "event %s " % event
gw.transition(event)
pygame.event.pump()
# make sure to call pygame.quit() if using the framebuffer to get back to your terminal
pygame.quit()