Facial recognition

๐—”๐—ฃ๐—œ ๐—ณ๐—ฎ๐—ฐ๐—ฒ ๐—ฟ๐—ฒ๐—ฐ๐—ผ๐—ด๐—ป๐—ถ๐˜๐—ถ๐—ผ๐—ป (ageitgey)

 
 
โ–ˆโ–ˆโ–ˆโ–ˆ ๐—จ๐—ง๐—œ๐—Ÿ๐—œ๐—ฆ๐—”๐—ง๐—œ๐—ข๐—ก
 
 
Crรฉer les dir suivants:
 
# mkdir /opt/reco
# mkdir /opt/reco/faces (photos jpg de visages)
โ—† nom fichier : prenom-nom_xx.jpg (xx = 0 ร  99)
 
Exemple : 
kim_kardashian_01.jpg
kim_kardashian_02.jpg
kim_kardashian_03.jpg
...
kim_kardashian_99.jpg
 
โ—† nous allons retirer les caractรจres suivants " _xx.jpg " avec " [:-7] "
 
# mkdir /opt/reco/captures (stockage des visages inconnue)
 
 
๐—ง๐—ฅ๐—”๐—œ๐—ก
# python3 train.py
 
๐—ฅ๐—˜๐—–๐—ข๐—™๐—”๐—–๐—œ๐—”๐—Ÿ
# python3 reco.py --cpus 4
 

โ–ˆโ–ˆโ–ˆโ–ˆ ๐—š๐—ฃ๐—จ

# raspi-config
split under 'Advanced'. Set it up '16'.
 
 
โ–ˆโ–ˆโ–ˆโ–ˆ ๐—ฃ๐—”๐—ค๐—จ๐—˜๐—ง๐—ฆ
 
# apt update
# apt upgrade (15min)
 
# apt install fswebcam  (webcam)
 
apt install build-essential \
    cmake \
    gfortran \
    git \
    wget \
    curl \
    graphicsmagick \
    libgraphicsmagick1-dev \
    libatlas-dev \
    libavcodec-dev \
    libavformat-dev \
    libboost-all-dev \
    libgtk2.0-dev \
    libjpeg-dev \
    liblapack-dev \
    libswscale-dev \
    pkg-config \
    python3-dev \
    python3-numpy \
    python3-pip \
    zip
 
# apt install libatlas3-base
# apt clean
 
 
โ–ˆโ–ˆโ–ˆโ–ˆ ๐—ฃ๐—œ ๐—–๐—”๐— ๐—˜๐—ฅ๐—”
 
# apt install python3-picamera
# pip3 install --upgrade picamera[array]
 
 
Optionnel?
# nano /boot/config.txt
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
gpu_mem=128
start_x=1
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
 
______________________
๐š๐œ๐ญ๐ข๐ฏ๐ž๐ซ ๐œ๐š๐ฆ๐ž๐ซ๐š ๐ซ๐š๐ฌ๐ฉ๐›๐ž๐ซ๐ซ๐ฒ ๐ฉ๐ข
 
# raspi-config
[5] Interfacing Options
[P1] Camera --> YES
 
Vรฉrifier si la camera fonctionne
# vcgencmd get_camera
 

โ–ˆโ–ˆโ–ˆโ–ˆ ๐——๐—Ÿ๐—œ๐—• (25min)

# cd /opt && mkdir -p dlib
# git clone -b 'v19.6' --single-branch https://github.com/davisking/dlib.git dlib/
# cd ./dlib
# python3 setup.py install --compiler-flags "-mfpu=neon"


โ–ˆโ–ˆโ–ˆโ–ˆ ๐—”๐—š๐—˜๐—œ๐—š๐—ง๐—˜๐—ฌ ๐—™๐—”๐—–๐—œ๐—”๐—Ÿ ๐—ฅ๐—˜๐—–๐—ข ๐—”๐—ฃ๐—œ

# pip3 install face_recognition


