marimo-team /
marimo
A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Loading repository data…
MayankD409 / repository
A Python script for creating a 3D reconstruction of a scene while simultaneously determining the camera positions relative to that scene (Structure from Motion).
This repository implements a Structure from Motion (SfM) pipeline to reconstruct 3D point clouds from a sequence of 2D images. The pipeline leverages feature detection, feature matching, camera pose estimation, triangulation, and point cloud visualization to generate a 3D representation of the observed scene.
Key Capabilities:
Clone the Repository
git clone https://github.com/MayankD409/Structure-From-Motion.git
cd Structure-From-Motion
Create a Virtual Environment (Optional but Recommended)
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install Dependencies
pip install -r requirements.txt
This command installs all necessary Python packages listed in requirements.txt.
Images (Data/): A sequence of images capturing the scene from different viewpoints. For optimal results:
Calibration File (K.txt): Contains the camera intrinsic matrix. The expected format is a plain text file with nine numerical values representing the 3x3 matrix, separated by spaces or newlines.
Example Content of K.txt:
718.8560 0.0000 607.1928
0.0000 718.8560 185.2157
0.0000 0.0000 1.0000
Note: Ensure that the calibration data is accurate and corresponds to the camera used to capture the images.
Execute the main.py script to start the SfM process. The script processes image pairs sequentially to reconstruct the 3D structure of the scene.
Navigate to the Project Directory
Ensure you're in the root directory of the project where main.py resides.
cd Structure-From-Motion
Run the Pipeline
Execute the following command, specifying the dataset directory:
python Wrapper.py
Monitor the Output
The script will process each image pair, displaying informative messages about each processing step. It will perform feature matching, pose recovery, triangulation, and visualize the reconstructed 3D point cloud.
Visualize the Point Cloud
An interactive window will display the 3D point cloud. You can rotate, zoom, and pan to inspect the reconstruction.
Save the Point Cloud
Upon completion, the script saves the point cloud as output_with_colors.ply in the project directory. This file can be opened with visualization tools like MeshLab or CloudCompare.
Example Command:
python Wrapper.py
Output:
Intrinsic Matrix K:
[[718.856 0. 607.1928]
[0. 718.856 185.2157]
[0. 0. 1. ]]
Processing image pair 1 and 2...
Total matches found: 1500
Good matches after ratio test: 1200
Camera pose recovered.
Triangulation completed.
...
After processing all image pairs, you'll see:
Total 3D points reconstructed: 500000
Point cloud shape: (500000, 3)
Color data shape: (500000, 3)
Point cloud saved to output_with_colors.ply
Structure from Motion pipeline completed successfully.
Feature Matching Parameters:
SIFT Features: The number of SIFT features is set to 5000 for dense feature extraction. Adjust nfeatures in feature_matching_and_display for different requirements.
FLANN Matcher Parameters: The algorithm and trees parameters can be tuned for performance and accuracy. Refer to OpenCV's FLANN Matcher documentation for more details.
Triangulation and Pose Recovery:
Essential Matrix Thresholds: The threshold parameter in findEssentialMat influences the RANSAC threshold. Adjust based on the noise level in your dataset.
Bundle Adjustment: Currently implemented as a simple pose refinement using solvePnP. For more accurate reconstructions, consider integrating advanced bundle adjustment libraries like Ceres Solver or g2o.
Visualization:
Point Cloud Colors: The pipeline extracts BGR color information from the first image in each pair. Modify extract_colors_from_image if you wish to use different color extraction strategies.
Point Cloud Density: High-density point clouds may be computationally intensive. Adjust the number of features or implement point cloud filtering as needed.
The Structure from Motion (SfM) pipeline reconstructs a 3D structure from a series of 2D images by estimating camera poses and triangulating matched feature points. Here's a step-by-step overview of the process implemented in this project:
Image Acquisition:
K.txt).Feature Detection and Matching:
Camera Pose Recovery:
Triangulation:
Bundle Adjustment (Optional):
solvePnP based on the 3D points and their 2D projections.Point Cloud Visualization:
Point Cloud Saving:
The project relies on the following Python libraries:
opencv-python): Computer vision library for image processing, feature detection, and matching.All dependencies can be installed using the provided requirements.txt file.
pip install -r requirements.txt
Selected from shared topics, language and repository description—not editorial ratings.
marimo-team /
A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
hardikvasa /
Python Script to download hundreds of images from 'Google Images'. It is a ready-to-run code!
a1studmuffin /
A Blender script to procedurally generate 3D spaceships
infinition /
Bjorn is a powerful network scanning and offensive security tool for the Raspberry Pi with a 2.13-inch e-Paper HAT. It discovers network targets, identifies open ports, exposed services, and potential vulnerabilities. Bjorn can perform brute force attacks, file stealing, host zombification, and supports custom attack scripts.
pythonnet /
Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers.
CadQuery /
A python parametric CAD scripting framework based on OCCT