Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add installation by Docker #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` )
Expand Down
32 changes: 32 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
56 changes: 56 additions & 0 deletions docker/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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"

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"]
7 changes: 7 additions & 0 deletions docker/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"