โ–ˆโ–ˆโ–ˆโ–ˆ ๐—ฅ๐—˜๐—–๐—ข๐—š๐—ก๐—œ๐—ง๐—œ๐—ข๐—ก ๐—–๐—ข๐——๐—˜ ๐—˜๐—ซ๐—”๐— ๐—ฃ๐—Ÿ๐—˜

# cd /opt && mkdir -p ageitgey
# git clone --single-branch https://github.com/ageitgey/face_recognition.git ageitgey/
# cd ./face_recognition/examples
# python3 facerec_on_raspberry_pi.py

 


โ–ˆโ–ˆโ–ˆโ–ˆ ๐—š๐—˜๐—ง ๐—•๐—˜๐—ง๐—ง๐—˜๐—ฅ ๐—ฃ๐—˜๐—ฅ๐—™๐—ข๐—ฅ๐— ๐—”๐—ก๐—–๐—˜ (optio?)


โ–ˆ ๐จ๐ฉ๐ž๐ง๐›๐ฅ๐š๐ฌ
# apt install libopenblas-dev liblapack-dev libatlas-base-dev

On injecte dans l'environnement du shell avant l'execution du script de reco

# export OPENBLAS_NUM_THREADS=1 
# export OPENBLAS_MAIN_FREE=1

source : https://gist.github.com/ageitgey/1ac8dbe8572f3f533df6269dab35df65#gistcomment-2071073


โ–ˆโ–ˆโ–ˆโ–ˆ ๐—ง๐—˜๐—Ÿ๐—˜๐—š๐—ฅ๐—”๐— 

# pip3 install python-telegram-bot --upgrade
source : https://github.com/python-telegram-bot/python-telegram-bot


โ–ˆโ–ˆโ–ˆโ–ˆ ๐—ฉ๐—ข๐—œ๐—–๐—˜ ๐—ง๐—ง๐—ฆ

Puis installation de pico tts, la voix synthรฉtique est de 
meilleur qualitรฉ que 'espeak' ou 'google'
# apt install libttspico-utils

Augmenter le volume gรฉnรฉral au max
# amixer sset 'PCM' 100%

source : https://la-programmation.surleweb-france.fr/linux-faire-parler-systeme/
source : https://www.framboise314.fr/donnez-la-parole-a-votre-raspberry-pi/


โ–ˆโ–ˆโ–ˆโ–ˆ ๐—ฆ๐—ฌ๐—ฆ๐—ง๐—˜๐— ๐——


# nano /lib/systemd/system/recofacial.service
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
[Unit]
Description=Facial Reco
After=network.target

[Service]
Type=forking
ExecStart=/opt/reco/cronfacial.sh
Restart=always
RuntimeMaxSec=43200

[Install]
WantedBy=multi-user.target
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

RuntimeMaxSec=43200 = reboot du prog toute les 12h


# systemctl daemon-reload
# systemctl enable recofacial
# systemctl start recofacial


# nano /opt/reco/cronfacial.sh
# chmod +x cronfacial.sh
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
#!/usr/bin/env bash

cd /opt/reco/
screen -dmS recofacial python3 /opt/reco/reco.py --cpus 4
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•


โ–ˆ ๐œ๐จ๐ซ๐ซ๐ฎ๐ฉ๐ญ๐ข๐จ๐ง ?


๐™๐™ฎ๐™ฅ๐™ค๐™ฉ๐™๐™š๐™จ๐™š 1
Aprรจs 35heures de fonctionnement, le systรจme se voit apparaรฎtre une fuite de mรฉmoire...
On remarque facilement les crontabs screen de 4h.

๐™๐™ฎ๐™ฅ๐™ค๐™ฉ๐™๐™š๐™จ๐™š 2
Visiblement la fautive serait la pi camera !
source : https://github.com/raspberrypi/linux/issues/2680  (faire CTRL+F : camera)

๐™๐™ฎ๐™ฅ๐™ค๐™ฉ๐™๐™š๐™จ๐™š 3 ( โœ“ โœ“ ) (( ๐ž๐๐ข๐ญ ๐ฌ๐ž๐ฉ๐ญ๐ž๐ฆ๐›๐ซ๐ž ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ—))
trop de reboot de la carte SD, il y a des dรฉgats sur le FileSystem (FS)
besoin de rรฉparer avec l'utilitaire "fsck"

( screen UAG478 )
( screen YZB416 ) 

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
# fsck /dev/mmcblk0p1
1) Remove dirty bit  <----
2) No action
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

https://raspberrypi.stackexchange.com/questions/251/how-can-i-determine-when-an-sd-card-needs-replacement

edit : idรฉe, mettre un watchdog du process screen, si down alors faire la commande qui repare la carte SD puis reboot

# cat /var/log/kern.log
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
Jan 21 04:00:20 raspberrypi kernel: [135619.301497] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 21 08:13:25 raspberrypi kernel: [150804.353280] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 21 12:00:20 raspberrypi kernel: [164419.222848] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 21 16:00:19 raspberrypi kernel: [178818.772892] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 21 20:00:20 raspberrypi kernel: [193219.314390] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 22 00:00:20 raspberrypi kernel: [207619.939983] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 22 04:00:20 raspberrypi kernel: [222019.662578] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 22 08:58:54 raspberrypi kernel: [239933.801494] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 22 12:00:19 raspberrypi kernel: [250819.417679] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 22 16:00:20 raspberrypi kernel: [265219.816146] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 22 20:00:20 raspberrypi kernel: [279620.458547] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 23 00:00:20 raspberrypi kernel: [294020.066337] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 23 04:00:20 raspberrypi kernel: [308420.471800] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 23 08:00:20 raspberrypi kernel: [322820.903216] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 23 12:00:20 raspberrypi kernel: [337220.452950] cma: cma_alloc: alloc failed, req-size: 1 pages, ret: -16
Jan 23 13:13:24 raspberrypi kernel: [    0.000000] Booting Linux on physical CPU 0x0
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

A l'heure actuelle, je ne trouve aucune solution mise ร  part un reboot du systรจme 
Pas tรฉrrible pour la sdcards sur la longueur. Nous allons faire ce reboot via crontab.

# nano /opt/reco/reboot.sh
# chmod +x reboot.sh
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
#!/usr/bin/env bash

screen -X -S recofacial kill
sleep 20
/sbin/shutdown -r now
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

# crontab -e  (reboot miniuit tous les jours)
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
0 0 * * * /opt/reco/reboot.sh >/dev/null 2>&1
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐ž๐๐ข๐ญ ๐ฃ๐ฎ๐ข๐ฅ๐ฅ๐ž๐ญ ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ— : 3 fois sur 5 nous avons cette erreur au reboot de la Pi

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
root@raspberrypi:/opt/reco# python3 reco.py --cpus 4
Traceback (most recent call last):
  File "reco.py", line 3, in <module>
    import face_recognition
  File "/usr/local/lib/python3.5/dist-packages/face_recognition/__init__.py", line 7, in <module>
    from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
  File "/usr/local/lib/python3.5/dist-packages/face_recognition/api.py", line 17, in <module>
    pose_predictor_68_point = dlib.shape_predictor(predictor_68_point_model)
RuntimeError: Error deserializing object of type short
   while deserializing a floating point number.
   while deserializing a dlib::matrix
   while deserializing object of type std::vector
   while deserializing object of type std::vector
   while deserializing object of type std::vector
root@raspberrypi:/opt/reco#
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

ce problรจme pourrait etre du ร  la carte micro SD, corruption?
pour pallier le problรจme, il faut reboot jusqu'a ce que le systeme (carte sd?) soit ok
et donc le programme pourra รชtre lancรฉ!


la solution: arreter de reboot toute les nuits. mettre un reboot du prog sur systemd
=============
Restart=always
RuntimeMaxSec=604800
=============

๐—ฒ๐—ฑ๐—ถ๐˜ : Rigolo.. Adrian Rosebrock recommande aussi
d'utiliser un script bash puis d'appeller un script python


โ–ˆโ–ˆโ–ˆโ–ˆ ๐—ข๐—จ๐—ฉ๐—˜๐—ฅ๐—ง๐—จ๐—ฅ๐—˜ ๐—ฃ๐—ข๐—ฅ๐—ง๐—˜



โ–ˆ ๐ฌ๐ฌ๐ก ๐ฉ๐š๐ฌ๐ฌ๐ฐ๐จ๐ซ๐๐ฅ๐ž๐ฌ๐ฌ


(Depuis rpi recofacial)
# ssh-keygen
Enter passphrase (empty for no passphrase):  on laisse vide


# ssh-copy-id user@ip_relai
normalement nous pouvons รชtre log passwordless


# ssh user@ip_relai
source : https://askubuntu.com/questions/46930/how-can-i-set-up-password-less-ssh-login


โ–ˆ ๐ฌ๐œ๐ซ๐ข๐ฉ๐ญ ๐ฉ๐ฒ๐ญ๐ก๐จ๐ง ๐ซ๐ž๐œ๐จ.๐ฉ๐ฒ

Pas besoin d'utiliser de librairies comme "paramiko"
juste quelques lignes suffisent avec subprocess
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—

import subprocess
import sys
...

HOST="pi@192.168.1.24"
COMMAND="sudo python relay.py"
...
ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND])

โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

voir : hg commit nยฐ 13 et 15"
source : https://stackoverflow.com/questions/28411960/execute-a-command-on-remote-machine-in-python/28413657#28413657

sinon pour paramiko (mais on l'utilise pas!) :
* https://github.com/paramiko/paramiko
* https://blog.ruanbekker.com/blog/2018/04/23/using-paramiko-module-in-python-to-execute-remote-bash-commands/
* https://stackoverflow.com/questions/3586106/perform-commands-over-ssh-with-python (best!)

# pip3 install paramiko


โ–ˆ ๐๐ข ๐‘๐ž๐ฅ๐š๐ฒ
voir guide install basics rpi puis,
$ cd ~
$ nano relay.py
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—

import time
import RPi.GPIO as GPIO

GPIO.setwarnings(False)

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17, GPIO.LOW)

time.sleep(4)

GPIO.output(17, GPIO.HIGH)
GPIO.cleanup()

โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
source : https://github.com/teroknor01/relay_pi/blob/master/relay.py

$ chmod +x relay.py

โžค GPIO.setwarnings(False)
on dรฉsactive log warning ร  cause de

/home/pi/relay.py:7: RuntimeWarning: This channel is already in use, continuing anyway.  Use GPIO.setwarnings(False) to disable warnings.
car le trigger s'active hyper rapidement avec la boucle for

โžค time.sleep(4)
4 secondes c'est le temps durant lequel on resterait appuyer 
sur l'interrupteur de la porte

connection PIN photos




โ–ˆ ๐‘๐ž๐›๐จ๐จ๐ญ ๐๐ข ๐‘๐ž๐ฅ๐š๐ฒ
Etrange aprรจs plusieurs jours
le temps de latence augmente sur la commande SSH
un reboot daily est nรฉcessaire

$ sudo nano /home/pi/reboot.sh
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
#!/usr/bin/env bash

sudo /sbin/shutdown -r now
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
$ sudo chmod +x reboot.sh

$ crontab -e  (reboot miniuit tous les jours)
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
0 0 * * * /home/pi/reboot.sh >/dev/null 2>&1
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

โ–‘โ–„โ–ˆโ–€โ–€โ–ˆโ–ˆโ–ˆโ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–ˆโ–ˆโ–„โ–‘โ–‘โ–‘โ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–ˆโ–€โ–‘โ–„โ–ˆโ–€โ–‘โ–„โ–„โ–€โ–€โ–€โ–€โ–€โ–€โ–ˆโ–„โ–‘โ–€โ–ˆ

 

๐ƒ๐”๐๐‹๐ˆ๐๐”๐„๐‘ ๐‹๐€ ๐’๐Ž๐‘๐“๐ˆ๐„ ๐‡๐ƒ๐Œ๐ˆ


By mirroring /dev/fb0 onto /dev/fb1, we can take advantage of the GPU for hardware accelrated video playback.
fbcp takes a snapshot of /dev/fb0, copies it to /dev/fb1 and waits 25ms before repeating.
Snapshotting takes ~10ms and with a 25ms delay it gives roughly 1000/(10+25) = 28fps
CPU usage: ~2% Note: Snapshot and /dev/fb1 driver refresh is not syncronized.

If you have a TFT display , you must use omxplayer and fbcp together
fbcp has to run in the background.

Il est impossible out of the box d'utiliser omxplayer.
omxplayer utilise le fb0 (hdmi) et rien d'autre..
la seule solution c'est de copier le flux du fb0 vers fb1

-----------
๐™€๐™๐™๐˜ผ๐˜พ๐™€๐™ ๐™‡๐™€ ๐™๐™๐™” (commun aux 2 mรฉthodes ci-dessous)

mettre un delay pour l'execution du script dans la crontab
pour รชtre certain que le shell soit terminer ร  100%
puis mettre de couleur noir le shell :p black is black.

# cd ~
# nano clear.sh
# chmod +x clear.sh
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
#!/usr/bin/env bash
TERM=linux setterm -foreground black -clear all >/dev/tty1
# la commande dd ci-dessous fonctionne, mais me semble un poil aggressif?
# dd if=/dev/zero of=/dev/fb0
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# crontab -e
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
@reboot sleep 120 && /root/clear.sh
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

https://raspberrypi.stackexchange.com/questions/3268/how-to-disable-local-terminal-showing-through-when-playing-video/3269#3269


โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ ๐—™๐—•๐—œ (๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ ๐—ฏ๐˜‚๐—ณ๐—ณ๐—ฒ๐—ฟ ๐—ถ๐—บ๐—ฎ๐—ด๐—ฒ ๐˜ƒ๐—ถ๐—ฒ๐˜„๐—ฒ๐—ฟ)


๐—™๐—• (๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ ๐—ฏ๐˜‚๐—ณ๐—ณ๐—ฒ๐—ฟ)
fb0 = HDMI
fb1 = LCD
On check si fb1 est lร 
# ls /dev/fb*


๐™ข๐™š๐™ข๐™ค๐™ž๐™ง๐™š
Je sais pas si c'est l'utilisation du LCD, mais le script crash
pour de la mรฉmoire avec le message suivant :
"picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources"

On augmente de 128MB ร  256MB
# raspi-config
Advanced options -> Memory split -> and set at least 256MB
source : https://raspberrypi.stackexchange.com/questions/26829/picamera-not-working


๐™„๐™ฃ๐™จ๐™ฉ๐™–๐™ก๐™ก๐™–๐™ฉ๐™ž๐™ค๐™ฃ
# apt install fbi
Creation dossier contenant les visages qui seront afficher sur le LCD
# mkdir /recofacial/reco/lcd


โ–ˆ ๐˜พ๐™ค๐™ข๐™ข๐™–๐™ฃ๐™™๐™š ๐™๐˜ฝ๐™„ ๐™ฅ๐™ง๐™ž๐™ฃ๐™˜๐™ž๐™ฅ๐™–๐™ก๐™š
# fbi -T 1 -d /dev/fb1 -noverbose -t 5 -1 -once /opt/reco/lcd/{}.jpg

๐—˜๐˜…๐—ฝ๐—น๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ณ๐—น๐—ฎ๐—ด๐˜€:
-T 1     = console tty nยฐ1 (nous avons 6 tty, switch entre-eux [Ctrl]+[Alt][F1-6])
-d         = device sur framebuffer1 , le lcd
-t 5 -1 = durรฉe affichage image 5 secondes et -1 termine le loop de FBI, donc รฉcran noir

 


โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ ๐—ข๐— ๐—ซ๐—ฃ๐—Ÿ๐—”๐—ฌ๐—˜๐—ฅ

omxplayer est un excellent sur unix, il est super lรฉger

Creation dossier contenant les visages qui seront afficher sur le LCD
# mkdir /recofacial/reco/lcd

