Skip to content

Commit 7ea215a

Browse files
committed
initial commit
0 parents  commit 7ea215a

File tree

97 files changed

+13806
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+13806
-0
lines changed

.gitignore

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# Distribution / packaging
7+
.Python
8+
build/
9+
develop-eggs/
10+
dist/
11+
downloads/
12+
eggs/
13+
.eggs/
14+
lib/
15+
lib64/
16+
parts/
17+
sdist/
18+
var/
19+
wheels/
20+
pip-wheel-metadata/
21+
share/python-wheels/
22+
*.egg-info/
23+
.installed.cfg
24+
*.egg
25+
MANIFEST
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.nox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
*.py,cover
48+
.hypothesis/
49+
.pytest_cache/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Sphinx documentation
56+
docs/_build/
57+
58+
# PyBuilder
59+
target/
60+
61+
# pyenv
62+
.python-version
63+
64+
# Environments
65+
.env
66+
.venv
67+
env/
68+
venv/
69+
ENV/
70+
env.bak/
71+
venv.bak/
72+
73+
# VS Code
74+
.vscode
75+
!.vscode/settings.json
76+
!.vscode/tasks.json
77+
!.vscode/launch.json
78+
!.vscode/extensions.json
79+
*.code-workspace
80+
81+
# Local History for Visual Studio Code
82+
.history/
83+
84+
# Mac OS-specific storage files
85+
.DS_Store
86+
**/.DS_Store
87+
88+
# Google Drive related
89+
.tmp.driveupload
90+
.tmp.drivedownload
91+
92+
# Data
93+
/data
94+
*.mp4
95+
96+
# Misc
97+
TODOs.txt
98+

