Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Richard Torenvliet
eos
Commits
455e5bb8
Commit
455e5bb8
authored
Jun 30, 2015
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed comments formatting and includes
parent
bbc82d0d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
14 deletions
+14
-14
CMakeLists.txt
CMakeLists.txt
+2
-2
examples/fit_model.cpp
examples/fit_model.cpp
+2
-2
include/eos/fitting/affine_camera_estimation.hpp
include/eos/fitting/affine_camera_estimation.hpp
+6
-6
include/eos/fitting/linear_shape_fitting.hpp
include/eos/fitting/linear_shape_fitting.hpp
+4
-4
No files found.
CMakeLists.txt
View file @
455e5bb8
...
@@ -57,8 +57,8 @@ set(HEADERS
...
@@ -57,8 +57,8 @@ set(HEADERS
include/eos/morphablemodel/PcaModel.hpp
include/eos/morphablemodel/PcaModel.hpp
include/eos/morphablemodel/MorphableModel.hpp
include/eos/morphablemodel/MorphableModel.hpp
include/eos/morphablemodel/io/cvssp.hpp
include/eos/morphablemodel/io/cvssp.hpp
include/eos/fitting/
AffineCameraE
stimation.hpp
include/eos/fitting/
affine_camera_e
stimation.hpp
include/eos/fitting/
LinearShapeF
itting.hpp
include/eos/fitting/
linear_shape_f
itting.hpp
include/eos/render/Mesh.hpp
include/eos/render/Mesh.hpp
include/eos/render/utils.hpp
include/eos/render/utils.hpp
)
)
...
...
examples/fit_model.cpp
View file @
455e5bb8
...
@@ -18,8 +18,8 @@
...
@@ -18,8 +18,8 @@
* limitations under the License.
* limitations under the License.
*/
*/
#include "eos/core/LandmarkMapper.hpp"
#include "eos/core/LandmarkMapper.hpp"
#include "eos/fitting/
AffineCameraE
stimation.hpp"
#include "eos/fitting/
affine_camera_e
stimation.hpp"
#include "eos/fitting/
LinearShapeF
itting.hpp"
#include "eos/fitting/
linear_shape_f
itting.hpp"
#include "eos/morphablemodel/io/cvssp.hpp"
#include "eos/morphablemodel/io/cvssp.hpp"
#include "eos/render/utils.hpp"
#include "eos/render/utils.hpp"
...
...
include/eos/fitting/affine_camera_estimation.hpp
View file @
455e5bb8
/*
/*
* Eos - A 3D Morphable Model fitting library written in modern C++11/14.
* Eos - A 3D Morphable Model fitting library written in modern C++11/14.
*
*
* File: include/eos/fitting/
AffineCameraE
stimation.hpp
* File: include/eos/fitting/
affine_camera_e
stimation.hpp
*
*
* Copyright 2014, 2015 Patrik Huber
* Copyright 2014, 2015 Patrik Huber
*
*
...
@@ -84,8 +84,8 @@ cv::Mat estimate_affine_camera(std::vector<cv::Vec2f> image_points, std::vector<
...
@@ -84,8 +84,8 @@ cv::Mat estimate_affine_camera(std::vector<cv::Vec2f> image_points, std::vector<
// 2) multiply every vectors coordinate by sqrt(2)/avgnorm
// 2) multiply every vectors coordinate by sqrt(2)/avgnorm
float
scaleFactor
=
std
::
sqrt
(
2
)
/
averageNorm
;
float
scaleFactor
=
std
::
sqrt
(
2
)
/
averageNorm
;
matImagePoints
*=
scaleFactor
;
// add unit homogeneous component here
matImagePoints
*=
scaleFactor
;
// add unit homogeneous component here
// The points in matImagePoints now have a RMS distance from the origin of sqrt(2).
// The points in matImagePoints now have a RMS distance from the origin of sqrt(2).
// The normalisation matrix so that the 2D points are mean-free and their norm is as described above.
// The normalisation matrix so that the 2D points are mean-free and their norm is as described above.
Mat
T
=
Mat
::
zeros
(
3
,
3
,
CV_32FC1
);
Mat
T
=
Mat
::
zeros
(
3
,
3
,
CV_32FC1
);
T
.
at
<
float
>
(
0
,
0
)
=
scaleFactor
;
// s_x
T
.
at
<
float
>
(
0
,
0
)
=
scaleFactor
;
// s_x
T
.
at
<
float
>
(
1
,
1
)
=
scaleFactor
;
// s_y
T
.
at
<
float
>
(
1
,
1
)
=
scaleFactor
;
// s_y
...
@@ -95,7 +95,7 @@ cv::Mat estimate_affine_camera(std::vector<cv::Vec2f> image_points, std::vector<
...
@@ -95,7 +95,7 @@ cv::Mat estimate_affine_camera(std::vector<cv::Vec2f> image_points, std::vector<
// center the model points to the origin:
// center the model points to the origin:
Mat
tmpOrigMdlPoints
=
matModelPoints
.
clone
();
// Temp for testing: Save the original coordinates.
Mat
tmpOrigMdlPoints
=
matModelPoints
.
clone
();
// Temp for testing: Save the original coordinates.
// translate the centroid of the model points to the origin:
// translate the centroid of the model points to the origin:
Mat
modelPointsMean
;
// use non-homogeneous coords for the next few steps? (less submatrices etc overhead)
Mat
modelPointsMean
;
// use non-homogeneous coords for the next few steps? (less submatrices etc overhead)
cv
::
reduce
(
matModelPoints
,
modelPointsMean
,
0
,
CV_REDUCE_AVG
);
cv
::
reduce
(
matModelPoints
,
modelPointsMean
,
0
,
CV_REDUCE_AVG
);
modelPointsMean
=
cv
::
repeat
(
modelPointsMean
,
matModelPoints
.
rows
,
1
);
modelPointsMean
=
cv
::
repeat
(
modelPointsMean
,
matModelPoints
.
rows
,
1
);
...
@@ -110,8 +110,8 @@ cv::Mat estimate_affine_camera(std::vector<cv::Vec2f> image_points, std::vector<
...
@@ -110,8 +110,8 @@ cv::Mat estimate_affine_camera(std::vector<cv::Vec2f> image_points, std::vector<
// 2) multiply every vectors coordinate by sqrt(3)/avgnorm
// 2) multiply every vectors coordinate by sqrt(3)/avgnorm
scaleFactor
=
std
::
sqrt
(
3
)
/
averageNorm
;
scaleFactor
=
std
::
sqrt
(
3
)
/
averageNorm
;
matModelPoints
*=
scaleFactor
;
// add unit homogeneous component here
matModelPoints
*=
scaleFactor
;
// add unit homogeneous component here
// The points in matModelPoints now have a RMS distance from the origin of sqrt(3).
// The points in matModelPoints now have a RMS distance from the origin of sqrt(3).
// The normalisation matrix so that the 3D points are mean-free and their norm is as described above.
// The normalisation matrix so that the 3D points are mean-free and their norm is as described above.
Mat
U
=
Mat
::
zeros
(
4
,
4
,
CV_32FC1
);
Mat
U
=
Mat
::
zeros
(
4
,
4
,
CV_32FC1
);
U
.
at
<
float
>
(
0
,
0
)
=
scaleFactor
;
// s_x
U
.
at
<
float
>
(
0
,
0
)
=
scaleFactor
;
// s_x
U
.
at
<
float
>
(
1
,
1
)
=
scaleFactor
;
// s_y
U
.
at
<
float
>
(
1
,
1
)
=
scaleFactor
;
// s_y
...
...
include/eos/fitting/linear_shape_fitting.hpp
View file @
455e5bb8
/*
/*
* Eos - A 3D Morphable Model fitting library written in modern C++11/14.
* Eos - A 3D Morphable Model fitting library written in modern C++11/14.
*
*
* File: include/eos/fitting/
LinearShapeF
itting.hpp
* File: include/eos/fitting/
linear_shape_f
itting.hpp
*
*
* Copyright 2014, 2015 Patrik Huber
* Copyright 2014, 2015 Patrik Huber
*
*
...
@@ -91,7 +91,7 @@ inline std::vector<float> fit_shape_to_landmarks_linear(morphablemodel::Morphabl
...
@@ -91,7 +91,7 @@ inline std::vector<float> fit_shape_to_landmarks_linear(morphablemodel::Morphabl
Sigma
.
at
<
float
>
(
i
,
i
)
=
1.0
f
/
sigma_2D_3D
;
// the higher the sigma_2D_3D, the smaller the diagonal entries of Sigma will be
Sigma
.
at
<
float
>
(
i
,
i
)
=
1.0
f
/
sigma_2D_3D
;
// the higher the sigma_2D_3D, the smaller the diagonal entries of Sigma will be
}
}
Mat
Omega
=
Sigma
.
t
()
*
Sigma
;
// just squares the diagonal
Mat
Omega
=
Sigma
.
t
()
*
Sigma
;
// just squares the diagonal
// The landmarks in matrix notation (in homogeneous coordinates), $3N\times 1$
// The landmarks in matrix notation (in homogeneous coordinates), $3N\times 1$
Mat
y
=
Mat
::
ones
(
3
*
landmarks
.
size
(),
1
,
CV_32FC1
);
Mat
y
=
Mat
::
ones
(
3
*
landmarks
.
size
(),
1
,
CV_32FC1
);
for
(
int
i
=
0
;
i
<
landmarks
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
landmarks
.
size
();
++
i
)
{
y
.
at
<
float
>
(
3
*
i
,
0
)
=
landmarks
[
i
][
0
];
y
.
at
<
float
>
(
3
*
i
,
0
)
=
landmarks
[
i
][
0
];
...
@@ -112,8 +112,8 @@ inline std::vector<float> fit_shape_to_landmarks_linear(morphablemodel::Morphabl
...
@@ -112,8 +112,8 @@ inline std::vector<float> fit_shape_to_landmarks_linear(morphablemodel::Morphabl
// Bring into standard regularised quadratic form with diagonal distance matrix Omega
// Bring into standard regularised quadratic form with diagonal distance matrix Omega
Mat
A
=
P
*
V_hat_h
;
// camera matrix times the basis
Mat
A
=
P
*
V_hat_h
;
// camera matrix times the basis
Mat
b
=
P
*
v_bar
-
y
;
// camera matrix times the mean, minus the landmarks.
Mat
b
=
P
*
v_bar
-
y
;
// camera matrix times the mean, minus the landmarks.
//Mat c_s; // The x, we solve for this! (the variance-normalised shape parameter vector, $c_s = [a_1/sigma_{s,1} , ..., a_m-1/sigma_{s,m-1}]^t$
//Mat c_s; // The x, we solve for this! (the variance-normalised shape parameter vector, $c_s = [a_1/sigma_{s,1} , ..., a_m-1/sigma_{s,m-1}]^t$
//int numShapePc = morphableModel.getShapeModel().getNumberOfPrincipalComponents();
//int numShapePc = morphableModel.getShapeModel().getNumberOfPrincipalComponents();
int
num_shape_pc
=
num_coeffs_to_fit
;
int
num_shape_pc
=
num_coeffs_to_fit
;
Mat
AtOmegaA
=
A
.
t
()
*
Omega
*
A
;
Mat
AtOmegaA
=
A
.
t
()
*
Omega
*
A
;
Mat
AtOmegaAReg
=
AtOmegaA
+
lambda
*
Mat
::
eye
(
num_shape_pc
,
num_shape_pc
,
CV_32FC1
);
Mat
AtOmegaAReg
=
AtOmegaA
+
lambda
*
Mat
::
eye
(
num_shape_pc
,
num_shape_pc
,
CV_32FC1
);
...
...
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