# apt install omxplayer

Puis dans le script python reco
os.system("omxplayer --orientation 270 /opt/reco/lcd/{}.mp4".format(name))

Je n'utilise pas le flag : -b 
qui permet un black screen, vue que j'ai dรฉjร  black la console dans le boot
sa permet peut-etre d'รฉconomiser du CPU sur omxplayer.

 

 
โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ ๐——๐—˜๐—ฆ๐—”๐—–๐—ง๐—œ๐—ฉ๐—˜๐—ฅ ๐—–๐—ข๐—ก๐—ฆ๐—ข๐—Ÿ๐—˜ ๐—กยฐ๐Ÿญ 
 
JE N'UTILISE PAS CETTE PARTIE !!!
 
 
๐Œ๐ž๐ญ๐ก๐จ๐๐ž ๐Ÿ
 
On va desactiver le console vt220 du LCD, le login prompt quoi ! plus de curseur qui clignote.
# systemctl disable serial-getty@ttyAMA0.service
# reboot
 
Pas d'inquiรฉtude il nous reste 5 autres consoles avec [ctrl] [alt] [f2-6]
source : https://raspberrypi.stackexchange.com/questions/39165/how-can-i-stop-the-auto-login-console-and-getty-in-raspbian-8-jessie
 
 
๐Œ๐ž๐ญ๐ก๐จ๐๐ž ๐Ÿ (mรฉthode choisi โœ”โœ”)
# raspi-config
[5] Interfacing Options
[P6 Serial] 
Login shell : NO
Would you like the serial port hardware to be enabled? YES
[FINISH]
[Reboot]
 
results:
The serial login shell is disabled
The serial interface is enabled 
 
--------
Bon ok. Les 2 mรฉthodes ne semble pas fonctionner,
j'ai toujours un prompt login qui clignote, et ou
je peu taper des caractรจres. Bon c'est pas trรจs grave apres !
 
 
 
๐Œ๐ž๐ญ๐ก๐จ๐๐ž 3
 
On dรฉsactive le login prompt
# systemctl disable getty@tty1
 

โ–‘โ–„โ–ˆโ–€โ–€โ–ˆโ–ˆโ–ˆโ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–ˆโ–ˆโ–„โ–‘โ–‘โ–‘โ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–„โ–ˆโ–€โ–€โ–ˆโ–ˆโ–ˆโ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–ˆโ–ˆโ–„โ–‘โ–‘โ–‘โ–„โ–ˆโ–€โ–‘โ–„โ–ˆโ–€โ–‘โ–„โ–„โ–€โ–€โ–€โ–€โ–€โ–€โ–ˆโ–„โ–‘โ–€โ–ˆโ–„โ–„โ–ˆโ–ˆโ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–ˆโ–€
๐—–๐—ฅ๐—˜๐—”๐—ง๐—œ๐—ข๐—ก ๐— ๐—œ๐—ก๐—œ ๐—ฉ๐—œ๐——๐—˜๐—ข


๐—ข๐—•๐—ฆ - ๐—ฐ๐—ฎ๐—ฝ๐˜๐˜‚๐—ฟ๐—ฒ ๐—ฒ๐—ฐ๐—ฟ๐—ฎ๐—ป ๐—ฝ๐—ฐ (๐˜€๐—ถ๐—บ๐—ถ๐—น๐—ฎ๐—ถ๐—ฟ๐—ฒ ๐—™๐—ฟ๐—ฎ๐—ฝ๐˜€)
Tรฉlรฉcharger OBS
https://obsproject.com/fr

๐˜ƒ๐—ถ๐˜€๐—ฎ๐—ด๐—ฒ๐Ÿฏ๐—ฑ
Utiliser le site suivant pour faire un visage 3D
http://cvl-demos.cs.nott.ac.uk/vrn/index.php
puis filmer l'รฉcran avec OBS

๐—ฆ๐—ข๐—ก๐—ฌ ๐—ฉ๐—˜๐—š๐—”๐—ฆ
utiliser les templates "lcd"
dans les FX puis dans le render
 

