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
14ff9b6e
Commit
14ff9b6e
authored
Jul 11, 2015
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed fit-model to use the new cereal model format. Also added an output param.
parent
5f406bb4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
examples/fit_model.cpp
examples/fit_model.cpp
+12
-10
No files found.
examples/fit_model.cpp
View file @
14ff9b6e
...
@@ -105,33 +105,33 @@ vector<Vec2f> readPtsLandmarks(std::string filename)
...
@@ -105,33 +105,33 @@ vector<Vec2f> readPtsLandmarks(std::string filename)
*/
*/
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
fs
::
path
modelfile
,
isomapfile
,
imagefile
,
landmarksfile
,
mappingsfile
;
fs
::
path
modelfile
,
isomapfile
,
imagefile
,
landmarksfile
,
mappingsfile
,
outputfile
;
try
{
try
{
po
::
options_description
desc
(
"Allowed options"
);
po
::
options_description
desc
(
"Allowed options"
);
desc
.
add_options
()
desc
.
add_options
()
(
"help,h"
,
(
"help,h"
,
"display the help message"
)
"display the help message"
)
(
"model,m"
,
po
::
value
<
fs
::
path
>
(
&
modelfile
)
->
required
(),
(
"model,m"
,
po
::
value
<
fs
::
path
>
(
&
modelfile
)
->
required
(),
"a CVSSP .scm Morphable Model file"
)
"a Morphable Model stored as cereal BinaryArchive"
)
(
"isomap,t"
,
po
::
value
<
fs
::
path
>
(
&
isomapfile
),
"optional isomap containing the texture mapping coordinates"
)
(
"image,i"
,
po
::
value
<
fs
::
path
>
(
&
imagefile
)
->
required
()
->
default_value
(
"data/image_0001.png"
),
(
"image,i"
,
po
::
value
<
fs
::
path
>
(
&
imagefile
)
->
required
()
->
default_value
(
"data/image_0001.png"
),
"an input image"
)
"an input image"
)
(
"landmarks,l"
,
po
::
value
<
fs
::
path
>
(
&
landmarksfile
)
->
required
()
->
default_value
(
"data/image_0001.pts"
),
(
"landmarks,l"
,
po
::
value
<
fs
::
path
>
(
&
landmarksfile
)
->
required
()
->
default_value
(
"data/image_0001.pts"
),
"2D landmarks for the image, in ibug .pts format"
)
"2D landmarks for the image, in ibug .pts format"
)
(
"mapping,p"
,
po
::
value
<
fs
::
path
>
(
&
mappingsfile
)
->
required
()
->
default_value
(
"../share/ibug2did.txt"
),
(
"mapping,p"
,
po
::
value
<
fs
::
path
>
(
&
mappingsfile
)
->
required
()
->
default_value
(
"../share/ibug2did.txt"
),
"landmark identifier to model vertex number mapping"
)
"landmark identifier to model vertex number mapping"
)
(
"output,o"
,
po
::
value
<
fs
::
path
>
(
&
outputfile
)
->
required
()
->
default_value
(
"out"
),
"basename for the output rendering and obj files"
)
;
;
po
::
variables_map
vm
;
po
::
variables_map
vm
;
po
::
store
(
po
::
command_line_parser
(
argc
,
argv
).
options
(
desc
).
run
(),
vm
);
po
::
store
(
po
::
command_line_parser
(
argc
,
argv
).
options
(
desc
).
run
(),
vm
);
if
(
vm
.
count
(
"help"
))
{
if
(
vm
.
count
(
"help"
))
{
cout
<<
"Usage: fit
_
model [options]"
<<
endl
;
cout
<<
"Usage: fit
-
model [options]"
<<
endl
;
cout
<<
desc
;
cout
<<
desc
;
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
po
::
notify
(
vm
);
po
::
notify
(
vm
);
}
}
catch
(
po
::
error
&
e
)
{
catch
(
const
po
::
error
&
e
)
{
cout
<<
"Error while parsing command-line arguments: "
<<
e
.
what
()
<<
endl
;
cout
<<
"Error while parsing command-line arguments: "
<<
e
.
what
()
<<
endl
;
cout
<<
"Use --help to display a list of options."
<<
endl
;
cout
<<
"Use --help to display a list of options."
<<
endl
;
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
...
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
...
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
// Load the image, landmarks, LandmarkMapper and the Morphable Model:
// Load the image, landmarks, LandmarkMapper and the Morphable Model:
Mat
image
=
cv
::
imread
(
imagefile
.
string
());
Mat
image
=
cv
::
imread
(
imagefile
.
string
());
auto
landmarks
=
readPtsLandmarks
(
landmarksfile
.
string
());
auto
landmarks
=
readPtsLandmarks
(
landmarksfile
.
string
());
morphablemodel
::
MorphableModel
morphable_model
=
morphablemodel
::
load
ScmModel
(
modelfile
,
isomapfile
);
morphablemodel
::
MorphableModel
morphable_model
=
morphablemodel
::
load
_model
(
modelfile
.
string
()
);
core
::
LandmarkMapper
landmark_mapper
=
mappingsfile
.
empty
()
?
core
::
LandmarkMapper
()
:
core
::
LandmarkMapper
(
mappingsfile
);
core
::
LandmarkMapper
landmark_mapper
=
mappingsfile
.
empty
()
?
core
::
LandmarkMapper
()
:
core
::
LandmarkMapper
(
mappingsfile
);
// Draw the loaded landmarks:
// Draw the loaded landmarks:
...
@@ -188,7 +188,8 @@ int main(int argc, char *argv[])
...
@@ -188,7 +188,8 @@ int main(int argc, char *argv[])
// Obtain the full mesh and draw it using the estimated camera:
// Obtain the full mesh and draw it using the estimated camera:
render
::
Mesh
mesh
=
morphable_model
.
draw_sample
(
fitted_coeffs
,
vector
<
float
>
());
render
::
Mesh
mesh
=
morphable_model
.
draw_sample
(
fitted_coeffs
,
vector
<
float
>
());
render
::
write_obj
(
mesh
,
"out.obj"
);
// save the mesh as obj
outputfile
+=
fs
::
path
(
".obj"
);
render
::
write_obj
(
mesh
,
outputfile
.
string
());
// save the mesh as obj
// Draw the projected points again, this time using the fitted model shape:
// Draw the projected points again, this time using the fitted model shape:
for
(
auto
&&
idx
:
vertex_indices
)
{
for
(
auto
&&
idx
:
vertex_indices
)
{
...
@@ -198,8 +199,9 @@ int main(int argc, char *argv[])
...
@@ -198,8 +199,9 @@ int main(int argc, char *argv[])
}
}
// Save the output image:
// Save the output image:
cv
::
imwrite
(
"out.png"
,
outimg
);
outputfile
.
replace_extension
(
".png"
);
cout
<<
"Finished fitting and wrote result to out.png."
<<
endl
;
cv
::
imwrite
(
outputfile
.
string
(),
outimg
);
cout
<<
"Finished fitting and wrote result image "
<<
outputfile
.
string
()
<<
"."
<<
endl
;
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
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