NOTE: You only have to issue this (mega) command once (unless you pulled a new version of the facerec
image). This is because the --restart unless-stopped flag tells docker to ensure that the container
is always up and running, even after a reboot.
$ docker stop facerec && docker rm facerec &> /dev/null; \
docker run -dit -v /CCA/known_faces:/src/data/known_faces -p 7777:7777 -p 109:109 --device /dev/video0 --ipc host \
--restart unless-stopped --name facerec arcturusnetworks/facerec && \
docker logs facerec -f
You can receive live face recognition notifications on TCP port 109. For example, you can access them via telnet:
$ telnet 192.168.100.75 109
Trying 192.168.100.75...
Connected to 192.168.100.75.
Escape character is '^]'.
NF[name="Harshad Mahadik", eucldist=0.557691, timestamp="2020-03-12T19:50:19+0000"]
NF[name="Harshad Mahadik", eucldist=0.598658, timestamp="2020-03-12T19:50:23+0000"]
You can access the processed video output at HTTP port 7777.
The following sections describe how to customize various aspects of the facial recognition pipeline.
pipeline.iniThis is a configuration file which is loaded at runtime by the face recognition app. To edit it,
$ docker exec -it facerec bash -c 'vim pipeline.ini'
# make changes and save pipeline.ini, then restart container to apply changes
$ docker commit facerec arcturusnetworks/facerec:latest && docker restart facerec
Before the pipeline starts running it trains a facial recognition engine with a set of images which contain faces to recognize.
To add/remove images, ftp the images to the /known_faces directory on the host. Then, restart the container.
# upload your images to /known_faces via ftp, then
$ docker restart facerec
Note The pipeline example assumes that the file types of all images are
.jpg,.png, or a serialized.datfile (auto-generated).
The facial recognition uses Euclidean distance as a metric for matching detected faces to known faces. This metric measures how closely a detected face matches a known face on a scale of 0 - 1; the smaller the Euclidean distance, the stronger the confidence in the match. So, 0.6 = good match, 0.55 = slightly stricter, 0.5 = very strict, etc. while 0 = perfect match.
To change this threshold, modify the following entry in pipeline.ini
[facerec]
...
eucldistThreshold=0.6
By default the pipeline is recognizing faces from a local USB webcam (/dev/video0). This can be changed to a different source by modifying pipeline.ini
[videosource]
uri=/dev/video0
docker pull arcturusnetworks/facerec:latest