Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
py-3d-face-reconstruction
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
py-3d-face-reconstruction
Commits
292bf39b
Commit
292bf39b
authored
Nov 23, 2016
by
Richard Torenvliet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made changes to support eos, made Python bindings to call it from python
parent
579f7adc
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
402 additions
and
15 deletions
+402
-15
Dockerfile
Dockerfile
+33
-3
actions.mk
actions.mk
+0
-3
makefile
makefile
+3
-0
src/reconstruction/fit-model.cpp
src/reconstruction/fit-model.cpp
+313
-0
src/reconstruction/reconstruction.py
src/reconstruction/reconstruction.py
+0
-1
src/reconstruction/setup.py
src/reconstruction/setup.py
+23
-0
src/test/reconstruction_test.py
src/test/reconstruction_test.py
+30
-8
No files found.
Dockerfile
View file @
292bf39b
FROM
smvanveen/computer-vision:20161109143812
FROM
smvanveen/computer-vision:20161109143812
RUN
git clone https://github.com/davisking/dlib.git
RUN
(
cd
dlib
;
python setup.py
install
--yes
USE_AVX_INSTRUCTIONS
)
# install python requirements
RUN
apt-get
install
graphviz
-y
COPY
requirements.txt /tmp
COPY
requirements.txt /tmp
RUN
pip
install
-r
/tmp/requirements.txt
RUN
pip
install
-r
/tmp/requirements.txt
# extra packages:
# graphviz: for cProfiling using pycallgraph.
# libeigen3-dev: for eos: 3D morphable face model fitting library.
RUN
apt-get
install
-y
\
graphviz
\
libeigen3-dev
WORKDIR
/libs
# install dlib
RUN
git clone https://github.com/davisking/dlib.git
RUN
(
cd
dlib
;
python setup.py
install
--yes
USE_AVX_INSTRUCTIONS
)
# install eos (face-recosntruction, (3D Morphable Face Model fitting library)
RUN
git clone
--recursive
https://github.com/patrikhuber/eos.git
# remove dependency on opencv 2.4.3, opencv 3.0 works fine
WORKDIR
/libs/eos
RUN
sed
-i
's/2.4.3//g'
CMakeLists.txt
RUN
mkdir
build
WORKDIR
/libs/eos/build
RUN
cmake ../
\
-DCMAKE_INSTALL_PREFIX
=
/usr/local/eos
\
-DGENERATE_PYTHON_BINDINGS
=
on
\
-DBUILD_UTILS
=
on
\
-DPYTHON_EXECUTABLE
=
/usr/bin/python
RUN
make
&&
make
install
ENV
PYTHONPATH=/usr/local/eos/bin/:$PYTHONPATH
WORKDIR
/src
WORKDIR
/src
actions.mk
View file @
292bf39b
...
@@ -17,9 +17,6 @@ runnit:
...
@@ -17,9 +17,6 @@ runnit:
$(BASE_DOCKER_CMD)
python main.py
$(BASE_DOCKER_CMD)
python main.py
src/reconstruction/texture.so
:
src/reconstruction/texture.pyx
$(BASE_DOCKER_CMD)
/bin/bash
-c
'(cd reconstruction; python setup.py build_ext --inplace)'
## IMM Dataset
## IMM Dataset
data/pca_imm_shape_model.npy
:
data/pca_imm_shape_model.npy
:
$(BASE_DOCKER_CMD)
python main.py
\
$(BASE_DOCKER_CMD)
python main.py
\
...
...
makefile
View file @
292bf39b
...
@@ -15,6 +15,7 @@ $(info $(TARGETS))
...
@@ -15,6 +15,7 @@ $(info $(TARGETS))
DEPENDENCIES
:=
data/imm_face_db
DEPENDENCIES
:=
data/imm_face_db
TARGETS
:=
data/shape_predictor_68_face_landmarks.dat
\
TARGETS
:=
data/shape_predictor_68_face_landmarks.dat
\
src/reconstruction/texture.so
\
src/reconstruction/texture.so
\
src/reconstruction/fit.so
\
data/pca_ibug_shape_model.npy
\
data/pca_ibug_shape_model.npy
\
data/pca_ibug_texture_model.npy
data/pca_ibug_texture_model.npy
...
@@ -43,3 +44,5 @@ $(SITE_PACKAGES)/cv%:
...
@@ -43,3 +44,5 @@ $(SITE_PACKAGES)/cv%:
@
ls
$@
@
ls
$@
src/reconstruction/fit.so
:
src/reconstruction/fit-model.cpp
$(BASE_DOCKER_CMD)
/bin/bash
-c
'(cd reconstruction; python setup.py build_ext --inplace)'
src/reconstruction/fit-model.cpp
0 → 100644
View file @
292bf39b
This diff is collapsed.
Click to expand it.
src/reconstruction/reconstruction.py
View file @
292bf39b
...
@@ -3,7 +3,6 @@ import numpy as np
...
@@ -3,7 +3,6 @@ import numpy as np
import
pca
import
pca
import
aam
import
aam
from
utility
import
import_dataset_module
def
draw_shape
(
image
,
points
,
triangles
,
multiply
=
True
):
def
draw_shape
(
image
,
points
,
triangles
,
multiply
=
True
):
...
...
src/reconstruction/setup.py
View file @
292bf39b
...
@@ -16,6 +16,29 @@ extensions = [
...
@@ -16,6 +16,29 @@ extensions = [
'texture'
,
'texture'
,
[
'texture.pyx'
],
[
'texture.pyx'
],
include_dirs
=
[
np
.
get_include
()],
),
include_dirs
=
[
np
.
get_include
()],
),
Extension
(
'fit'
,
[
'fit-model.cpp'
],
language
=
"c++"
,
include_dirs
=
[
'/usr/local/eos/include/'
,
# path need to be changed in future
'/usr/local/eos/3rdparty/glm/'
,
'/usr/local/eos/3rdparty/cereal-1.1.1/include/'
,
'/usr/local/include/opencv2/'
,
'/usr/include/boost/'
],
library_dirs
=
[
'/usr/local/eos/bin'
,
'/usr/lib/x86_64-linux-gnu/'
,
'/usr/local/lib/'
],
libraries
=
[
'boost_program_options'
,
'boost_filesystem'
,
'opencv_world'
],
extra_compile_args
=
[
'-std=c++14'
],
)
#include_dirs=[np.get_include()], ),
#Extension(
#Extension(
# 'halide',
# 'halide',
# ['texture_halide.cpp'],
# ['texture_halide.cpp'],
...
...
src/test/reconstruction_test.py
View file @
292bf39b
...
@@ -3,24 +3,28 @@ import cv2
...
@@ -3,24 +3,28 @@ import cv2
import
pca
as
pca
import
pca
as
pca
from
settings
import
logger
from
settings
import
logger
from
reconstruction
import
reconstruction
from
reconstruction
import
reconstruction
from
utility
import
import_dataset_module
#
model_texture_file = '/data/pca_ibug_texture_model.npy'
model_texture_file
=
'/data/pca_ibug_texture_model.npy'
#
model_shape_file = '/data/pca_ibug_shape_model.npy'
model_shape_file
=
'/data/pca_ibug_shape_model.npy'
model_texture_file
=
'/data/pca_imm_texture_model.npy'
#
model_texture_file = '/data/pca_imm_texture_model.npy'
model_shape_file
=
'/data/pca_imm_shape_model.npy'
#
model_shape_file = '/data/pca_imm_shape_model.npy'
def
main
():
def
shape
():
shape_components
=
58
shape_components
=
58
shape_model
=
pca
.
PCAModel
(
model_shape_file
)
shape_model
=
pca
.
PCAModel
(
model_shape_file
)
texture_model
=
pca
.
PCAModel
(
model_texture_file
)
texture_model
=
pca
.
PCAModel
(
model_texture_file
)
logger
.
info
(
'using %s shape_components'
,
shape_components
)
logger
.
info
(
'using %s shape_components'
,
shape_components
)
image_filename
=
'/data/imm_face_db/01-1m.asf'
image_filename
=
'/data/imm_face_db/01-1m.jpg'
dataset_module
=
import_dataset_module
(
'ibug'
)
dst_image
=
reconstruction
.
reconstruct_shape_texture
(
dst_image
=
reconstruction
.
reconstruct_shape_texture
(
'imm'
,
dataset_module
,
shape_model
,
shape_model
,
texture_model
,
texture_model
,
image_filename
,
image_filename
,
...
@@ -30,5 +34,23 @@ def main():
...
@@ -30,5 +34,23 @@ def main():
cv2
.
imwrite
(
'/data/reconstructed.png'
,
dst_image
)
cv2
.
imwrite
(
'/data/reconstructed.png'
,
dst_image
)
def
fit_model
():
from
reconstruction
import
fit
shape_components
=
58
shape_model
=
pca
.
PCAModel
(
model_shape_file
)
texture_model
=
pca
.
PCAModel
(
model_texture_file
)
logger
.
info
(
'using %s shape_components'
,
shape_components
)
image_filename
=
'/data/imm_face_db/01-1m.jpg'
dataset_module
=
import_dataset_module
(
'ibug'
)
input_points
=
dataset_module
.
factory
(
filename
=
image_filename
)
input_image
=
input_points
.
get_image
()
fit
.
fit_model
(
image
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
#fit_model()
shape
()
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