Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
b1b9a29e
Commit
b1b9a29e
authored
Jul 21, 2014
by
edgarriba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extracting Eigenvalues and Eigenvectors
parent
40f6d320
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
5 deletions
+34
-5
dls.cpp
modules/calib3d/src/dls.cpp
+34
-5
No files found.
modules/calib3d/src/dls.cpp
View file @
b1b9a29e
...
@@ -2,6 +2,10 @@
...
@@ -2,6 +2,10 @@
#include "dls.h"
#include "dls.h"
#include <iostream>
#include <iostream>
#include <Eigen/Eigenvalues>
#include <Eigen/Core>
using
namespace
std
;
using
namespace
std
;
void
printSize
(
const
cv
::
Mat
&
mat
)
void
printSize
(
const
cv
::
Mat
&
mat
)
...
@@ -201,13 +205,36 @@ void dls::build_coeff_matrix()
...
@@ -201,13 +205,36 @@ void dls::build_coeff_matrix()
// construct the multiplication matrix via schur compliment of the Macaulay
// construct the multiplication matrix via schur compliment of the Macaulay
// matrix
// matrix
cv
::
Mat
Mtilde
=
M2_1
-
M2_5
.
t
()
*
M2_4
;
// OK
cv
::
Mat
Mtilde
=
M2_1
-
M2_5
.
t
()
*
M2_4
;
// 27x27 non-symmetric // OK
// EIGENVALUES AND EIGENVECTORS
Eigen
::
MatrixXd
Mtilde_eig
,
zeros_eig
;
cv
::
cv2eigen
(
Mtilde
,
Mtilde_eig
);
cv
::
cv2eigen
(
cv
::
Mat
::
zeros
(
27
,
27
,
CV_64F
),
zeros_eig
);
Eigen
::
MatrixXcd
Mtilde_eig_cmplx
(
27
,
27
);
Mtilde_eig_cmplx
.
real
()
=
Mtilde_eig
;
Mtilde_eig_cmplx
.
imag
()
=
zeros_eig
;
Eigen
::
ComplexEigenSolver
<
Eigen
::
MatrixXcd
>
ces
(
Mtilde_eig_cmplx
);
Eigen
::
MatrixXd
eigval_real
=
ces
.
eigenvalues
().
real
();
Eigen
::
MatrixXd
eigval_cmplx
=
ces
.
eigenvalues
().
imag
();
Eigen
::
MatrixXd
eigvec_real
=
ces
.
eigenvectors
().
real
();
Eigen
::
MatrixXd
eigvec_cmplx
=
ces
.
eigenvectors
().
imag
();
cv
::
Mat
eigenvalues
,
eigenvectors
;
cv
::
Mat
eigenvalues
_real
,
eigenvalues_complex
;
cv
::
eigen
(
Mtilde
,
eigenvalues
,
eigenvectors
)
;
cv
::
Mat
eigenvectors_real
,
eigenvectors_complex
;
cv
::
Mat
V
=
eigenvectors
;
cv
::
eigen2cv
(
eigval_real
,
eigenvalues_real
);
cv
::
eigen2cv
(
eigval_cmplx
,
eigenvalues_complex
);
cv
::
eigen2cv
(
eigvec_real
,
eigenvectors_real
);
cv
::
eigen2cv
(
eigvec_cmplx
,
eigenvectors_complex
);
cv
::
Mat
V
=
eigenvectors_real
;
cv
::
Mat
v
=
eigenvalues_real
;
/*
/*
* Now check the solutions
* Now check the solutions
...
@@ -227,10 +254,12 @@ void dls::build_coeff_matrix()
...
@@ -227,10 +254,12 @@ void dls::build_coeff_matrix()
cv
::
Mat
V_k
;
cv
::
solve
(
V_kB
.
t
(),
V_kA
.
t
(),
V_k
);
// A/B = B'\A'
cv
::
Mat
V_k
;
cv
::
solve
(
V_kB
.
t
(),
V_kA
.
t
(),
V_k
);
// A/B = B'\A'
cv
::
Mat
(
V_k
.
t
()).
col
(
0
).
copyTo
(
V
.
col
(
0
)
);
cv
::
Mat
(
V_k
.
t
()).
col
(
0
).
copyTo
(
V
.
col
(
0
)
);
cout
<<
eigenvectors_complex
.
at
<
double
>
(
1
,
k
)
<<
endl
;
if
(
1
)
//if (imag(V(2,k)) == 0)
if
(
eigenvectors_complex
.
at
<
double
>
(
1
,
k
)
==
0
)
//if (imag(V(2,k)) == 0)
{
{
//TODO: check for pure real part
//TODO: check for pure real part
cout
<<
eigenvectors_complex
.
at
<
double
>
(
1
,
k
)
<<
endl
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment