Skip to content

Commit

Permalink
#8, #9 fixed. idea about #10
Browse files Browse the repository at this point in the history
  • Loading branch information
varunmehta committed Apr 18, 2017
1 parent 39bd8cd commit cdefc2d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
5 changes: 3 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
23 changes: 18 additions & 5 deletions photobooth.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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?
Expand All @@ -68,7 +69,6 @@
# init logging
logging.basicConfig(format='%(asctime)s %(message)s', filename='photobooth.log', level=logging.INFO)


#################
### Functions ###
#################
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand All @@ -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")
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit cdefc2d

Please sign in to comment.