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
229fd2fe
Commit
229fd2fe
authored
Aug 01, 2015
by
patrikhuber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed fit-model to estimate the camera from world to screen instead of world to clip coordinates
parent
39b58004
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
examples/fit-model.cpp
examples/fit-model.cpp
+3
-6
No files found.
examples/fit-model.cpp
View file @
229fd2fe
...
...
@@ -171,9 +171,6 @@ int main(int argc, char *argv[])
cv
::
rectangle
(
outimg
,
cv
::
Point2f
(
lm
.
coordinates
[
0
]
-
2.0
f
,
lm
.
coordinates
[
1
]
-
2.0
f
),
cv
::
Point2f
(
lm
.
coordinates
[
0
]
+
2.0
f
,
lm
.
coordinates
[
1
]
+
2.0
f
),
{
255
,
0
,
0
});
}
// Convert the landmarks to clip-space:
std
::
for_each
(
begin
(
landmarks
),
end
(
landmarks
),
[
&
image
](
Landmark
<
Vec2f
>&
lm
)
{
lm
.
coordinates
=
render
::
screen_to_clip_space
(
lm
.
coordinates
,
image
.
cols
,
image
.
rows
);
});
// These will be the final 2D and 3D points used for the fitting:
vector
<
Vec4f
>
model_points
;
// the points in the 3D shape model
vector
<
int
>
vertex_indices
;
// their vertex indices
...
...
@@ -198,12 +195,12 @@ int main(int argc, char *argv[])
// Draw the mean-face landmarks projected using the estimated camera:
for
(
auto
&&
vertex
:
model_points
)
{
Vec2f
screen_point
=
fitting
::
project_affine
(
vertex
,
affine_cam
,
image
.
cols
,
image
.
rows
);
Vec2f
screen_point
(
Mat
(
affine_cam
*
Mat
(
vertex
)).
at
<
float
>
(
0
),
Mat
(
affine_cam
*
Mat
(
vertex
)).
at
<
float
>
(
1
)
);
cv
::
circle
(
outimg
,
cv
::
Point2f
(
screen_point
),
5
,
{
0.0
f
,
255.0
f
,
0.0
f
});
}
// Estimate the shape coefficients by fitting the shape to the landmarks:
float
lambda
=
5
.0
f
;
// the regularisation parameter
float
lambda
=
100'000
.0
f
;
// the regularisation parameter
vector
<
float
>
fitted_coeffs
=
fitting
::
fit_shape_to_landmarks_linear
(
morphable_model
,
affine_cam
,
image_points
,
vertex_indices
,
lambda
);
// Obtain the full mesh and draw it using the estimated camera:
...
...
@@ -214,7 +211,7 @@ int main(int argc, char *argv[])
// Draw the projected points again, this time using the fitted model shape:
for
(
auto
&&
idx
:
vertex_indices
)
{
Vec4f
model_point
(
mesh
.
vertices
[
idx
][
0
],
mesh
.
vertices
[
idx
][
1
],
mesh
.
vertices
[
idx
][
2
],
mesh
.
vertices
[
idx
][
3
]);
Vec2f
screen_point
=
fitting
::
project_affine
(
model_point
,
affine_cam
,
image
.
cols
,
image
.
rows
);
Vec2f
screen_point
(
Mat
(
affine_cam
*
Mat
(
model_point
)).
at
<
float
>
(
0
),
Mat
(
affine_cam
*
Mat
(
model_point
)).
at
<
float
>
(
1
)
);
cv
::
circle
(
outimg
,
cv
::
Point2f
(
screen_point
),
3
,
{
0.0
f
,
0.0
f
,
255.0
f
});
}
...
...
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