Skip to content

BAMresearch/LiveFT

Repository files navigation

Live Fourier Transform of Camera Feed

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.

image

Prerequisites

Ensure you have Python 3.12 or above installed.

Installation

Install dependencies with:

pip install -r requirements.txt

Usage

Run the program with:

python LiveFT.py

Press "q" to exit the application

Packaging

Build a distributable bundle with:

pip install -r requirements_for_testing.txt
sh scripts/build_dist.sh

The 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_ID
  • LIVEFT_CAMERA_USAGE
  • LIVEFT_CODESIGN_IDENTITY
  • LIVEFT_ENTITLEMENTS_FILE
  • LIVEFT_ICON_PATH
  • PYINSTALLER_CONFIG_DIR

On macOS, create a DMG after the app bundle is built:

sh scripts/create_dmg.sh dist

Set 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.sh

Additional macOS release scripts:

  • sh scripts/sign_macos.sh dist
  • sh scripts/notarize_macos.sh dist
  • sh scripts/verify_macos.sh dist

The GitHub workflow uses these optional secrets for signed/notarized macOS releases:

  • MACOS_CODESIGN_IDENTITY
  • MACOS_CERTIFICATE_P12_BASE64
  • MACOS_CERTIFICATE_PASSWORD
  • MACOS_NOTARY_KEY_ID
  • MACOS_NOTARY_ISSUER
  • MACOS_NOTARY_KEY_P8

macOS Release Secrets

These MACOS_* values are intended for GitHub Actions repository or organization secrets.

  • MACOS_CODESIGN_IDENTITY The 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_BASE64 A base64-encoded .p12 export 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_PASSWORD The password you chose when exporting the .p12 certificate bundle.
  • MACOS_NOTARY_KEY_ID The App Store Connect API key ID used with xcrun notarytool.
  • MACOS_NOTARY_ISSUER The issuer UUID associated with that App Store Connect API key.
  • MACOS_NOTARY_KEY_P8 The full contents of the AuthKey_<KEY_ID>.p8 file for the notarization API key. Paste the entire file into the GitHub secret, including the BEGIN PRIVATE KEY and END PRIVATE KEY lines.

These are not the main local-shell variables. For local release runs, the scripts use:

  • LIVEFT_CODESIGN_IDENTITY
  • LIVEFT_NOTARY_KEY_ID
  • LIVEFT_NOTARY_ISSUER
  • LIVEFT_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

Options

  • -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. Use 0 to disable the limit.

Notes

  • This program uses OpenCV and NumPy for FFT calculations.
  • Tested on MacOS and Linux environments.

License

This project is licensed under the Apache-2.0 license.

About

An educational tool showing in realtime the webcam image and the intensity of its Fourier Transform next to it.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors