A high-performance graphical interface for controlling Holographic Optical Tweezers (HOT). Built with modern C++ and Qt 6, this software calculates phase masks in real time for Spatial Light Modulators (SLMs) and provides a live camera feed for active particle tracking and manipulation.
Platform note: The application is currently developed and deployed for Windows. It depends on a LabVIEW-built vendor DLL (
Image_Control.dll), Win32 sockets for the UDP camera backend, and Visual Studio CMake presets. The code is written with portable C++/Qt, but other platforms are not yet officially supported or tested.
- Triple-Backend Camera Stream: Toggle between Qt Native (WMF) for standard webcams, OpenCV (DirectShow) for high-speed scientific lab cameras and virtual drivers (e.g. OBS), and a UDP stream for Ethernet camera receivers (raw and RLE-encoded frames).
- Real-Time Phase Mask Generation: Convert 2D target patterns into phase holograms with Gerchberg–Saxton (GS) (CPU, OpenCL, or CUDA/cuFFT backends) or the non-iterative Random Mask Encoding (RME) algorithm. Weighted GS is exposed in the UI but is not implemented yet.
- Mathematical Hologram Generator: A standalone utility that instantly generates blazed gratings (prisms), binary gratings, Fresnel lenses, axicons, vortex beams, sinusoidal gratings, and checkerboards at any angle or pitch.
- Pattern Presets & Image Import: Built-in trap layouts (circles, triangles, stars, grids, spirals, rose curves, etc.) plus image-to-target import.
- Python Trap Scripting: An embedded CPython 3.12 runtime with NumPy for static trap patterns and animation frame sequences, with a
hot.patternhelper namespace and 14+ examples inpython_examples/. - Hardware Persistence: Automatically saves and loads SLM dimensions, pixel pitches, and optical settings via an
.iniconfiguration file (hardware_config.ini). - Live Capture Suite: High-resolution snapshots and video recording of the active optical trap workspace, with zoom, flips/rotation, target overlay, and live FPS monitoring.
- SLM Output & Correction: Send masks to the SLM through the vendor DLL or a direct fullscreen monitor, with aberration/correction mask support.
- Dark Mode UI: A professional, low-eye-strain dark theme designed for laser lab environments.
| Main Control Interface | Standalone Phase Generator |
|---|---|
![]() |
![]() |
| Live camera feed, target pattern grid, and SLM mask monitor. | Analytical generation of blazed and binary gratings. |
To build the C++ application from source you will need:
- CMake v3.16 or higher (v3.25+ is required to use the included CMake presets)
- C++17 compatible compiler (MSVC 2019/2022 recommended; GCC/Clang may work with adjustments)
- Qt 6.x — required modules:
Core,Gui,Widgets,Multimedia,MultimediaWidgets,Network - OpenCV 4.x (DirectShow camera support and image/matrix operations)
- Python 3 development libraries (the app embeds CPython; NumPy is bundled for deployment)
- Optional: CUDA 11.2 + cuFFT for GPU-accelerated GS, and OpenCV with OpenCL (
cv::UMat) for the OpenCL GS backend
The provided presets target Visual Studio 2022 (x64) with Qt 6.7.3 at C:/Qt/6.7.3/msvc2022_64.
Use the included presets (run from the repository root):
# Standard release build (CUDA off)
cmake --preset release-default
cmake --build --preset build-release-default
# CUDA build for GT 730 / Kepler (sm_35, CUDA 11.2, v142 toolset)
cmake --preset release-gt730-cuda
cmake --build --preset build-release-gt730-cudaBuild output is placed in build/ (or build_gt730_combo/ for the CUDA variant). Post-build steps use windeployqt to deploy Qt DLLs along with the OpenCV DLL and the embedded Python runtime/NumPy.
Useful CMake options (set at configure time):
| Option | Default | Description |
|---|---|---|
HOT_TARGET_GT730 |
ON |
Target GT 730 / Kepler (CUDA sm_35) |
HOT_ENABLE_CUDA_GS |
ON |
Enable the CUDA GS backend |
HOT_ENABLE_OPENCL_GS |
ON |
Enable the OpenCV OpenCL GS backend |
HOT_ENABLE_TEMP_GS_PROFILING |
ON |
Temporary GS runtime profiling/logging |
Launch the built executable (no command-line arguments are required):
build/Release/HOT_Control_App.exe
On first run, configure your SLM dimensions, pixel pitch, and camera backend in Settings. Hardware values are persisted to hardware_config.ini next to the executable.
- Select a camera backend (Qt Native, OpenCV, or UDP) and start the live feed.
- Place or drag trap points on the camera-centered grid, or load a pattern preset / Python-generated pattern.
- Choose an algorithm — Gerchberg-Saxton or Random Mask Encoding (Paper) — and configure the optical parameters (wavelength, focal length, magnification, pixel sizes).
- Generate the phase mask, preview it, optionally compose a correction mask, then save, animate, or send to the SLM.
Coordinates are camera-centered: (0, 0) is the center, +x is right, +y is up. Points outside the field of view are clamped automatically.
The embedded Python tab accepts scripts with either entry point:
build_pattern(width, height)— recommended for a single static patternbuild_frames(frame_count, width, height)— for multi-frame animation
Scripts may define FRAME_COUNT and FPS to override the UI controls, import math and numpy, and use injected helpers such as hot.pattern.circle(...), hot.pattern.grid(...), and hot.pattern.star(...). See docs/python-trap-scripting.md and the examples in python_examples/.
- GS Algorithm Overview
- RME Algorithm Overview
- Python Trap Scripting Guide
- Camera Receive Logic (UDP)
- Extending Built-In Patterns
- Hologram Logic Implementation Plan
A parallel, incremental reimplementation in PySide6 lives in python_port/. It aims for feature parity with the C++ app and currently supports a subset of features (see python_port/progress.md).
cd python_port
pip install -r requirements.txt
python main.pyalgorithm_direct/ contains UI-free C++ and Python versions of the GS and RME algorithms for experimentation and reuse. The Python scripts require numpy and pillow:
pip install numpy pillowSee algorithm_direct/README.md for usage and optical parameter examples.
src/
main.cpp Application entry point (QApplication -> MainWindow)
ui/ MainWindow, dialogs, and reusable widgets
components/ Target grid, pattern presets, Python code editor
core/ GS/RME algorithms, pattern generator, Python script engine
algorithms/ GS (CPU/OpenCL/CUDA) and RME implementations
camera/ CameraManager with Qt/OpenCV/UDP backends
hardware/ UDP frame receiver and SLM driver interface
docs/ Algorithm, camera, pattern, and scripting guides
python_examples/ Example Python trap/animation scripts
python_port/ PySide6 reimplementation of the app
algorithm_direct/ Standalone UI-free algorithm implementations
images/ Screenshots
third_party/VkFFT/ Vendored Vulkan FFT library
resources/ QSS themes, icons, and Qt resources
This project is licensed under the MIT License — see the LICENSE file for details.
Bundled third-party components carry their own licenses, including VkFFT in third_party/ (MIT, Copyright © 2020–present Dmitrii Tolmachev).