โ–‘โ–„โ–ˆโ–€โ–€โ–ˆโ–ˆโ–ˆโ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–ˆโ–ˆโ–„โ–‘โ–‘โ–‘โ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–„โ–ˆโ–€โ–€โ–ˆโ–ˆโ–ˆโ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–ˆโ–ˆโ–„โ–‘โ–‘โ–‘โ–„โ–ˆโ–€โ–‘โ–„โ–ˆโ–€โ–‘โ–„โ–„โ–€โ–€โ–€โ–€โ–€โ–€โ–ˆโ–„โ–‘โ–€โ–ˆโ–„โ–„โ–ˆโ–ˆโ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–ˆโ–€
 
Pendant ce temps lร ..
 
Nous pouvons creer un script (python, bash, etc..) qui porte simplement le nom de la personne :-)

Pleins d'utilisation !
os.system("mon logiciel /opt/reco/lcd/{}.mp4".format(name))
os.system("mon logiciel /opt/reco/lcd/{}.mp3".format(name))
os.system("mon logiciel /opt/reco/lcd/{}.txt".format(name))
os.system("mon logiciel /opt/reco/lcd/{}.sh".format(name))
 

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
๐—™๐—”๐—จ๐—ซ ๐—ฃ๐—ข๐—ฆ๐—œ๐—ง๐—œ๐—™

๐™‰๐™ž๐™˜๐™ค๐™ก๐™–๐™จ: Comme l'indique Adrian, il s'agit un rรฉseaux neurones
prรฉ entainer sur des millions de visages (majoritairement blanc)
pour calculer les 128D. Il recommande d'entrainer le rรฉseaux neurones
sur nos propres visages pour รฉviter de faux positif.

๐™Œ๐™ช๐™š๐™จ๐™ฉ๐™ž๐™ค๐™ฃ ๐™ฉ๐™ค๐™ข๐™ข๐™ฎ
Hi, Adrian.
Always thanks for your wonderful article.
I have tested your code for a week.
It was working for small dataset(1~2 people face).
But when I increased number of people(upto 10), 
it looked unstable sometims.

๐™๐™š๐™ฅ๐™ค๐™ฃ๐™จ๐™š
Once you start getting more and more people in your dataset
this method will start to fail. Keep in mind that weโ€™re
leveraging a pre-trained network here to compute the 128-d
facial embeddings. Try instead fine-tuning the network itself
on the people you want to recognize to increase accuracy.

source : https://www.pyimagesearch.com/2018/09/24/opencv-face-recognition/#comment-485420

ajuster la tolรฉrance pour รฉviter les faux positives
https://github.com/ageitgey/face_recognition/wiki/Face-Recognition-Accuracy-Problems
 

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
๐—ง๐—ข๐——๐—ข

โžค ๐ƒ๐จ๐ฎ๐›๐ฅ๐ž ๐Ÿ๐š๐œ๐ญ๐ž๐ฎ๐ซ (new)
" pour de la double auth, 
pourquoi ne pas utiliser le probe request wifi, ou du bluetooth
regarder mes projets probe request python "

rpi zรฉro bluetooth. smartphone auto connect bluetooth (check nouveau device connected) ouvre la porte

https://towardsdatascience.com/real-time-face-liveness-detection-with-python-keras-and-opencv-c35dc70dafd3
https://www.youtube.com/watch?v=arQN6w0fZw8&feature=youtu.be
https://www.pyimagesearch.com/2019/03/11/liveness-detection-with-opencv
https://github.com/ageitgey/face_recognition/issues/371

โžค๐ƒ๐š๐ญ๐š๐ฌ๐ž๐ญ๐ฌ ๐Ÿ๐จ๐ซ ๐ฆ๐š๐œ๐ก๐ข๐ง๐ž ๐ฅ๐ž๐š๐ซ๐ง๐ข๐ง๐ 
https://www.datasetlist.com/

