This repository provides a comprehensive framework for exploring the use of gradient descent and homotopy continuation techniques in image rectification. The goal is to evaluate whether these methods offer greater robustness compared to traditional numerical and symbolic solvers, and to determine which of the two performs more effectively.
A detailed description of the project is available in the report.
Sample videos demonstrating image rectification via gradient descent can be found here.
- Filippo Balzarini
- Paolo Ginefra
- Martina Missana
The project leverages the usage of Adam's optimization method to perform image rectification.
The project leverages the HomotopyContinuation.jl package for solving systems of polynomial equations using the Homotopy Continuation approach.
To test the application of homotopy continuation techniques to image rectification it is used a simulator with the following pipeline:
-
Given a scene definition it generates synthetic scenes warping three circles and creating an homography matrix.
-
Abstract class to reconstruct the scene using different approaches:
It reconstruct the image computing an homography matrix.
-
Computes reconstruction errors and distortions using various metrics:
-
uses the eccentricity of the reconstructed conics.
-
uses the cosine of the angle between two perpendicular lines.
-
uses the distance of the reconstructed circular points from the true ones.
-
uses Frobenius norm of the difference between two homography matrices.
-
uses the angle between the lines at infinity.
-
uses the L2 norm of the difference between the warped points using the true and the computed homographies.
-
-
Create a virtual environment:
python -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt -
Install the package in development mode:
pip install -e .
-
Install Julia from JuliaLang.org
-
Install the
HomotopyContinuationpackage:using Pkg Pkg.add("HomotopyContinuation")
- Install MATLAB from MathWorks
-
Build and start the services:
docker-compose up -d -
Example Julia API call:
curl -X POST http://localhost:8081/rectify \ -H "Content-Type: application/json" \ -d '{"conics": [ [1.0, 0.0, 1.0, 0.0, 0.0, -1.0], [1.0, 0.0, 0.0, 0.0, 0.0, -1.0], [0.0, 0.0, 1.0, 0.0, 0.0, -1.0] ]}' ```
-
Example Conics Intersection API call:
curl -X POST http://localhost:8082/intersect \ -H "Content-Type: application/json" \ -d '{"conics": [ [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, -1.0]], [[3.0, 0.0, 0.0], [0.0, 0.0, -0.5], [0.0, -0.5, -2.0]] ]}' ```
-
Check services health:
curl http://localhost:8081/health curl http://localhost:8082/health
To test different experiment parameters Optuna is used. To visualize the Optuna dashboard
optuna-dashboard sqlite:///db.sqlite3To run the tests for the Python package, use the following command:
pytest