Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: code cleanup. #368

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions python/oddkiva/combination.py

This file was deleted.

2 changes: 2 additions & 0 deletions python/oddkiva/sara/sfm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The code in this folder are mostly a collection of results we reuse in the C++
code.
33 changes: 20 additions & 13 deletions python/oddkiva/sara/sfm/five_point_algorithm.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import sympy as sp
from sympy.abc import x, y, z
def calculate_E_matrix_constraints_from_5_point():
import sympy as sp
from sympy.abc import x, y, z

# Solve the cubic polynomial.
X = sp.MatrixSymbol('X', 3, 3)
Y = sp.MatrixSymbol('Y', 3, 3)
Z = sp.MatrixSymbol('Z', 3, 3)
W = sp.MatrixSymbol('W', 3, 3)
# Solve the cubic polynomial.
#
# The essential matrix lives in the nullspace which is spanned by 4
# eigenvectors.
X = sp.MatrixSymbol('X', 3, 3)
Y = sp.MatrixSymbol('Y', 3, 3)
Z = sp.MatrixSymbol('Z', 3, 3)
W = sp.MatrixSymbol('W', 3, 3)

# Form the symbolic matrix expression as reported in the paper.
E = sp.Matrix(x * X + y * Y + z * Z + W)
# Form the symbolic matrix expression as reported in the paper.
E = sp.Matrix(x * X + y * Y + z * Z + W)

essential_constraint = E * E.T * E - sp.Trace(E * E.T) * E
rank_2_constraint = E.det()
# Form the first system of equations that the essential matrix must
# satisfy:
essential_constraint = E * E.T * E - sp.Trace(E * E.T) * E

e = essential_constraint
# Form the second system of equations. The essential matrix has rank 2,
# therefore its determinant must be zero.
rank_2_constraint = E.det()

import IPython; IPython.embed()
return essential_constraint, rank_2_constraint
29 changes: 16 additions & 13 deletions python/oddkiva/sara/sfm/seven_point_algorithm.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import sympy as sp
def calculate_F_matrix_rank_2_constraint_from_7_points():
import sympy as sp

# Solve the cubic polynomial.
F1 = sp.MatrixSymbol('F1', 3, 3)
F2 = sp.MatrixSymbol('F2', 3, 3)
α = sp.symbols('α')
# Solve the cubic polynomial.
F1 = sp.MatrixSymbol('F1', 3, 3)
F2 = sp.MatrixSymbol('F2', 3, 3)
α = sp.symbols('α')

# Form the symbolic matrix expression as reported in the paper.
F = sp.Matrix(F1 + α * F2)
# The fundamental matrix has rank 2.
# Necessarily its determinant must be 0.
#
# Form the symbolic matrix expression as reported in the paper.
F = sp.Matrix(F1 + α * F2)

# Form the polynomial in the variable α.
det_F, _ = sp.polys.poly_from_expr(F.det(), α)
# Form the polynomial in the variable α.
det_F, _ = sp.polys.poly_from_expr(F.det(), α)

# Collect the coefficients "c[i]" as denoted in the paper.
c = det_F.all_coeffs()
# Collect the coefficients "c[i]" as denoted in the paper.
c = det_F.all_coeffs()


import IPython; IPython.embed()
return c