โžค๐—”๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ถ๐—ฐ ๐— ๐—ฎ๐—ฐ๐—ต๐—ถ๐—ป๐—ฒ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ถ๐—ป๐—ด
https://www.makeml.app/?ref=producthunt

โžค๐—š๐—”๐—–๐—›๐—˜ ๐—˜๐—Ÿ๐—˜๐—–๐—ง๐—ฅ๐—œ๐—ค๐—จ๐—˜ (serrure electrique comme au bureau)
https://www.manomano.fr/serrure-electrique-2266
https://youtu.be/-dMSBzsO2Qw

โžค๐—ฐ๐—ฟ๐—ผ๐—ฝ
https://github.com/theidentity/Face-Tracker/blob/master/detect_faces.py#L11
https://github.com/ageitgey/face_recognition/blob/master/examples/blur_faces_on_webcam.py#L35

โžค๐—š๐—ฒ๐˜ ๐—ป๐—ฎ๐—บ๐—ฒ๐˜€ ๐—ณ๐—ฟ๐—ผ๐—บ ๐—ป๐—ฎ๐—บ๐—ฒ ๐—ณ๐—ผ๐—น๐—ฑ๐—ฒ๐—ฟ ๐—ถ๐—ป๐˜€๐˜๐—ฒ๐—ฎ๐—ฑ ๐—ผ๐—ณ ๐—ณ๐—ถ๐—น๐—ฒ๐—ป๐—ฎ๐—บ๐—ฒ
https://github.com/ManishaNatarajan/Facial-Recognition/blob/master/get_encodings.py
https://github.com/ageitgey/face_recognition/issues/599#issuecomment-417850005
https://github.com/jrosebr1/imutils

โžค๐—จ๐˜๐—ถ๐—น๐—ถ๐˜€๐—ฒ๐—ฟ ๐—ฆ๐—ค๐—Ÿ ๐—ฝ๐—ผ๐˜‚๐—ฟ ๐˜€๐˜๐—ผ๐—ฐ๐—ธ๐—ฒ๐—ฟ ๐—น๐—ฒ๐˜€ ๐Ÿญ๐Ÿฎ๐Ÿด๐——
https://github.com/Nakroma/facial_recognition_system
https://github.com/ageitgey/face_recognition/issues/403#issuecomment-376136244
https://github.com/vearutop/face-postgre
https://github.com/d-demirci/face-postgre

โžค๐—š๐—จ๐—œ
https://github.com/TheDogeOfTheInternet/ModFaceMatch
 

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
๐—Ÿ๐—˜๐—–๐—ง๐—จ๐—ฅ๐—˜๐—ฆ / ๐—ฆ๐—ข๐—จ๐—ฅ๐—–๐—˜๐—ฆ

โžค๐ˆ๐ง๐ฌ๐ญ๐š๐ฅ๐ฅ๐š๐ญ๐ข๐จ๐ง
https://robotzero.one/face-recognition-party-greeter-raspberry-pi/
https://gist.github.com/ageitgey/1ac8dbe8572f3f533df6269dab35df65

โžค๐ƒ๐ข๐ฏ๐ž๐ซ๐ฌ
https://twitter.com/techinsider/status/1114222166713741312?s=21
https://blog.csdn.net/qq_30460905/article/details/80864081
https://github.com/ageitgey/face_recognition/issues/501#issuecomment-395716780
https://twitter.com/shirokunet/status/1174322070265556993?s=12

โžค๐—–๐—ผ๐—บ๐—บ๐—ฒ๐—ป๐˜ ๐——๐—Ÿ๐—œ๐—• ๐—ฒ๐˜…๐˜๐—ฟ๐—ฎ๐—ถ๐˜ ๐—น๐—ฒ๐˜€ ๐Ÿญ๐Ÿฎ๐Ÿด ๐—ฑ๐—ถ๐—บ๐—ฒ๐—ป๐˜€๐—ถ๐—ผ๐—ป๐˜€
http://dlib.net/dnn_metric_learning_on_images_ex.cpp.html
 
Download this blog post with all media included in a single HTML file (5,44 Mo)