Shotwell – How to Install Shotwell with Face Detection in Ubuntu 18.04

opencvshotwell

I'm transitioning from Google Photos and I really liked Shotwell's features. However, face detection/recognition is very important to me because of how I manage my photos. I viewed this blog post that apparently shows how to do it, but it's very vague IMO since I'm not exactly an expert in this area. I tried doing the meson build but there were a ton of dependencies that I manually installed (maybe wasn't supposed to do that?) and one of them messed up my apt system (I ended fixing that by removing all other software in the Software app and doing a dist-upgrade which removed unnecessary packages and dependencies).

Is there a more step-by-step guide to doing this? I really like Shotwell but I must have the face detection feature (I know that it is in beta, but I saw a video that proves it works).

(I know I could use digiKam but I really like Shotwell!)

Best Answer

Here's what you could do:

# Downloads will be our workspace
cd ~/Downloads

# prepare the terrain by removing unwanted divs
sudo apt remove shotwell gir1.2-gexiv2-0.11 -y
# install dependencies (takes about 30 mins to complete)
sudo apt install unzip meson valac libgphoto2-dev libgudev-1.0-dev \
libgee-0.8 libgtk-3-dev gir1.2-gexiv2-0.10 libgexiv2-2 libwebkit2gtk-4.0 \
libgstreamer1.0-0 libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc \
gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 \
gstreamer1.0-qt5 gstreamer1.0-pulseaudio libraw-dev build-essential \
build-essential checkinstall cmake pkg-config yasm gfortran gstreamer1.0-tools \
libjpeg8-dev libpng-dev software-properties-common libjasper1 libtiff-dev \
libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev \
libv4l-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgtk2.0-dev \
libtbb-dev qt5-default libatlas-base-dev libfaac-dev libmp3lame-dev libtheora-dev \
libvorbis-dev libxvidcore-dev libopencore-amrnb-dev libopencore-amrwb-dev \
libavresample-dev x264 v4l-utils libprotobuf-dev protobuf-compiler \
libgoogle-glog-dev libgflags-dev libgphoto2-dev libeigen3-dev libhdf5-dev \
doxygen python3-dev python3-pip \
-y
# install one package via pip
sudo -H pip3 install -U pip numpy
# continue install now that pip deps are met
sudo apt -y install python3-testresources

# python virtualenv creation
cd
python3 -m venv opencv-4.1.0-py3
source ~/opencv-4.1.0-py3/bin/activate
# now install python libraries within this virtual environment
pip install wheel numpy scipy matplotlib scikit-image scikit-learn ipython dlib
# quit virtual environment
deactivate

# some post install
cd /usr/include/linux
sudo ln -s -f ../libv4l1-videodev.h videodev.h
cd ~/Downloads

# fulfill opencv 4.1 dependency by building from source
# this won't work yet, working off of :
# https://www.learnopencv.com/install-opencv-4-on-ubuntu-18-04/
sudo apt build-dep opencv
cd ~/Downloads
wget -O opencv-4.1.0.zip https://github.com/opencv/opencv/archive/4.1.0.zip
unzip -q opencv-4.1.0.zip
cd opencv-4.1.0/build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D OPENCV_PYTHON3_INSTALL_PATH=~/opencv-4.1.0-py3/lib/python3.5/site-packages \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
make -j4
make install
cd build
cmake ..
cmake --build . --config Release
# still need to move built binary to usable space and declare it system-wide

# No idea how to do DNN models
# !!!

# fulfill exiv2 0.27 dependency by building from source
sudo apt build-dep exiv2
cd ~/Downloads
wget https://www.exiv2.org/builds/exiv2-0.27.1-Source.tar.gz
tar xf exiv2-0.27.1-Source.tar.gz
cd exiv2-0.27.1-Source/
cmake .
make
sudo make install

# fulfill libgexiv2-dev 0.12 dependency by building from source
sudo apt build-dep libgexiv2-dev
cd ~/Downloads
wget http://ftp.gnome.org/pub/GNOME/sources/gexiv2/0.12/gexiv2-0.12.0.tar.xz
tar xf gexiv2-0.12.0.tar.xz
cd gexiv2-0.12.0/
meson build
cd build
sudo meson install

# final build of shotwell with face detection
sudo apt build-dep shotwell
cd ~/Downloads
wget https://gitlab.gnome.org/nma83/shotwell/
\-/archive/wip/faces/shotwell-wip-faces.tar.gz
tar xzf shotwell-wip-faces.tar.gz
cd shotwell-wip-faces
meson configure -Dface-detection=true
meson build
cd build
sudo meson install

Note: my post is WIP and edits will be accepted.

Update: I'm losing hope, I can't figure out how to get an install of opencv and how to get the mentioned DNN models from OpenFace.