Skip to main content

Stabilizes video or extracted trajectories with respect to a selected reference frame in the video, with optional user-provided masks.

Project description

Stabilo

PyPI Version GitHub Release License DOI Downloads Development Status

Stabilo is a specialized Python package for stabilizing video frames or tracked object trajectories in videos, using robust homography or affine transformations. Its core functionality focuses on aligning each frame or object track to a chosen reference frame, enabling precise stabilization that mitigates disturbances like camera movements. Key features include robust keypoint-based image registration and the option to integrate user-defined masks, which exclude dynamic regions (e.g., moving objects) to enhance stabilization accuracy. Integrating seamlessly with object detection and tracking algorithms, Stabilo is ideal for high-precision applications like urban traffic monitoring, as demonstrated in the geo-trax 🚀 trajectory extraction framework. Extensive transformation and enhancement options, including multiple feature detectors and matchers, masking techniques, further expand its utility. The repository also includes valuable resources like utility scripts and example videos to demonstrate its capabilities.

Stabilization Visualization GIF

Features

  • Video Stabilization: Align (warp) all video frames to a custom (anchor) reference frame using homography or affine transformations.
  • Trajectory Stabilization: Transform object trajectories (e.g., bounding boxes) to a common fixed reference frame using homography or affine transformations.
  • User-Defined Masks: Allow users to specify custom masks to exclude regions of interest during stabilization.
  • Wide Range of Algorithms: Includes support for various feature detectors (ORB, (R)SIFT, BRISK, (A)KAZE), matchers (BF, FLANN), RANSAC algorithms (MAGSAC++, DEGENSAC, ...), transformation types, and pre-processing options.
  • Customizable Parameters: Fine-tune the stabilization by adjusting parameters such as the number of keypoints, RANSAC parameters, matching thresholds, downsampling factors, etc..
  • Visualization Tools: Generate visualizations of the stabilization process, with frame-by-frame comparisons and trajectory transformations (see the above animation).
  • Threshold Analysis: Analyze the relationship between detection thresholds and keypoint counts for BRISK, KAZE, and AKAZE to fairly benchmark with different detectors.
  • Benchmarking Campaigns: Use stabilo-optimize 🎯 to establish benchmarking campaigns to optimize algorithm and hyperparameter selection for specific applications.
🚀 Planned Enhancements
  • Unit Tests: Comprehensive unit test suite to ensure package stability and reliability.
  • Different Mask Types: Inclusion of additional mask types (e.g., polygonal, circular) for enhanced precision in stabilization.
  • GPU Acceleration: Integration of GPU acceleration to improve processing speed.
  • Documentation: Detailed documentation covering the package’s functionality and usage.

Installation

First, create a Python Virtual Environment (Python >= 3.9) using e.g., Miniconda3:

conda create -n stabilo python=3.9 -y
conda activate stabilo

Then, install the stabilo library using one of the following options:

Option 1: Install from PyPI

You can install the package from PyPI using pip:

pip install stabilo

Option 2: Install from Source

You can install the package directly from the repository:

pip install git+https://github.com/rfonod/stabilo.git

Option 3: Install from Local Source

You can also clone the repository and install the package from the local source:

git clone https://github.com/rfonod/stabilo.git
cd stabilo
pip install .

If you want the changes you make in the repo to be reflected in your install, use pip install -e . instead of pip install ..

Example Usage

from stabilo import Stabilizer 

# Create an instance of the Stabilizer class with default parameters
stabilizer = Stabilizer() 

# Set a reference frame with (optional) mask
stabilizer.set_ref_frame(ref_frame, ref_mask)

# Stabilize any frame with (optional) mask
stabilizer.stabilize(cur_frame, cur_mask)

# Get the stabilized (warped) frame 
stabilized_frame = stabilizer.warp_cur_frame()

# Transform current masks (bounding boxes) if it was provided
stabilized_boxes = stabilizer.transform_cur_boxes()

# Transform any point (pixel coordinates) from the current frame to reference frame
cur_point = np.array([x, y, 1])
ref_point = stabilizer.get_cur_trans_matrix() @ cur_point

Utility Scripts

Utility scripts are provided to demonstrate the functionality of the Stabilo package. These scripts can be found in the scripts directory.

Stabilization Examples

  • stabilize_video.py: Implements video stabilization relative to a reference frame.
  • stabilize_boxes.py: Implements object trajectory stabilization relative to a reference frame.

Threshold Analysis

  • find_threshold_models.py: Computes regression models between detection thresholds and average keypoint counts for BRISK, KAZE, and AKAZE feature detectors.

Citing This Work

If you use this project in your academic research, commercial products, or any published material, please acknowledge its use by citing it.

  1. Preferred Citation: For research-related references, please cite the related paper once it is formally published. A preprint is currently available on arXiv:
@misc{fonod2024advanced,
  title={Advanced computer vision for extracting georeferenced vehicle trajectories from drone imagery}, 
  author={Robert Fonod and Haechan Cho and Hwasoo Yeo and Nikolas Geroliminis},
  year={2024},
  eprint={2411.02136},
  archivePrefix={arXiv},
  primaryClass={cs.CV},
  url={https://arxiv.org/abs/2411.02136},
  doi={https://doi.org/10.48550/arXiv.2411.02136}
}
  1. Repository Citation: For direct use of the stabilo repository, please cite the software release version on Zenodo. You may refer to the DOI badge above for the correct version or use the BibTeX below:
@software{fonod2024stabilo,
author = {Fonod, Robert},
license = {MIT},
month = nov,
title = {Stabilo: A Comprehensive Python Library for Video and Trajectory Stabilization with User-Defined Masks},
url = {https://github.com/rfonod/stabilo},
doi = {10.5281/zenodo.12117092},
version = {1.0.0},
year = {2024}
}

To ensure accurate and consistent citations, a CITATION.cff file is included in this repository. GitHub automatically generates a formatted citation from this file, accessible in the "Cite this repository" option at the top right of this page.

Please select the correct citation based on your use:

  • Methodology: For referencing the research framework and methodology, cite the journal paper (or preprint if unpublished).
  • Repository: For direct use of the code, cite the Zenodo release of this GitHub repository.

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open a GitHub Issue or submit a pull request. Your contributions are greatly appreciated!

License

This project is licensed under the MIT License, an OSI-approved 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 file. Thank you!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stabilo-1.0.0.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stabilo-1.0.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file stabilo-1.0.0.tar.gz.

File metadata

  • Download URL: stabilo-1.0.0.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for stabilo-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ee934ec6fb56f684247a0fb183bc037afd29cc3e3da342bf29cf9537a984aee5
MD5 1c2fabedeab93180caf78eb670db975c
BLAKE2b-256 3b252f8fa36ce0108a863db9266a02d9cc822bca44050b6f58d1e1b1e139d065

See more details on using hashes here.

File details

Details for the file stabilo-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: stabilo-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for stabilo-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6af0557fea7bc389845c7fe55fb5c4dbe0431c0cc2c0051a4d9a9613ebfc30ff
MD5 2e3737317c9a85333d836f214f86e7e9
BLAKE2b-256 f377b0deb16971c94d038c977139e8baa160e45b49a27414d0a30d282b7301d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page