This Python program captures images from a camera feed, applies a Fourier transform (FFT) with OpenCV and NumPy, and displays the transformed image alongside the original.
This can be used to explain concepts such as the Fourier Transform, but also scattering and diffraction effects, if the lecturer shows printouts of the library of shapes and arrays in front of the camera.
Ensure you have Python 3.12 or above installed.
Install dependencies with:
pip install -r requirements.txtRun the program with:
python LiveFT.pyPress "q" to exit the application
Build a distributable bundle with:
pip install -r requirements_for_testing.txt
sh scripts/build_dist.shThe build script auto-detects .venv/bin/python, python, or python3. Override it with
LIVEFT_PYTHON=/path/to/python when needed.
Useful packaging environment variables:
LIVEFT_BUNDLE_IDLIVEFT_CAMERA_USAGELIVEFT_CODESIGN_IDENTITYLIVEFT_ENTITLEMENTS_FILELIVEFT_ICON_PATHPYINSTALLER_CONFIG_DIR
On macOS, create a DMG after the app bundle is built:
sh scripts/create_dmg.sh distSet LIVEFT_KEEP_APP_AFTER_DMG=1 if you want to keep the .app bundle in dist/ after the DMG is created.
For a local macOS release build:
LIVEFT_CODESIGN_IDENTITY="Developer ID Application: Your Name (TEAMID)" sh scripts/release_macos.shAdditional macOS release scripts:
sh scripts/sign_macos.sh distsh scripts/notarize_macos.sh distsh scripts/verify_macos.sh dist
The GitHub workflow uses these optional secrets for signed/notarized macOS releases:
MACOS_CODESIGN_IDENTITYMACOS_CERTIFICATE_P12_BASE64MACOS_CERTIFICATE_PASSWORDMACOS_NOTARY_KEY_IDMACOS_NOTARY_ISSUERMACOS_NOTARY_KEY_P8
These MACOS_* values are intended for GitHub Actions repository or organization secrets.
MACOS_CODESIGN_IDENTITYThe exact signing identity name shown by Keychain for your Developer ID Application certificate. Example:Developer ID Application: Your Name or Company (TEAMID)MACOS_CERTIFICATE_P12_BASE64A base64-encoded.p12export of the same Developer ID Application certificate, including its private key. Export the certificate from Keychain Access as.p12, then base64-encode that file before storing it as a GitHub secret.MACOS_CERTIFICATE_PASSWORDThe password you chose when exporting the.p12certificate bundle.MACOS_NOTARY_KEY_IDThe App Store Connect API key ID used withxcrun notarytool.MACOS_NOTARY_ISSUERThe issuer UUID associated with that App Store Connect API key.MACOS_NOTARY_KEY_P8The full contents of theAuthKey_<KEY_ID>.p8file for the notarization API key. Paste the entire file into the GitHub secret, including theBEGIN PRIVATE KEYandEND PRIVATE KEYlines.
These are not the main local-shell variables. For local release runs, the scripts use:
LIVEFT_CODESIGN_IDENTITYLIVEFT_NOTARY_KEY_IDLIVEFT_NOTARY_ISSUERLIVEFT_NOTARY_KEY_FILE
Example local notarized release invocation:
LIVEFT_CODESIGN_IDENTITY="Developer ID Application: Your Name or Company (TEAMID)" \
LIVEFT_NOTARY_KEY_ID="ABC123DEF4" \
LIVEFT_NOTARY_ISSUER="00000000-0000-0000-0000-000000000000" \
LIVEFT_NOTARY_KEY_FILE="$HOME/private_keys/AuthKey_ABC123DEF4.p8" \
sh scripts/release_macos.sh-n, --numShots: Maximum number of images before program exits.-d, --camDevice: Camera device ID to use.-i, --imAvgs: Number of images to average for display and FFT processing.-y, --vScale: Vertical video scaling factor.-x, --hScale: Horizontal video scaling factor.-k, --killCenterLines: Remove central lines from FFT image to improve dynamic range.-f, --figid: Name for the display window.-r, --rows: Number of central rows to use in video frame cropping.-c, --columns: Number of central columns to use in video frame cropping.-o, --showRadialProfile: Show the FFT radial distribution panel.-e, --fftGamma: Set the FFT display gamma.-m, --maxFPS: Limit processing speed to N FPS. Use0to disable the limit.
- This program uses OpenCV and NumPy for FFT calculations.
- Tested on MacOS and Linux environments.
This project is licensed under the Apache-2.0 license.