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.
- 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
The application has been organized into separate modules for better maintainability:
main.py- The main application entry pointcamera.py- Contains the camera thread for capturing and processing frames and videosui.py- UI components and layout creation functionsutils.py- Helper functions for file operations and securitycloud.py- Handles cloud storage uploads and QR code generationemail_manager.py- Manages email collection and storage
- 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.txtBefore running the application, you need to set up Dropbox integration:
- Create a Dropbox app at https://www.dropbox.com/developers/apps
- Grant the app permissions for
files.content.writeandsharing.write - Generate an access token for your app
- Replace the
DROPBOX_ACCESS_TOKENvalue incloud.pywith your token
- Run the application:
python main.py-
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.csvwith a timestamp - The email collection popup cannot be dismissed without entering a valid email
-
To add custom overlays, place PNG files with transparency in the
overlaysfolder. -
Use the "Select Overlay" button to choose an overlay.
-
For photos:
- Click "Take Photo" to capture an image with the current overlay.
- A 3-second countdown will appear before the photo is taken.
-
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.
-
Media is saved locally and also uploaded to Dropbox:
- Photos are saved in the
photosdirectory (PNG format) - Videos are saved in the
videosdirectory (MP4 format)
- Photos are saved in the
-
Once the upload is complete, a QR code will be displayed that can be scanned to download the photo or video.
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.123456The 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
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
overlays/- Directory for PNG overlay filesphotos/- Directory where captured photos are savedvideos/- Directory where recorded videos are savedqrcodes/- Directory where QR codes are saved