This project reconstructs a 3D rectangular parallelepiped from a single 2D image captured with an uncalibrated, zero-skew camera. It involves theoretical formulations and MATLAB implementations for vanishing lines, rectification mappings, and camera calibration, culminating in a 3D rendering of the results.
This project is part of the Image Analysis and Computer Vision (IACV) course (2024-2025) at Politecnico di Milano.
- Feature Extraction: Edge and corner detection using the Canny and Harris algorithms.
- Homography & Rectification: Stratified method for affine and metric rectification.
- Camera Calibration: Recovery of the camera calibration matrix.
- 3D Reconstruction: Visualization of the computed parallelepiped.
├── assets/ # Images used in the report and results
├── code/ # MATLAB scripts
│ ├── HomeworkIACV_code.m # Full MATLAB code
│ ├── HomeworkIACV_code.mlx # Main script for processing
│ ├── code_sections/ # Code sections
│ │ ├── feature_extraction.mlx # Edge and corner detection
│ │ ├── rectification.mlx # Homography and rectification functions
│ │ ├── calibration.mlx # Camera calibration
│ │ ├── rendering.mlx # 3D visualization
├── data/ # Report and documentation
│ ├── Homework Assignment 2024-25.pdf
│ ├── HomeworkIACV_report.pdf
│ ├── HomeworkIACV_results.pdf
├── README.md # Project documentation
- MATLAB installed.
- Clone the repository:
git clone https://github.com/CorraPiano/3D-reconstruction.git cd 3D-reconstruction - Open MATLAB and navigate to the
code/directory. - Run the main script:
HomeworkIACV_code
Below are the visual results of the reconstruction process. The initial image represents the raw input, while the final rendering showcases the reconstructed 3D parallelepiped.
Initial Image |
Final 3D Rendering |
The reconstruction process successfully recovered the depth and height of the parallelepiped, accurately computing the camera calibration matrix. The final 3D visualization provided insights into the spatial structure of the scene. Minor discrepancies in the curve reconstruction were observed, likely due to image quality and manual feature extraction limitations. Despite these, the overall approach proved effective for 3D reconstruction from a single image.
This project is licensed under the MIT License.
For inquiries, please reach out via GitHub issues.

