Skip to content

Photo booth python app intended for simple, white-label deployments.

License

Notifications You must be signed in to change notification settings

e-Reese/photo-booth

Repository files navigation

Photo Booth Application

A simple photo booth application built with Python, OpenCV, and Kivy that allows users to take photos and record videos with fun overlays. The application also automatically uploads media to Dropbox and generates QR codes for easy sharing. Intended for simple, white-label deployments.

Features

  • Live camera feed display
  • Apply PNG overlays with transparency
  • Countdown timer when taking photos
  • Photo capture with timestamp in the filename
  • Video recording with real-time duration display
  • Save photos and videos with timestamps in their filenames
  • Secure file handling
  • Automatic upload to Dropbox cloud storage
  • QR code generation for easy media download
  • Robust error handling and race condition prevention
  • Email collection and storage for user tracking

Project Structure

The application has been organized into separate modules for better maintainability:

  • main.py - The main application entry point
  • camera.py - Contains the camera thread for capturing and processing frames and videos
  • ui.py - UI components and layout creation functions
  • utils.py - Helper functions for file operations and security
  • cloud.py - Handles cloud storage uploads and QR code generation
  • email_manager.py - Manages email collection and storage

Requirements

  • Python 3.6+
  • Kivy 2.0.0+
  • OpenCV 4.5.0+
  • Pillow 8.0.0+
  • NumPy 1.19.0+
  • Dropbox SDK 11.36.0+
  • QRCode 7.3+

Install the requirements with:

pip install -r requirements.txt

Configuration

Before running the application, you need to set up Dropbox integration:

  1. Create a Dropbox app at https://www.dropbox.com/developers/apps
  2. Grant the app permissions for files.content.write and sharing.write
  3. Generate an access token for your app
  4. Replace the DROPBOX_ACCESS_TOKEN value in cloud.py with your token

Usage

  1. Run the application:
python main.py
  1. When the application starts, you'll be prompted to enter your email address:

    • This is required before taking photos or recording videos
    • Your email is saved locally in user_emails.csv with a timestamp
    • The email collection popup cannot be dismissed without entering a valid email
  2. To add custom overlays, place PNG files with transparency in the overlays folder.

  3. Use the "Select Overlay" button to choose an overlay.

  4. For photos:

    • Click "Take Photo" to capture an image with the current overlay.
    • A 3-second countdown will appear before the photo is taken.
  5. For videos:

    • Click "Record Video" to start recording with the current overlay.
    • A red recording indicator will appear in the corner along with a timer showing recording duration.
    • Click "Stop Recording" when you're finished.
  6. Media is saved locally and also uploaded to Dropbox:

    • Photos are saved in the photos directory (PNG format)
    • Videos are saved in the videos directory (MP4 format)
  7. Once the upload is complete, a QR code will be displayed that can be scanned to download the photo or video.

Email Collection

The application includes an email collection system that:

  • Requires users to enter their email before using photo/video features
  • Stores emails in a local CSV file (user_emails.csv)
  • Records timestamps for each email entry
  • Validates email format (must contain '@' symbol)
  • Prevents dismissal of the email popup without valid input

The email data is stored in the following format:

email,timestamp
user@example.com,2024-03-21T10:30:45.123456

Implementation Details

Thread Safety and Race Conditions

The application uses a multi-threaded architecture to keep the UI responsive:

  • The camera operates in its own thread
  • Dropbox uploads occur in a background thread
  • The main thread handles UI updates

To prevent race conditions:

  • Media files are only uploaded to Dropbox after confirmation they've been saved to disk
  • Thread-safe queues are used for communication between threads
  • Callbacks are properly scheduled on the main thread using Kivy's Clock

Video Recording

The application supports video recording with the following features:

  • Records video at 30 FPS for smooth playback
  • Displays a real-time duration counter during recording
  • Shows a red indicator in the corner when recording is active
  • Applies the selected overlay to the video in real-time
  • Supports different video codecs (XVID, MJPG) for maximum compatibility
  • Automatically handles codec selection based on system capabilities

Directory Structure

  • overlays/ - Directory for PNG overlay files
  • photos/ - Directory where captured photos are saved
  • videos/ - Directory where recorded videos are saved
  • qrcodes/ - Directory where QR codes are saved

About

Photo booth python app intended for simple, white-label deployments.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages