From 5ad283d9adba7ace2f2412141e7c32cfb3abd0e6 Mon Sep 17 00:00:00 2001 From: Hironori Fujimoto Date: Tue, 20 Aug 2019 17:44:53 +0900 Subject: [PATCH 1/5] Add dockerfile --- docker/dockerfile | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docker/dockerfile diff --git a/docker/dockerfile b/docker/dockerfile new file mode 100644 index 0000000..0c4ca5f --- /dev/null +++ b/docker/dockerfile @@ -0,0 +1,43 @@ +FROM ros:melodic-perception + +RUN apt-get update && apt-get install -y \ + libopenblas-dev \ + unzip \ + wget + +# Install OpenCV 3.4.0 +WORKDIR /root +RUN wget https://github.com/opencv/opencv/archive/3.4.0.zip +RUN unzip 3.4.0.zip +RUN mkdir -p opencv-3.4.0/build +WORKDIR /root/opencv-3.4.0/build +RUN cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_TIFF=ON -D WITH_TBB=ON -D BUILD_SHARED_LIBS=OFF .. +RUN make -j8 +RUN make install + +# Install dlib 19.13 +WORKDIR /root +RUN wget http://dlib.net/files/dlib-19.13.tar.bz2 +RUN tar xf dlib-19.13.tar.bz2 +RUN mkdir -p dlib-19.13/build +WORKDIR /root/dlib-19.13/build +RUN cmake .. +RUN cmake --build . --config Release +RUN make install + +# Install OpenFace 2.1.0 +WORKDIR /root +RUN git clone https://github.com/TadasBaltrusaitis/OpenFace.git +WORKDIR /root/OpenFace +RUN git checkout OpenFace_2.1.0 +RUN bash ./download_models.sh +RUN mkdir build +WORKDIR /root/OpenFace/build +RUN cmake -D CMAKE_BUILD_TYPE=RELEASE CMAKE_CXX_FLAGS="-std=c++11" -D CMAKE_EXE_LINKER_FLAGS="-std=c++11" .. +RUN make -j8 +RUN make install + +# Install openface2_ros +RUN mkdir -p /root/catkin_ws/src +RUN cd /root/catkin_ws/src && git clone https://github.com/ditoec/openface2_ros.git +RUN bash -c "cd /root/catkin_ws && source /opt/ros/melodic/setup.bash && catkin_make" From a1f0f97e6239eb1c44cfa4bbc02d493433a3948c Mon Sep 17 00:00:00 2001 From: Hironori Fujimoto Date: Wed, 21 Aug 2019 10:51:53 +0900 Subject: [PATCH 2/5] Install usb_cam to test --- docker/dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/dockerfile b/docker/dockerfile index 0c4ca5f..f49b9e3 100644 --- a/docker/dockerfile +++ b/docker/dockerfile @@ -41,3 +41,6 @@ RUN make install RUN mkdir -p /root/catkin_ws/src RUN cd /root/catkin_ws/src && git clone https://github.com/ditoec/openface2_ros.git RUN bash -c "cd /root/catkin_ws && source /opt/ros/melodic/setup.bash && catkin_make" + +RUN apt-get update && apt-get install -y ros-melodic-usb-cam + From 42eba2b3582a4947cf8f7bb0ff377b5292d6437c Mon Sep 17 00:00:00 2001 From: Hironori Fujimoto Date: Wed, 21 Aug 2019 10:52:18 +0900 Subject: [PATCH 3/5] Load ROS environment at exec and run --- docker/dockerfile | 10 ++++++++++ docker/ros_entrypoint.sh | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100755 docker/ros_entrypoint.sh diff --git a/docker/dockerfile b/docker/dockerfile index f49b9e3..bc66f86 100644 --- a/docker/dockerfile +++ b/docker/dockerfile @@ -44,3 +44,13 @@ RUN bash -c "cd /root/catkin_ws && source /opt/ros/melodic/setup.bash && catkin_ RUN apt-get update && apt-get install -y ros-melodic-usb-cam +# Load ROS environment at each run +COPY ./ros_entrypoint.sh / +ENTRYPOINT ["/ros_entrypoint.sh"] + +# Load ROS environment at exec bash +RUN echo "source /opt/ros/melodic/setup.bash" >> /root/.bashrc +RUN echo "source /root/catkin_ws/devel/setup.bash" >> /root/.bashrc + +WORKDIR /root/catkin_ws +CMD ["bash"] \ No newline at end of file diff --git a/docker/ros_entrypoint.sh b/docker/ros_entrypoint.sh new file mode 100755 index 0000000..8464352 --- /dev/null +++ b/docker/ros_entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +# setup ros environment +source "/opt/ros/melodic/setup.bash" +source "/root/catkin_ws/devel/setup.bash" +exec "$@" \ No newline at end of file From 02dd8ce67771c4561646b9b87ca9be09459abfb0 Mon Sep 17 00:00:00 2001 From: Hironori Fujimoto Date: Wed, 21 Aug 2019 10:53:05 +0900 Subject: [PATCH 4/5] Add docker-compose to launch test --- docker/docker-compose.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docker/docker-compose.yml diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..ef74b2c --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,32 @@ +version: "3" +services: + master: + build: . + container_name: master + command: roscore + + usb_cam: + build: . + container_name: usb_cam + depends_on: + - master + devices: + - /dev/video0:/dev/video0 + environment: + - ROS_HOSTNAME=usb_cam + - ROS_MASTER_URI=http://master:11311 + command: rosrun usb_cam usb_cam_node + + openface2_ros: + build: . + container_name: openface2_ros + depends_on: + - master + environment: + - DISPLAY + - QT_X11_NO_MITSHM=1 + - ROS_HOSTNAME=openface2_ros + - ROS_MASTER_URI=http://master:11311 + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:rw + command: roslaunch --wait openface2_ros openface2_ros.launch From bf4ee40c4af2287c08bbf4e67cc4f2c7de804d0f Mon Sep 17 00:00:00 2001 From: Hironori Fujimoto Date: Wed, 21 Aug 2019 11:04:59 +0900 Subject: [PATCH 5/5] Add instruction to use docker --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 8eafdaa..fd71004 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,20 @@ If running `openface2_ros` results in a segfault or you see the following lines then openface2 ros is linking against OpenCV2 instead of OpenCV3. To fix this: update cmake to at least 3.6.2, rebuild OpenCV3, clone vision\_opencv into the src folder of your catkin workspace, then recompile cv\_bridge. Remake your catkin workspace, and the segfault and warnings should have been resolved. +## Installation with Docker + +If you don't want to change your environment, you had better to use Docker. + +### Requirements + +* Docker +* Docker Compose + +### Running + +* xhost +local:root +* docker-compose up + ## Published Topics * `/openface2/faces` ( `openface2_ros/faces` )