From a512e02601dd0d0daa76cfde7a0473690c16f786 Mon Sep 17 00:00:00 2001 From: Tamerlan Date: Wed, 29 Dec 2021 17:45:54 +0300 Subject: [PATCH 1/4] build: Add Dockerfile --- Dockerfile | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..30601ac --- /dev/null +++ b/Dockerfile @@ -0,0 +1,57 @@ +FROM ubuntu:18.04 + +RUN apt-get update + +# Скачать wget и nano +RUN apt-get install -y wget nano + +# Установка пакетов для компиляции +RUN apt-get install -y build-essential cmake pkg-config + +# Установка OpenBLAS и X11 +RUN apt-get install -y libopenblas-dev liblapack-dev libx11-dev + +# Установка unzip +RUN apt-get install -y unzip + +# Установка OpenGL +RUN apt-get install -y libgl1-mesa-dev + +# Установка GLUT +RUN apt-get install -y freeglut3-dev + +# Установка Boost +RUN apt-get install -y libboost-all-dev + +# Скачать OpenCV 2.4 +RUN wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip; \ +unzip opencv.zip; \ +cd opencv-4.x/; \ +mkdir build; \ +cd build/; \ +cmake ..; \ +cmake --build .; \ +make install; \ +ldconfig; \ +cd ../../; + +# Удалить архив после установки +RUN rm opencv.zip + +# Скачать dlib 19.22 +RUN wget http://dlib.net/files/dlib-19.22.tar.bz2; \ + tar xvf dlib-19.22.tar.bz2; \ + cd dlib-19.22/; \ + mkdir build; \ + cd build; \ + cmake ..; \ + cmake --build . --config Release; \ + make install; \ + ldconfig; \ + cd ../../; + +# Удалить архив dlib после распаковки +RUN rm dlib-19.22.tar.bz2 + +# Скачать bzip2 +RUN apt-get install -y bzip2 \ No newline at end of file From 4355bcb45847e0298ceaa2d60e5801d574994a1b Mon Sep 17 00:00:00 2001 From: Tamerlan Date: Wed, 29 Dec 2021 17:46:45 +0300 Subject: [PATCH 2/4] fix: Change code for compatibility with latest version of OpenCV --- DenseFace3D.cpp | 3 +-- OGL_OCV_common.cpp | 2 +- ThinPlateSpline.h | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/DenseFace3D.cpp b/DenseFace3D.cpp index 1466796..adff544 100644 --- a/DenseFace3D.cpp +++ b/DenseFace3D.cpp @@ -23,8 +23,7 @@ along with DenseFace3D. If not, see . #include #include -#include "cv.h" -#include "highgui.h" +#include "opencv2/opencv.hpp" #include #include diff --git a/OGL_OCV_common.cpp b/OGL_OCV_common.cpp index 465f660..42a789a 100644 --- a/OGL_OCV_common.cpp +++ b/OGL_OCV_common.cpp @@ -101,7 +101,7 @@ void copyImgToTex(const Mat& _tex_img, GLuint* texID, double* _twr, double* _thr if (tex_img.type() == region.type()) { tex_img.copyTo(region); } else if (tex_img.type() == CV_8UC1) { - cvtColor(tex_img, region, CV_GRAY2BGR); + cvtColor(tex_img, region, COLOR_GRAY2BGR); } else { tex_img.convertTo(region, CV_8UC3, 255.0); } diff --git a/ThinPlateSpline.h b/ThinPlateSpline.h index 3a8701d..3470a23 100644 --- a/ThinPlateSpline.h +++ b/ThinPlateSpline.h @@ -65,7 +65,7 @@ class ThinPlateSpline { double bending_energy = 0.0; int p; boost::numeric::ublas::matrix mtx_l,mtx_v,mtx_orig_k,valid; - bool READY = FALSE; + bool READY = false; ThinPlateSpline(int p); void insert(const std::vector& x_coor, const std::vector& y_coor, const std::vector& z_coor); void calc_tps(); From d4e641358b7e08592322cdbf749736706f0b5ad2 Mon Sep 17 00:00:00 2001 From: Tamerlan Date: Wed, 29 Dec 2021 17:57:38 +0300 Subject: [PATCH 3/4] refactor: Translate comments in Dockerfile to english --- Dockerfile | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 30601ac..d5654e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,28 +2,25 @@ FROM ubuntu:18.04 RUN apt-get update -# Скачать wget и nano RUN apt-get install -y wget nano -# Установка пакетов для компиляции RUN apt-get install -y build-essential cmake pkg-config -# Установка OpenBLAS и X11 +# OpenBLAS and X11 RUN apt-get install -y libopenblas-dev liblapack-dev libx11-dev -# Установка unzip RUN apt-get install -y unzip -# Установка OpenGL +# OpenGL RUN apt-get install -y libgl1-mesa-dev -# Установка GLUT +# GLUT RUN apt-get install -y freeglut3-dev -# Установка Boost +# Boost RUN apt-get install -y libboost-all-dev -# Скачать OpenCV 2.4 +# Load OpenCV 4.x RUN wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip; \ unzip opencv.zip; \ cd opencv-4.x/; \ @@ -35,10 +32,9 @@ make install; \ ldconfig; \ cd ../../; -# Удалить архив после установки RUN rm opencv.zip -# Скачать dlib 19.22 +# Load dlib 19.22 RUN wget http://dlib.net/files/dlib-19.22.tar.bz2; \ tar xvf dlib-19.22.tar.bz2; \ cd dlib-19.22/; \ @@ -50,8 +46,6 @@ RUN wget http://dlib.net/files/dlib-19.22.tar.bz2; \ ldconfig; \ cd ../../; -# Удалить архив dlib после распаковки RUN rm dlib-19.22.tar.bz2 -# Скачать bzip2 RUN apt-get install -y bzip2 \ No newline at end of file From 7dc5d0cffcbe99c9a545e6f0afe5e458010c4fce Mon Sep 17 00:00:00 2001 From: Tamerlan Date: Wed, 29 Dec 2021 18:10:09 +0300 Subject: [PATCH 4/4] docs: Add instructions for docker usage --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index cb0adaf..49f9913 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,28 @@ Note: Please make sure `conn.txt` and `landmark.txt` and dlib's default face landmarking model file shape_predictor_68_face_landmarks.dat (download [here](http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2)) are in the same directory as the executable. +##### Installation with Docker +Install [Docker](https://www.docker.com/), clone project from git and build docker image: +```bash +docker build -t dense-face-3d:latest . +``` + +Then disable access to X server: +```bash +xhost + +``` + +Launch container with the following params to use GUI (do not forget to specify absolute path to project): +```bash +docker run -it --rm --privileged \ +--network host --tmpfs=/tmp \ + -v /tmp/.X11-unix:/tmp/.X11-unix:ro \ + -e DISPLAY=:0 -e QT_X11_NO_MITSHM=1 \ + -v :/DenseFace3D \ + --name=dense_container dense-face-3d:latest +``` +Then in container follow the installation instructions. + ##### Installation: `mkdir build`