Installation procedure:
Go into your configuration.yaml and follow this to setup your camera
Note that the input can only be an url (rtsp or http)
and follow this page to setup the dlib component
setting it up the source to be your ffmpeg camera.
you should be able to see your dlib component on lovelace
ffmpeg if you want GPU video decoding:
mkdir -p source/
cd source
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers && sudo make install && cd –
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
./configure --enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --enable-pic --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --extra-ldexeflags=-pie
make
sudo make install
sudo mv ffmpeg /usr/bin
cd ..
git clone https://github.com/davisking/dlib.git
cd dlib
git submodule init
git submodule update
mkdir build
cd build
cmake -D DLIB_USE_CUDA=1 -D USE_AVX_INSTRUCTIONS=1 ../
cd ../
python setup.py install
Now the mods:
activate your venv and run this:
pip install git+https://github.com/rafale77/face_recognition_models
pip install git+https://github.com/rafale77/face_recognition
pip install opencv-python-headless
pip install opencv_contrib_python_headless
pip install sklearn
cd ..
if want to use GPU, Build opencv with CUDA:
git clone https://github.com/opencv/opencv.git
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D WITH_CUDA=ON \
-D WITH_CUDNN=ON \
-D WITH_CAFFE=ON \
-D WITH_NVCUVID=ON \
-D OPENCV_DNN_CUDA=ON \
-D ENABLE_FAST_MATH=ON \
-D CUDA_FAST_MATH=ON \
-D CUDA_ARCH_BIN=7.5 \
-D WITH_CUBLAS=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/source/opencv_contrib/modules \
-D HAVE_opencv_python3=ON \
-D PYTHON_EXECUTABLE=/usr/bin/python3 \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D PYTHON2_EXECUTABLE=/usr/bin/python \
-D CMAKE_CUDA_FLAGS=-lineinfo --use_fast_math -rdc=true -lcudadevrt \
-D BUILD_EXAMPLES=OFF ..
make
sudo make install
Change the “CUDA_ARCH_BIN” to be the one corresponding to your GPU. 7.5 is for the turing GPUs
ok now everything is set
find the ffmpeg component within your venv:
homeassistant/lib/python3.7/site-packages/ffmpeg/
and replace the camera.py file with this one:
comment out line 19 if you do not use a GPU
find the dlib face identify component
homeassistant/lib/python3.7/site-packages/dlib_face_identify/
and replace the image_processing.py with this one
note that line 84 is where you input the folder where your pictures are going to be, you can change this depending on your setup below:
You are done with installation! Now the setup.
Create a folder where you will put pictures used to train the model. In my example it is in my .homeassistant configuration folder
~/.homeassistant/recogface/faces/
Create one folder for each person you want recognized and one “unknown” folder and copy in all the pictures you want. I recommend at least 20 pics in each
restart home assistant