Intelligent and Scalable Face Recognition System for IP CCTV Cameras with a RESTfull interface.

EBAH7873
Chinese IP CCTV Camera (WiFi / Ethernet Connectivity)

With many cheap Chinese IP CCTV cameras flooding the market and the Internet of Things revolutionizing many devices, I embarked on a personal project; which resulted in the design and development of an intelligent and scalable face recognition system with a RESTfull interface. In simple terms, the system can be scaled up to recognize multiple people from a myriad of cameras. The RESTfull interface allows the system to be Operating System independent and is easy to access using the HTTP GET command.

System Overview

Screenshot_2018-09-04 Screenshot
Home Page of the IP CCTV Face Recognition System.

Multiple IP CCTV cameras were installed and setup across the user’s property and connected to the same Local Area Network; either using Ethernet or Wi-Fi. A RTSP or RTMP stream address is obtained from each of the cameras that the Face Recognition system needs to work on. A Computer (PC or Raspberry Pi) running on Linux is also connected to the same local area network.

Screenshot from 2018-08-27 11-29-40
Results from the Training Algorithm

To train the system to recognize faces, multiple cropped photos of a person’s face was taken under different conditions (lighting, distance from camera, Colour & B/W) and stored in a Known Faces folder. A CSV file was used to map a person’s name to his/her respective face image. The number of face images taken per person and condition was kept the same to avoid any unnecessary biases. An Apple IPhone 6s camera was used to take the training images, due to the high resolution of it’s camera. HDR was used to capture as many face landmarks as possible.

A Python program then ran through the CSV file, whilst extracting face landmarks data from the face images and mapping the landmarks data to the respective person’s name. A Flask Webserver from within the Python program, then started listening for incoming HTTP connections.

Screenshot from 2018-08-27 11-27-52
XML Result

The user can access the Flask Webserver, from anywhere within the LAN, via the following URL: http://host_ip_address:5000/detect/select_camera. The RESTfull service returns the Face Recognition data using the XML format. The user can select the CCTV camera from which they want to perform face recognition by altering the URL.

The Face Recognition Algorithm

Screenshot from 2018-08-27 11-31-47
Euclid Distances between Live Image and Trained Images

When the Face Recognition model is trained, a facial landmarks vector is produced for each trained image. When a new image is taken (i.e. from a live webcam or CCTV feed), the faces from this new image are analyzed and facial landmarks vectors are created. The Euclid Distances between the new image vector and all trained images vectors are calculated. The cut-off Euclid distance for a known face is 0.6, whilst anything beyond that is an unknown face. The trained image with the least Euclid Distance is taken, and the respective Person Name label is returned.

Taking this project further

An analysis is currently being done on a new algorithm, which will allow Face Recognition Data to be periodically posted to the cloud. This algorithm can be accessed and controlled (i.e. start/stop, post frequency, Cloud Identifier) via a separate RESTfull service URL. This will allow for cloud-based events to be created on the receipt of the Face Recognition data (e.g. A smart speaker could speak out a personalized greeting with the recognized person’s name or attendance monitoring at a school/university). The possibilities are endless, and I have just only scratched the beginning.

 

 

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.