Ubuntu20 に CPU 版の dlib をインストール

Ubuntu20 に CPU 版の dlib をインストールします。

````bash
sudo apt install -y python3-dev python3-pip python3-setuptools python3-venv
#sudo pip3 uninstall ptyprocess sniffio terminado tornado jupyterlab jupyter jupyter-console jupytext nteract_on_jupyter spyder
#sudo apt install -y jupyter jupyter-qtconsole spyder3
sudo apt install -y python3-ptyprocess python3-sniffio python3-terminado python3-tornado 
#sudo pip3 install -U jupyterlab nteract_on_jupyter
sudo apt install -y git cmake cmake-curses-gui cmake-gui wget p7zip-full
sudo apt install -y build-essential gcc g++ make libtool texinfo dpkg-dev pkg-config
cd /usr/local
sudo rm -rf dlib
sudo git clone https://github.com/davisking/dlib
cd /usr/local/dlib
sudo rm -rf build
sudo mkdir build
cd build
sudo cmake -DUSE_AVX_INSTRUCTIONS=YES -DDLIB_USE_CUDA=NO ..
sudo cmake --build .
sudo make install 
which python3
cd /usr/local/dlib
sudo python3 setup.py build
sudo python3 setup.py install 

# python3 sample
cd /usr/local/dlib/python_examples
sudo wget http://dlib.net/files/mmod_human_face_detector.dat.bz2
sudo wget http://dlib.net/files/dlib_face_recognition_resnet_model_v1.dat.bz2
sudo wget http://dlib.net/files/shape_predictor_5_face_landmarks.dat.bz2
sudo wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
sudo bzip2 -d mmod_human_face_detector.dat.bz2
sudo bzip2 -d dlib_face_recognition_resnet_model_v1.dat.bz2
sudo bzip2 -d shape_predictor_5_face_landmarks.dat.bz2
sudo bzip2 -d shape_predictor_68_face_landmarks.dat.bz2
python3 opencv_webcam_face_detection.py

# test
cd /usr/local/dlib/test
sudo mkdir build
cd build
sudo cmake ..
sudo cmake --build . --config Release
sudo ./dtest --runall

# c sample
cd /usr/local/dlib/examples
sudo rm -rf build
sudo mkdir build
cd build
sudo cmake -DUSE_AVX_INSTRUCTIONS=YES -DDLIB_USE_CUDA=NO ..
sudo cmake --build .
sudo wget http://dlib.net/files/mmod_human_face_detector.dat.bz2
sudo wget http://dlib.net/files/dlib_face_recognition_resnet_model_v1.dat.bz2
sudo wget http://dlib.net/files/shape_predictor_5_face_landmarks.dat.bz2
sudo wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
sudo bzip2 -d mmod_human_face_detector.dat.bz2
sudo bzip2 -d dlib_face_recognition_resnet_model_v1.dat.bz2
sudo bzip2 -d shape_predictor_5_face_landmarks.dat.bz2
sudo bzip2 -d shape_predictor_68_face_landmarks.dat.bz2
./webcam_face_pose_ex
````

C言語でのサンプルファイルの作成（おそらく Python で作成したほうがいいかも）

````bash
cd
gedit mysample.c
````

サンプルファイルの中身

````c:mysample.c
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_io.h>
#include <dlib/gui_widgets.h>
#include <iostream>

using namespace dlib;
using namespace std;

int main(int argc, char** argv)
{  
  frontal_face_detector detector = get_frontal_face_detector();
  array2d<unsigned char> img;
  load_image(img, argv[1]);
  pyramid_up(img);
  std::vector<rectangle> dets = detector(img);
  std::vector<rectangle>::iterator it;
  for( it = dets.begin(); it != dets.end(); it++ )
    cout << *it << endl; 

  image_window win;
  win.clear_overlay();
  win.set_image(img);
  win.add_overlay(dets, rgb_pixel(255,0,0));
  cin.get();
}
````

コンパイルと実行（ちょっとエラー undefined reference to `pthread_create' が出ますが雰囲気として）

````bash
sudo apt install -y libblas-dev liblapack-dev
g++ -ldlib -llapack -lblas mysample.c -o mysample.exe
./mysample.out 2007_007763.jpg 
````

####参考リンク
- [Dlib 最新版のインストール（Ubuntu 上）](https://www.kkaneko.jp/tools/ubuntu/ubuntu_dlib_buildout.html)