bag2mesh is a powerful, standalone Python tool designed to convert ROS Bag files (specifically from RGB-D cameras like Intel RealSense) into high-quality 3D Meshes (.ply).
Unlike many other tools, this does not require a ROS installation. It uses rosbags to read data directly and Open3D for advanced processing, making it lightweight and easy to run on Windows, Linux, or macOS.
- No ROS Required: Runs purely on Python.
- Robust Tracking: Implements a Local Map ICP strategy with Constant Velocity prediction to maintain tracking even during fast movements.
- Anti-Ghosting: Smart keyframe selection and strict validation logic prevent "double vision" or ghosting artifacts in the final model.
- High-Fidelity Meshing: Uses Poisson Surface Reconstruction with customizable depth and density trimming to produce watertight or clean surfaces.
- Auto-Colorization: Projects color data from the RGB camera onto the generated mesh.
- Fully Parametric: Almost every aspect of the pipeline (tracking, filtering, meshing) can be tuned via command-line arguments.
-
Clone the repository:
git clone https://github.com/yourusername/bag2mesh.git cd bag2mesh -
Install dependencies:
pip install -r requirements.txt
(Dependencies:
open3d,rosbags,numpy,opencv-python,tqdm)
Convert a bag file to a mesh using default settings (good for most room-scale scans):
python bag2mesh.py input.bag output.plyFor scanning a small object (e.g., a chair) with high detail:
python bag2mesh.py object.bag chair.ply --voxel_size 0.01 --poisson_depth 11 --density_threshold 0.2If scanning an object on a turntable with a fixed camera, use --max_depth to remove the background:
python bag2mesh.py turntable.bag object.ply --max_depth 0.8To quickly check the geometry without waiting for high-res processing:
python bag2mesh.py large_scan.bag preview.ply --step 5 --voxel_size 0.05 --poisson_depth 8For a detailed explanation of all parameters, defaults, and tuning guides, please refer to the Wiki Documentation.
-
"Ghosting" (Double objects):
- Increase
--keyframe_movement_threshold(e.g., to0.15or0.20). - Increase
--voxel_sizeslightly. - Ensure
--max_translation_jumpis not too high.
- Increase
-
Mesh is too "bubbly" or fills empty spaces:
- Increase
--density_threshold(e.g., to0.4).
- Increase
-
Mesh is too rough/noisy:
- Decrease
--poisson_depth(e.g., to9or10). - Decrease
--outlier_std_ratio(e.g., to1.0).
- Decrease
-
Tracking lost (Mesh is scrambled):
- Increase
--coarse_threshold_multiplier. - Increase
--window_size. - Try processing every frame (
--step 1).
- Increase
MIT License