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
013a7c0f
Commit
013a7c0f
authored
Mar 06, 2017
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made Ceres fitting compile with the new Eigen models
parent
b57ada81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
examples/fit-model-ceres.cpp
examples/fit-model-ceres.cpp
+2
-2
include/eos/fitting/ceres_nonlinear.hpp
include/eos/fitting/ceres_nonlinear.hpp
+11
-11
No files found.
examples/fit-model-ceres.cpp
View file @
013a7c0f
...
...
@@ -223,7 +223,6 @@ int main(int argc, char *argv[])
continue
;
}
int
vertex_idx
=
std
::
stoi
(
converted_name
.
get
());
Vec4f
vertex
=
morphable_model
.
get_shape_model
().
get_mean_at_point
(
vertex_idx
);
vertex_indices
.
emplace_back
(
vertex_idx
);
image_points
.
emplace_back
(
landmarks
[
i
].
coordinates
);
}
...
...
@@ -420,7 +419,8 @@ int main(int argc, char *argv[])
auto
vectord_to_vectorf
=
[](
const
std
::
vector
<
double
>&
vec
)
{
return
std
::
vector
<
float
>
(
std
::
begin
(
vec
),
std
::
end
(
vec
));
};
auto
shape_ceres
=
morphable_model
.
get_shape_model
().
draw_sample
(
shape_coefficients
)
+
to_matrix
(
blendshapes
)
*
Mat
(
vectord_to_vectorf
(
blendshape_coefficients
),
true
);
auto
blendshape_coeffs_float
=
vectord_to_vectorf
(
blendshape_coefficients
);
auto
shape_ceres
=
morphable_model
.
get_shape_model
().
draw_sample
(
shape_coefficients
)
+
to_matrix
(
blendshapes
)
*
Eigen
::
Map
<
const
Eigen
::
VectorXf
>
(
blendshape_coeffs_float
.
data
(),
blendshape_coeffs_float
.
size
());
core
::
Mesh
mesh
=
morphablemodel
::
sample_to_mesh
(
shape_ceres
,
morphable_model
.
get_color_model
().
draw_sample
(
colour_coefficients
),
morphable_model
.
get_shape_model
().
get_triangle_list
(),
morphable_model
.
get_color_model
().
get_triangle_list
(),
morphable_model
.
get_texture_coordinates
());
for
(
auto
&&
idx
:
vertex_indices
)
{
...
...
include/eos/fitting/ceres_nonlinear.hpp
View file @
013a7c0f
...
...
@@ -314,30 +314,30 @@ std::array<T, 3> get_shape_point(const morphablemodel::PcaModel& shape_model, co
{
int
num_coeffs_fitting
=
10
;
// Todo: Should be inferred or a function parameter!
auto
mean
=
shape_model
.
get_mean_at_point
(
vertex_id
);
auto
basis
=
shape_model
.
get_rescaled_pca_basis
(
vertex_id
);
auto
basis
=
shape_model
.
get_rescaled_pca_basis
_at_point
(
vertex_id
);
// Computing Shape = mean + basis * coeffs:
// Note: Could use an Eigen matrix with type T to see if it gives a speedup.
std
::
array
<
T
,
3
>
point
{
T
(
mean
[
0
]),
T
(
mean
[
1
]),
T
(
mean
[
2
])
};
for
(
int
i
=
0
;
i
<
num_coeffs_fitting
;
++
i
)
{
point
[
0
]
+=
T
(
basis
.
row
(
0
).
col
(
i
)
.
at
<
float
>
(
0
))
*
shape_coeffs
[
i
];
// it seems to be ~15% faster when these are static_cast<double>() instead of T()?
point
[
0
]
+=
T
(
basis
.
row
(
0
).
col
(
i
)(
0
))
*
shape_coeffs
[
i
];
// it seems to be ~15% faster when these are static_cast<double>() instead of T()?
}
for
(
int
i
=
0
;
i
<
num_coeffs_fitting
;
++
i
)
{
point
[
1
]
+=
T
(
basis
.
row
(
1
).
col
(
i
)
.
at
<
float
>
(
0
))
*
shape_coeffs
[
i
];
point
[
1
]
+=
T
(
basis
.
row
(
1
).
col
(
i
)(
0
))
*
shape_coeffs
[
i
];
}
for
(
int
i
=
0
;
i
<
num_coeffs_fitting
;
++
i
)
{
point
[
2
]
+=
T
(
basis
.
row
(
2
).
col
(
i
)
.
at
<
float
>
(
0
))
*
shape_coeffs
[
i
];
point
[
2
]
+=
T
(
basis
.
row
(
2
).
col
(
i
)(
0
))
*
shape_coeffs
[
i
];
}
// Adding the blendshape offsets:
// Shape = mean + basis * coeffs + blendshapes * bs_coeffs:
auto
num_blendshapes
=
blendshapes
.
size
();
for
(
int
i
=
0
;
i
<
num_blendshapes
;
++
i
)
{
point
[
0
]
+=
T
(
blendshapes
[
i
].
deformation
.
at
<
float
>
(
3
*
vertex_id
+
0
))
*
blendshape_coeffs
[
i
];
point
[
0
]
+=
T
(
blendshapes
[
i
].
deformation
(
3
*
vertex_id
+
0
))
*
blendshape_coeffs
[
i
];
}
for
(
int
i
=
0
;
i
<
num_blendshapes
;
++
i
)
{
point
[
1
]
+=
T
(
blendshapes
[
i
].
deformation
.
at
<
float
>
(
3
*
vertex_id
+
1
))
*
blendshape_coeffs
[
i
];
point
[
1
]
+=
T
(
blendshapes
[
i
].
deformation
(
3
*
vertex_id
+
1
))
*
blendshape_coeffs
[
i
];
}
for
(
int
i
=
0
;
i
<
num_blendshapes
;
++
i
)
{
point
[
2
]
+=
T
(
blendshapes
[
i
].
deformation
.
at
<
float
>
(
3
*
vertex_id
+
2
))
*
blendshape_coeffs
[
i
];
point
[
2
]
+=
T
(
blendshapes
[
i
].
deformation
(
3
*
vertex_id
+
2
))
*
blendshape_coeffs
[
i
];
}
return
point
;
};
...
...
@@ -355,18 +355,18 @@ std::array<T, 3> get_vertex_colour(const morphablemodel::PcaModel& color_model,
{
int
num_coeffs_fitting
=
10
;
// Todo: Should be inferred or a function parameter!
auto
mean
=
color_model
.
get_mean_at_point
(
vertex_id
);
auto
basis
=
color_model
.
get_rescaled_pca_basis
(
vertex_id
);
auto
basis
=
color_model
.
get_rescaled_pca_basis
_at_point
(
vertex_id
);
// Computing Colour = mean + basis * coeffs
// Note: Could use an Eigen matrix with type T to see if it gives a speedup.
std
::
array
<
T
,
3
>
point
{
T
(
mean
[
0
]),
T
(
mean
[
1
]),
T
(
mean
[
2
])
};
for
(
int
i
=
0
;
i
<
num_coeffs_fitting
;
++
i
)
{
point
[
0
]
+=
T
(
basis
.
row
(
0
).
col
(
i
)
.
at
<
float
>
(
0
))
*
color_coeffs
[
i
];
// it seems to be ~15% faster when these are static_cast<double>() instead of T()?
point
[
0
]
+=
T
(
basis
.
row
(
0
).
col
(
i
)(
0
))
*
color_coeffs
[
i
];
// it seems to be ~15% faster when these are static_cast<double>() instead of T()?
}
for
(
int
i
=
0
;
i
<
num_coeffs_fitting
;
++
i
)
{
point
[
1
]
+=
T
(
basis
.
row
(
1
).
col
(
i
)
.
at
<
float
>
(
0
))
*
color_coeffs
[
i
];
point
[
1
]
+=
T
(
basis
.
row
(
1
).
col
(
i
)(
0
))
*
color_coeffs
[
i
];
}
for
(
int
i
=
0
;
i
<
num_coeffs_fitting
;
++
i
)
{
point
[
2
]
+=
T
(
basis
.
row
(
2
).
col
(
i
)
.
at
<
float
>
(
0
))
*
color_coeffs
[
i
];
point
[
2
]
+=
T
(
basis
.
row
(
2
).
col
(
i
)(
0
))
*
color_coeffs
[
i
];
}
return
point
;
};
...
...
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