ba-cuda
GPU-accelerated Bundle Adjustment using PyTorch with Analytical Jacobians.
Features
- SE3 Lie Group: Right perturbation convention for camera pose representation
- Analytical Jacobians: Fast and accurate gradient computation
- Batched Operations: Efficient GPU parallelization
- Levenberg-Marquardt Optimizer: Robust non-linear optimization
- Huber Loss: Robust to outliers
Installation
1. Install PyTorch (Required - Manual Installation)
⚠️ Important: PyTorch must be installed manually according to your CUDA version.
-
Check your CUDA version:
nvcc --version -
Install PyTorch from the official website:
For example, with CUDA 12.1:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
For CUDA 11.8:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
2. Install ba-cuda
pip install ba-cuda
Or from source:
git clone https://github.com/hunminkim98/BA_on_CUDA_130_Win.git
cd BA_on_CUDA_130_Win
pip install -e .
Quick Start
import torch
from ba_cuda import LevenbergMarquardtOptimizer
# Prepare your data
observations = torch.tensor(...) # (N_obs, 2) - 2D observations
points_3d = torch.tensor(...) # (N_obs, 3) - 3D points
camera_indices = torch.tensor(...) # (N_obs,) - camera index per observation
intrinsics = torch.tensor(...) # (N_cams, 3, 3)
distortions = torch.tensor(...) # (N_cams, 5)
initial_poses = torch.tensor(...) # (N_cams, 3, 4) - [R|t]
# Run optimization
optimizer = LevenbergMarquardtOptimizer()
optimized_poses, rmse = optimizer.optimize(
observations=observations,
points_3d=points_3d,
camera_indices=camera_indices,
intrinsics=intrinsics,
distortions=distortions,
initial_poses=initial_poses,
ref_cam_idx=0
)
print(f"Final RMSE: {rmse:.4f}")
API Reference
LevenbergMarquardtOptimizer
optimizer = LevenbergMarquardtOptimizer(
max_iterations=50, # Maximum LM iterations
abs_tolerance=1e-6, # Absolute convergence tolerance
rel_tolerance=1e-6, # Relative convergence tolerance
initial_damping=1e-3, # Initial LM damping factor
huber_delta=1.0, # Huber loss delta
device=None, # torch.device (auto-detects CUDA if available)
dtype=torch.float64 # Precision
)
Input Tensor Formats
| Tensor | Shape | Description |
|---|---|---|
observations |
(N_obs, 2) | 2D keypoint observations (u, v) |
points_3d |
(N_obs, 3) | 3D points in reference camera frame |
camera_indices |
(N_obs,) | Camera index for each observation |
intrinsics |
(N_cams, 3, 3) | Camera intrinsic matrices K |
distortions |
(N_cams, 5) | Distortion coefficients [k1, k2, p1, p2, k3] |
initial_poses |
(N_cams, 3, 4) | Initial camera poses [R |
Requirements
- Python >= 3.10
- PyTorch >= 2.0.0 (with CUDA support recommended)
- NumPy >= 1.20.0
License
MIT License
Metadata
Release files for ba-cuda 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ba_cuda-0.1.0.tar.gz | 11.2 kB | Without provenance | Details for ba_cuda-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ba_cuda-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for ba_cuda-0.1.0-py3-none-any.whl |
Total release size: 21.3 kB
Release files / ba_cuda-0.1.0.tar.gz
| Download URL | ba_cuda-0.1.0.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
550d8941b88a82228a4444851c927e2e5fc1eed56fc6fa15e7593773aefb5c80
|
|
BLAKE2b-256 checksum How to use checksums |
0bf0f18e3ebdb0a2f4713677ef013c49fb07a451dcec3cadcb3976e95f1bced7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.19
|
Release files / ba_cuda-0.1.0-py3-none-any.whl
| Download URL | ba_cuda-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e531d584bf2aec61bdf251d5e908d0fa9ec2a7319a5b41a4693bc4066f715366
|
|
BLAKE2b-256 checksum How to use checksums |
97bccc834cee5eb3d5b50ea607ae92ca8733e1a687b974271e409c294d6db258
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.19
|
Security for ba-cuda 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.