A Python module for RGB-D SLAM using OpenCV, Open3D, and SciPy
Project description
RGBD SLAM Module
This module provides a comprehensive 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
-
Clone this repository:
git clone https://github.com/hugohadfield/rgbdslam.git cd rgbdslam
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rgbdslam-0.0.3.tar.gz
.
File metadata
- Download URL: rgbdslam-0.0.3.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6966555c533ec05ac234d08254600c1c6e15ef853f57ea23ace313052603fedb |
|
MD5 | 6a3faf5a97523460f8ad7ee29a836c4d |
|
BLAKE2b-256 | e75a2464f8c11c185838da351385a0353117c96bc5be4e119ca9b85120c1a305 |
File details
Details for the file rgbdslam-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: rgbdslam-0.0.3-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd109f0b011546b69d9cc12e809dda83d2e95a2903272d8698dcd60711ad5947 |
|
MD5 | 242f023bdcaab00cfc646c0006e4be3a |
|
BLAKE2b-256 | 9f6c4ef8e8f79e94b971ef149c4735542572573f75f2fc1e2ff3c9b5d6aa35cb |