From cdefc2d79a567aa0326658fa06575801c858756a Mon Sep 17 00:00:00 2001 From: Varun Mehta Date: Tue, 18 Apr 2017 13:07:03 -0400 Subject: [PATCH] #8, #9 fixed. idea about #10 --- config.py | 5 +++-- photobooth.py | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/config.py b/config.py index 0a912f9..6aa5203 100755 --- a/config.py +++ b/config.py @@ -1,6 +1,7 @@ # Config settings to change behavior of photo booth -monitor_w = 1920 # width of the display monitor -monitor_h = 1080 # height of the display monitor +monitor_w = 800 # width of the display monitor +monitor_h = 400 # height of the display monitor +event_name = 'international_night' file_path = '/home/pi/photobooth/pics/' # path to save images clear_on_startup = False # True will clear previously stored photos as the program launches. False will leave all previous photos. debounce = 0.3 # how long to debounce the button. Add more time if the button triggers too many times. diff --git a/photobooth.py b/photobooth.py index 4a73f7d..1e0ab9b 100755 --- a/photobooth.py +++ b/photobooth.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # created by chris@drumminhands.com +# modified by varunmehta # see instructions at http://www.drumminhands.com/2014/06/15/raspberry-pi-photo-booth/ import atexit @@ -27,7 +28,7 @@ total_pics = 2 # number of pics to be taken capture_delay = 1 # delay between pics prep_delay = 5 # number of seconds at step 1 as users prep to have photo taken -restart_delay = 10 # how long to display finished message before beginning a new session +restart_delay = 7 # how long to display finished message before beginning a new session # full frame of v1 camera is 2592x1944. Wide screen max is 2592,1555 # if you run into resource issues, try smaller, like 1920x1152. @@ -52,7 +53,7 @@ real_path = os.path.dirname(os.path.realpath(__file__)) # GPIO setup -GPIO.setmode(GPIO.BOARD) +GPIO.setmode(GPIO.BCM) GPIO.setup(led_pin, GPIO.OUT) # LED GPIO.setup(btn_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.output(led_pin, False) # for some reason the pin turns on at the beginning of the program. Why? @@ -68,7 +69,6 @@ # init logging logging.basicConfig(format='%(asctime)s %(message)s', filename='photobooth.log', level=logging.INFO) - ################# ### Functions ### ################# @@ -103,6 +103,12 @@ def clear_pics(channel): sleep(0.25) +def init_event_folders(): + if (not os.path.exists(config.file_path)): + os.mkdir(config.file_path) + + + # set variables to properly display the image on screen at right ratio def set_dimensions(img_w, img_h): # Note this only works when in booting in desktop mode. @@ -192,7 +198,7 @@ def start_photobooth(): camera = picamera.PiCamera() camera.vflip = False camera.hflip = True # flip for preview, showing users a mirror image - camera.rotation = 270 # revisit this depending upon final camera placement + camera.rotation = 0 # revisit this depending upon final camera placement # camera.saturation = -100 # comment out this line if you want color images # camera.iso = config.camera_iso @@ -204,6 +210,7 @@ def start_photobooth(): # All images will be number appended by now, 20160310113034-01.jpg now = time.strftime("%Y%m%d-%H%M%S") # get the current date and time for the start of the filename + montage_img = now + "-montage.jpg" # montage file name if config.capture_count_pics: logging.debug("Decided to go count pics") @@ -255,7 +262,7 @@ def start_photobooth(): # Create a montage of the images montage = "gm montage -mode concatenate -resize 1190x1770 -borderwidth 5 -bordercolor white " \ + config.file_path + "/" + now + "*.jpg bottom-1190x190.jpg -tile 1x3 " \ - + config.file_path + "/final/" + now + "-final.jpg " + + config.file_path + "/final/" + montage_img processed = subprocess.call(montage, shell=True) @@ -267,6 +274,9 @@ def start_photobooth(): try: display_pics(now) + # show preview of finally created image + show_image(config.file_path + "/final/" + montage_img) + time.sleep(2) except Exception as e: tb = sys.exc_info()[2] traceback.print_exception(e.__class__, e, tb) @@ -289,6 +299,9 @@ def start_photobooth(): if config.clear_on_startup: clear_pics(1) + # check if files and folders exist for the event, or create them + config.file_path + logging.warning("Starting photo booth...") for x in range(0, 5): # blink light to show the app is running