Active 3D Stabilization: Open source code for active 3D stabilization using multiprocessing
The software does not require an installation process to function.
The software required prerequisites for functioning properly. It requires the following Python packages
matplotlib
numba (required for JIT compiling numpy)
numpy
opencv_python
pandas
PIPython (PI piezo stage)
psutil
pylablib (Thorlabs camera control)
scikit_learn
scipy
tqdm
All the specific versions of the packages are mentioned and can be installed from the "requirements.txt" file. All packages can be directly installed using the command
pip install -r requirements.txt
Additionally, the software required the installation of third-party software - Thorcam (Download Link) and piMikroMove to control the Thorlabs cameras and PI piezo stage. These software provide the necessary .dll files for Python to interface with the devices.
During the installation of Thorcam software, the user will be asked to choose the driver required for the cameras (Image 1)
The user then should select the "USB" option and select "Entire feature will be installed on local hard drive" (Image 2)
Finally, the user should do the same for the "Camera Link" option (Image 3). After this, the user can proceed with the installation of the software.
The software is designed and tested using Thorlabs Zelux (CS165MU1/M) and PI piezo stage (P-545.3R8S PInano, E-727 Controller). The software has been tested on two computers with configuration - CPU
1) Intel i7-9750H - 2.60GHz, 16 GB RAM, NVIDIA GeForce RTX 2060 [Laptop]
2) Intel Xeon W-2245 - 3.90GHz, 128GB RAM, NVIDIA Quadro P1000 [Workstation]
The software is able to achieve comparable performance on both machines.
The software can be set and used in the following steps:
- create a new Python environment
- clone repository
- install requirements and associated software
- perform hardware checks
- run the main code script
Details for each step are given below:
-
Create a new Python, preferably for compatibility reasons, using Python Venv or Conda (if using Anaconda)
a) Pure Python Method
- Install Python 3.10.X from the package installer (Download Link)
- Make a new Python environment using the command :
-
python -m venv active_stabilizationb) Anaconda Method
- If you are using Anaconda, you can make a new environment using the command:
-
conda create --name active_stabilization python=3.10 conda activate active_stabilization
-
Once the environment is created, clone the active stabilization code on your local machine
The repository can be cloned on a local system using the command (preferably in a new folder)
git clone https://github.com/VicidominiLab/Active_stabilization.git -
After cloning, install the requirements as mentioned in "requirements.txt" file All the requirements can be installed using the command:
pip install -r requirements.txtAfter the requirements, Install the Thorcam and piMikroMove software as mentioned in Requirements
-
After installing the requirements, run the "req_test.py" file to perform the checks for all the requirements using the command:
python req_test.py -
Finally, if there are no errors, proceed to run the main stabilization script to start the active stabilization:
python stabilization_main.py
The code can be executed on Windows in any terminal program (Powershell, console emulator, terminal). It has been developed on Windows and tested in Powershell - which we recommend running the code with. The execution of the scripts is shown in the videos below
-
Execution without loading from the configuration file:- Without_config.webm
-
Execution with loading from the configuration file:- with_config.webm
The button presses are shown on the left side of the video.


