Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Torenvliet
eos
Commits
013a7c0f
Commit
013a7c0f
authored
8 years ago
by
Patrik Huber
Browse files
Options
Downloads
Patches
Plain Diff
Made Ceres fitting compile with the new Eigen models
parent
b57ada81
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/fit-model-ceres.cpp
+2
-2
2 additions, 2 deletions
examples/fit-model-ceres.cpp
include/eos/fitting/ceres_nonlinear.hpp
+11
-11
11 additions, 11 deletions
include/eos/fitting/ceres_nonlinear.hpp
with
13 additions
and
13 deletions
examples/fit-model-ceres.cpp
+
2
−
2
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
)
{
...
...
This diff is collapsed.
Click to expand it.
include/eos/fitting/ceres_nonlinear.hpp
+
11
−
11
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
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment