This project performs Structure from Motion (SfM) and Iterative Closest Point (ICP) alignment on a series of images to generate and merge point clouds.
Ensure you have the required dependencies installed. You can install them using:
uv syncEnsure your datasets are organized in subdirectories within a main directory. Each subdirectory should contain images for that dataset.
Load the chessboard images and calibrate the camera to generate the intrinsic matrix. This step is required for SfM.
uv run src/calibrate.py <dataset_path> <chessboard_dims> -s <scale_factor> -o <output_dir><dataset_path>: Path to the dataset containing chessboard images.<chessboard_dims>: Dimensions of the chessboard in WxH format (e.g., 4x4).<scale_factor>: Scale factor for image pyramid downscaling (optional).<output_dir>: Directory to save camera parameters (optional).
Example:
uv run src/calibrate.py chessboard/ 4x4 -s 2 -o camera_paramsOnce the camera is calibrated, copy the instrinsic matrix K.npy to each dataset subdirectory.
Run SfM on the datasets to generate point clouds. Use the following command:
uv run src/sfm.py <datasets_dir> <output_dir> -s <downscale_factor><datasets_dir>: Directory containing subdirectories with datasets.<output_dir>: Directory to save the output point clouds.<downscale_factor>: Downscale factor for image loading (optional).
Example:
uv run src/sfm.py datasets output -s 2This will generate point clouds for each dataset in the output directory. The point clouds will be saved as PLY files in the format dataset_name.ply.
Merge the generated point clouds using ICP. Use the following command:
uv run src/icp.py <input_dir> <output_dir> -i <max_iter> -t <tol> -s <std_ratio> -n <nb_neighbors> -d <threshold><input_dir>: Path to the directory containing point cloud PLY files.<output_dir>: Path to the directory to save the merged point cloud.<max_iter>: Maximum number of ICP iterations (optional).<tol>: Tolerance for ICP convergence (optional).<std_ratio>: Standard deviation ratio for statistical outlier removal (optional).<nb_neighbors>: Number of neighbors to analyze for each point in statistical outlier removal (optional).<threshold>: Distance threshold for ICP (optional).
Example:
uv run src/icp.py point_clouds outputNote
On wayland linux distros, Open3D fails to initialize GTK, use this env variable as a workaround.
XDG_SESSION_TYPE=x11 uv run src/icp.py point_clouds outputTo run the unit tests, use the following command:
pytestThis will execute all the unit tests in the tests directory.
This project is licensed under the MIT License. See the LICENSE file for details.