Skip to main content

RGBD SLAM Module

This module provides a prototype solution for RGB-D SLAM (Simultaneous Localization and Mapping) using Python. The code integrates several key libraries, such as OpenCV, Open3D, and SciPy, to process RGB-D images, perform visual odometry, and visualize results.

Features

  • Loading Camera Intrinsics: Load camera intrinsics from a file.
  • Combining RGB and Depth Images: Combine RGB and depth images for processing.
  • Visualizing RGB-D Images: Visualize RGB-D images using Matplotlib and Open3D.
  • Performing RGB-D Odometry: Perform visual odometry using Open3D.
  • Sequence Processing: Process sequences of RGB-D images.
  • Hybrid Visual Odometry: Combine color and depth information for odometry using feature tracking and 3D points.

Installation

Install from pypi

rgbdslam is on pypi!

pip install rgbdslam

Local install

  1. Clone this repository:

    git clone https://github.com/hugohadfield/rgbdslam.git
    cd rgbdslam
    
  2. Install with pip:

    pip install .
    

Dependencies

Ensure you have the following Python libraries installed:

  • numpy
  • Pillow
  • click
  • matplotlib
  • tqdm
  • pandas
  • open3d
  • opencv-python
  • scipy

You can install these dependencies using pip:

pip install numpy Pillow click matplotlib tqdm pandas open3d opencv-python scipy

Usage

CLI Commands

The module provides a command-line interface (CLI) to process images.

Single Image Pair

Process a single pair of RGB and depth images:

python rgbdslam.py single-image-pair <rgb_path_a> <depth_path_a> <rgb_path_b> <depth_path_b>

Directory of Images

Process a directory of RGB and depth images:

python rgbdslam.py run-on-directory <rgb_path> <depth_path> <output_csv>

Example

To run the SLAM algorithm on a directory of images:

python rgbdslam.py run-on-directory rgb/ depth/ output.csv

This command processes all RGB and depth images in the rgb/ and depth/ directories and saves the results in output.csv.

Functions

load_intrinsics(intrinsics_path: str) -> np.ndarray

Load camera intrinsics from a file.

combine_rgb_depth(rgb_path: str, depth_path: str) -> np.ndarray

Combine RGB and depth images into a single image for processing.

visualise_rgbd_matplotlib(rgbd_image: np.ndarray)

Visualize an RGBD image using Matplotlib.

visualise_rgbd_o3d(rgbd_image: np.ndarray)

Visualize an RGBD image using Open3D.

extract_translation_from_4x4_matrix(matrix: np.ndarray) -> np.ndarray

Extract translation information from a 4x4 transformation matrix.

o3d_rgbd_vo(rgdb_a: np.ndarray, rgdb_b: np.ndarray, intrinsic_matrix: np.ndarray)

Perform RGBD Odometry using Open3D.

o3d_rgbd_sequence(rgbd_image_list: List[np.ndarray], intrinsic_matrix: np.ndarray, use_tqdm: bool = True)

Process a sequence of RGB-D images.

odom_extract_scipy_minimize(points_3d, points_2d, intrinsic_matrix)

Extract yaw and distance using SciPy's minimize function.

odom_extract_opencv_pnpransac(points_3d, points_2d, intrinsic_matrix)

Extract yaw and distance using OpenCV's solvePnPRansac.

hybrid_rgbd_odometry(rgbd_image_list: List[np.ndarray], intrinsic_matrix: np.ndarray, use_tqdm: bool = True, backward: bool = False)

Perform hybrid visual odometry using both color and depth information.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

License

This project is licensed under the MIT License.

Contact

For questions or suggestions, please get in contact with Hugo Hadfield, contact details can be found on his website.

Metadata

Release files for rgbdslam 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rgbdslam 0.0.4
File Size Uploaded
rgbdslam-0.0.4.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rgbdslam 0.0.4
File Interpreter ABI Platform
rgbdslam-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 21.7 kB

Release files / rgbdslam-0.0.4.tar.gz

Download URL rgbdslam-0.0.4.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
85355f040932fbf7e5306335e9a055919cedabfde3bae826b2caeb430afd7c0b
BLAKE2b-256 checksum
How to use checksums
efc60d7133f6fee80ab45767c8a8c53e2713dfeb5aac1a758b76fa42d04a9c24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / rgbdslam-0.0.4-py3-none-any.whl

Download URL rgbdslam-0.0.4-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6025381e2f7c3fe10f6c691736fd7fbc589cb4ee01b5efd1849257e70bd2bece
BLAKE2b-256 checksum
How to use checksums
7ea571d63c54a547adbd03c9c225439dfcd3dc35422e7f3e87218287ab3b5f2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page