From 52eabc362fdb174204b3f4d479159f026f525949 Mon Sep 17 00:00:00 2001 From: "Dr. Zygmunt L. Szpak" Date: Fri, 23 Mar 2018 09:44:30 +1030 Subject: [PATCH] WIP Establishes basic estimation framework --- src/MultipleViewGeometry.jl | 6 +++++- src/math_aliases.jl | 1 + .../moments_fundamentalmatrix.jl | 14 ++++++++++++++ src/types.jl | 5 +++++ test/moments_fundamentalmatrix_tests.jl | 15 +++++++++++++++ 5 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/twoview_estimation/moments_fundamentalmatrix.jl create mode 100644 test/moments_fundamentalmatrix_tests.jl diff --git a/src/MultipleViewGeometry.jl b/src/MultipleViewGeometry.jl index 33cb03d..a51fca1 100644 --- a/src/MultipleViewGeometry.jl +++ b/src/MultipleViewGeometry.jl @@ -8,7 +8,7 @@ include("types.jl") include("math_aliases.jl") # Types exported from `types.jl` -export HomogeneousPoint +export HomogeneousPoint, ProjectiveEntity, FundamentalMatrix # Functions exported from `operators.jl`. export 𝑛 @@ -16,8 +16,12 @@ export 𝑛 # Functions exported from `hartley_transformation.jl`. export hartley_normalization, hartley_transformation +# Functions exported from `moments_fundamentalmatrix.jl` +export moments + include("operators.jl") include("data_normalization/hartley_transformation.jl") +include("twoview_estimation/moments_fundamentalmatrix.jl") # package code goes here diff --git a/src/math_aliases.jl b/src/math_aliases.jl index 2afc6b2..c9d8efc 100644 --- a/src/math_aliases.jl +++ b/src/math_aliases.jl @@ -1,2 +1,3 @@ const √ = sqrt const βˆ‘ = sum +const βŠ— = kron diff --git a/src/twoview_estimation/moments_fundamentalmatrix.jl b/src/twoview_estimation/moments_fundamentalmatrix.jl new file mode 100644 index 0000000..7f305d6 --- /dev/null +++ b/src/twoview_estimation/moments_fundamentalmatrix.jl @@ -0,0 +1,14 @@ +function moments(entity::FundamentalMatrix, matches...) + # ΚΉ : CTRL + SHIFT + 02b9 + pts1, pts2 = matches + + 𝐀 = fill(0.0,(9,9)) + for correspondence in zip(pts1, pts2) + m , mΚΉ = correspondence + 𝐦 = 𝑛(collect(m.coords)) + 𝐦ʹ = 𝑛(collect(mΚΉ.coords)) + 𝐀 = 𝐀 + βŠ—(𝐦*transpose(𝐦) , 𝐦ʹ*transpose(𝐦ʹ)) + end + dump(𝐀) + +end diff --git a/src/types.jl b/src/types.jl index 2593420..12b1fb0 100644 --- a/src/types.jl +++ b/src/types.jl @@ -1,3 +1,8 @@ struct HomogeneousPoint{T <: AbstractFloat,N} coords::NTuple{N, T} end + +abstract type ProjectiveEntity end + +type FundamentalMatrix <: ProjectiveEntity +end diff --git a/test/moments_fundamentalmatrix_tests.jl b/test/moments_fundamentalmatrix_tests.jl new file mode 100644 index 0000000..9d4eb82 --- /dev/null +++ b/test/moments_fundamentalmatrix_tests.jl @@ -0,0 +1,15 @@ +using MultipleViewGeometry, Base.Test + +pts1 = map(HomogeneousPoint, + [(-10.0, -10.0, 1.0), + (-10.0, 10.0, 1.0), + ( 10.0, -10.0, 1.0), + ( 10.0, 10.0, 1.0)]) + +pts2 = map(HomogeneousPoint, + [(-20.0, -20.0, 1.0), + (-20.0, 20.0, 1.0), + ( 20.0, -20.0, 1.0), + ( 20.0, 20.0, 1.0)]) + +moments(FundamentalMatrix(), (pts1,pts2)...)