-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from oddkiva/maint-code-cleanup
MAINT: code cleanup.
- Loading branch information
Showing
7 changed files
with
38 additions
and
83 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |