Skip to main content

A Python module for RGB-D SLAM using OpenCV, Open3D, and SciPy

Project description

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.

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

rgbdslam-0.0.4.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

rgbdslam-0.0.4-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file rgbdslam-0.0.4.tar.gz.

File metadata

  • Download URL: rgbdslam-0.0.4.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for rgbdslam-0.0.4.tar.gz
Algorithm Hash digest
SHA256 85355f040932fbf7e5306335e9a055919cedabfde3bae826b2caeb430afd7c0b
MD5 b9289a799e2d6256aeb98de2ed2758f7
BLAKE2b-256 efc60d7133f6fee80ab45767c8a8c53e2713dfeb5aac1a758b76fa42d04a9c24

See more details on using hashes here.

File details

Details for the file rgbdslam-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: rgbdslam-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for rgbdslam-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6025381e2f7c3fe10f6c691736fd7fbc589cb4ee01b5efd1849257e70bd2bece
MD5 8c918b3c45322a1ba28cb55ee1d592b5
BLAKE2b-256 7ea571d63c54a547adbd03c9c225439dfcd3dc35422e7f3e87218287ab3b5f2d

See more details on using hashes here.

Supported by

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