CITATION.cff

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cff-version: 1.2.0
2+
title: Stabilo
3+
abstract: Reference frame video stabilization with or without user-provided masks.
4+
message: If you use this software, please cite it as below.
5+
type: software
6+
authors:
7+
- given-names: Robert
8+
family-names: Fonod
9+
email: robert.fonod@ieee.org
10+
affiliation: EPFL
11+
orcid: 'https://orcid.org/0000-0002-9434-3156'
12+
identifiers:
13+
- type: doi
14+
value: XXX
15+
description: Zenodo archive
16+
repository-code: 'https://github.com/rfonod/stabilo'
17+
url: 'https://github.com/rfonod/stabilo'
18+
license: MIT
19+
version: 0.1.0
20+
date-released: '2024-06-18'

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Robert Fonod
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Stabilo
2+
3+
![GitHub Release](https://img.shields.io/github/v/release/rfonod/stabilo?include_prereleases) [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) ![GitHub](https://img.shields.io/badge/Development-Active-brightgreen)
4+
5+
🚧 **Development Notice** 🚧
6+
7+
> ⚠️ **IMPORTANT:** Stabilo is currently in its preliminary stages and under active development. Not all features are complete, and significant changes may occur. It is recommended for experimental use only. Please report any issues you encounter, and feel free to contribute to the project.
8+
9+
Stabilo is a Python package for stabilizing video frames or tracked object trajectories in videos using homography or affine transformations, with optional user-provided masks that define areas to ignore during stabilization. It is optimized for use in environments where accurate, frame-by-frame alignment is crucial, such as video surveillance and research applications. For instance, Stabilo can be integrated with object detection and tracking algorithms to stabilize trajectories, enhancing the performance of such systems. See for example [this project](https://github.com/rfonod/geo-trax). The package offers flexibility through a variety of transformation and enhancement options, including the ability to handle different types of feature detection and masking techniques.
10+
11+
## Features
12+
13+
- **Video Stabilization**: Align video frames to a selected reference using homography or affine transformations.
14+
- **Trajectory Stabilization**: Apply stabilization to object trajectories using homography or affine transformations.
15+
- **User-Defined Masks**: Allow users to specify areas to ignore during stabilization, such as bounding boxes of moving objects or regions of no interest.
16+
- **Wide Range of Algorithms**: Support for various feature detectors (e.g., ORB, (R)SIFT, BRISK, (A)KAZE), matchers (e.g., BF, FLANN), RANSAC algorithms, transformation types, and pre-processing options.
17+
- **Customizable Parameters**: Fine-tune the stabilization process by adjusting parameters such as the number of keypoints, RANSAC and matching thresholds, and downsampling factors.
18+
- **Visualization Tools**: Generate visualizations of the stabilization process, including frame-by-frame comparisons.
19+
- **Threshold Analysis**: Analyze the relationship between detection thresholds and keypoint counts for BRISK, KAZE, and AKAZE feature detectors.
20+
21+
<details>
22+
<summary><b>🚀 Planned Enhancements</b></summary>
23+
24+
- **Benchmarking and Tuning Tools**: Develop tools to benchmark and tune the performance of the stabilization algorithms.
25+
- **Trajectory Stabilization Script**: Create a script to stabilize object trajectories in videos.
26+
- **Custom Mask Encoding**: Support for more generic types of custom mask encodings.
27+
- **Custom Reference Frame Selection**: Allow users to select a custom reference frame for stabilization.
28+
- **GPU Acceleration**: Utilize GPU acceleration for faster processing.
29+
- **Documentation**: Provide detailed documentation and examples for ease of use.
30+
- **Unit Tests**: Implement comprehensive unit tests to ensure the stability and reliability of the package.
31+
- **Deployment to PyPI**: Publish the package on PyPI for easy installation and distribution.
32+
33+
</details>
34+
35+
## Installation
36+
37+
First, create a **Python Virtual Environment** (Python >= 3.9) using e.g., [Miniconda3](https://docs.anaconda.com/free/miniconda/):
38+
```bash
39+
conda create -n stabilo python=3.9 -y
40+
conda activate stabilo
41+
```
42+
43+
Then, install the package using one of the following methods:
44+
45+
### Option 1: Install from PyPI
46+
You can install the package from PyPI (not available yet):
47+
48+
<strike>
49+
50+
```sh
51+
pip install stabilo
52+
```
53+
54+
</strike>
55+
56+
57+
### Option 2: Install from Source (recommended)
58+
You can install the package directly from the repository:
59+
```sh
60+
pip install git+https://github.com/rfonod/stabilo.git
61+
```
62+
63+
### Option 3: Install from Local Source
64+
65+
Clone the repository and install the package:
66+
67+
```sh
68+
git clone https://github.com/rfonod/stabilo.git
69+
cd stabilo
70+
pip install .
71+
```
72+
73+
If you want the changes you make in the repo to be reflected in your install, use `pip install -e .` instead of `pip install .`.
74+
75+
## Example Usage
76+
77+
```python
78+
from stabilo import Stabilizer
79+
80+
# Create an instance of the Stabilizer class with default parameters
81+
stabilizer = Stabilizer()
82+
83+
# Set a reference frame with optional mask (e.g., bounding boxes)
84+
stabilizer.set_ref_frame(ref_frame, ref_mask)
85+
86+
# Stabilize any consecutive frame with optional mask
87+
stabilizer.stabilize(frame, mask)
88+
89+
# Get the stabilized (warped to the reference frame) frame
90+
stabilized_frame = stabilizer.warp_cur_frame()
91+
92+
# Get the transformed bounding boxes (if mask was provided)
93+
stabilized_boxes = stabilizer.transform_cur_boxes()
94+
```
95+
96+
## Additional Scripts
97+
98+
Utility scripts are provided to demonstrate the functionality of the Stabilo package. These scripts can be found in the `scripts` directory.
99+
100+
#### Stabilization Examples
101+
102+
- `stabilize_video.py`: Demonstrates video stabilization relative to a reference frame.
103+
- `stabilize_boxes.py`: Shows how to stabilize bounding boxes relative to a reference frame.
104+
105+
#### Threshold Analysis
106+
107+
The `find_threshold_models.py` script is designed to model the relationship between detection thresholds for BRISK, KAZE, and AKAZE feature detectors and their average keypoint counts. It outputs regression models, saves pertinent data, and generates plots for visual analysis.
108+
109+
To run this script, install the optional dependencies `pip install .[extras]` (or `pip install '.[extras]'` if you use zsh).
110+
111+
## Citing This Work
112+
113+
If you use this project in your academic research, commercial products, or any published material, please acknowledge its use by citing it. For the correct citation, refer to the DOI badge above, which links to the appropriate version of the release on Zenodo. Ensure you reference the version you actually used. A formatted citation can also be obtained from the top right of the [GitHub repository](https://github.com/stabilo).
114+
115+
```bibtex
116+
@software{Fonod_Stabilo_2024,
117+
author = {Fonod, Robert},
118+
license = {MIT},
119+
month = jun,
120+
title = {{Stabilo}},
121+
url = {https://github.com/rfonod/stabilo},
122+
version = {0.1.0},
123+
year = {2024}
124+
}
125+
```
126+
127+
## Contributing
128+
129+
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open a [GitHub Issue](https://github.com/rfonod/stabilo/issues) or submit a pull request. Your contributions are greatly appreciated!
130+
131+
132+
## License
133+
134+
This project is licensed under the MIT License, an [OSI-approved](https://opensource.org/licenses/MIT) open-source license, which allows for both academic and commercial use. By citing this project, you help support its development and acknowledge the effort that went into creating it. For more details, see the [LICENSE](LICENSE) file. Thank you!

pyproject.toml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "stabilo"
7+
dynamic = ["version"]
8+
description = "Reference frame video stabilization with optional user-provided masks."
9+
authors = [
10+
{ name = "Robert Fonod", email = "robert.fonod@ieee.org" },
11+
]
12+
readme = "README.md"
13+
license = { file = "LICENSE" }
14+
requires-python = ">=3.9"
15+
keywords = ["stabilo", "video-stabilization", "object-stabilization", "mask", "reference-frame", "computer-vision"]
16+
classifiers = [
17+
"Development Status :: 3 - Alpha",
18+
"License :: OSI Approved :: MIT License",
19+
"Programming Language :: Python :: 3.9",
20+
"Programming Language :: Python :: 3.10",
21+
"Programming Language :: Python :: 3.11",
22+
"Topic :: Software Development",
23+
"Topic :: Scientific/Engineering",
24+
]
25+
26+
dependencies = [
27+
"numpy>=1.26.4,<2.0",
28+
"opencv-python>=4.6.0",
29+
"pyyaml>=5.3.1",
30+
"tqdm>=4.64.0",
31+
]
32+
33+
[project.optional-dependencies]
34+
extras = [
35+
"matplotlib>=3.5.0"
36+
]
37+
38+
[tool.setuptools]
39+
packages = { find = { where = ["."], include = ["stabilo", "stabilo.*"] } }
40+
package-data = { "stabilo" = ["**/*.yaml", "**/*.txt"] }
41+
42+
[tool.setuptools.dynamic]
43+
version = { attr = "stabilo.__version__" }
44+
45+
[project.urls]
46+
homepage = "https://github.com/rfonod/stabilo/"
47+
repository = "https://github.com/rfonod/stabilo/"
48+
issues = "https://github.com/rfonod/stabilo/issues/"
49+
releases = "https://github.com/rfonod/stabilo/releases"

scripts/find_thresholds/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# find_thresholds.py
2+
3+
## Description
4+
The `find_thresholds.py` script is designed to derive linear regression models for the BRISK, KAZE, and AKAZE feature detectors. These models aim to establish the correspondence between the average number of detected keypoints in an image and the threshold value applied by the detectors. The script employs a diverse image dataset with optional axis-aligned bounding boxes representing regions where features should not be detected. Additionally, histogram normalization using CLAHE may influence the models, leading to the creation of separate models for all combinations of mask usage and CLAHE application. The resulting threshold models play a crucial role in configuring the Stabilo module, enabling a fair comparison with other detectors like ORB, SIFT, and RSIFT.
5+
6+
## Usage
7+
```
8+
python find_thresholds.py --dataset-dir=<dir>
9+
10+
Options
11+
--dataset-dir=<dir>: Directory containing the diverse image dataset (default: scenes/).
12+
```
13+
14+
## Dataset Requirements
15+
16+
1. **Diverse Set of Images**: The dataset should include a diverse set of images representing various scenarios.
17+
2. **Axis-Aligned Bounding Boxes (Optional)**: The images may come with axis-aligned bounding boxes representing regions where features should not be detected.
18+
19+
## Script Functionality
20+
- **Threshold Models**: Finds linear models for BRISK, KAZE, and AKAZE detectors, considering various combinations of detectors, mask usage, and CLAHE.
21+
- **Data Generation**: Collects data by finding the average number of detected keypoints for different threshold values.
22+
- **Model Fitting**: Fits linear models to the collected data, considering a specified range of keypoints.
23+
- **Data Filtering**: Filters the collected data to fit the model only within a specified range of keypoints.
24+
- **Data and Model Storage**: Saves raw and filtered data, as well as the linear models for further analysis.
25+
- **Plotting**: Generates and saves plots illustrating the relationship between average keypoints and thresholds.
26+
27+
## Important Notes
28+
- The dataset should be carefully crafted to ensure a representative set of images with diverse content and scenarios.
29+
- Axis-aligned bounding boxes can be provided to guide the feature detection process and create more meaningful threshold models.
30+
- The generated models will be stored in the `models` directory, while the data and plots will be saved in the `results` and `plots` directories, respectively.
31+
32+
Feel free to adapt the script and instructions based on your specific dataset and requirements.

0 commit comments

Comments
 (0)