Final Iot PR
Final Iot PR
Branch: CS A(03)
Subject: IoT Programming (CSPC 209)
1
Abstract
This project implements a smart lock system based on facial detection, recognition,
and liveness detection models to provide a modern security solution. The system
integrates two models: one for face detection and recognition, and another for
liveness detection to prevent spoofing. The system captures live input from a
users. If a match is found, the system proceeds to verify the liveness of the detected
unauthorized or fake face is detected, a snapshot is taken, and the user is alerted via
a Telegram bot, with the option to remotely unlock the door through Telegram.
For facial recognition, the face_recognition library is used, which is based on dlib
library and employs a CNN model for accurate recognition. The system also improves
real or fake. OpenCV is employed for handling live video processing, NumPy for
numerical operations, and TeleBot for Telegram bot communication. The deep
learning models are supported by TensorFlow and Keras, providing the necessary
2
1. Introduction
In the modern world, where facial recognition systems are used in critical applications
for user access control and authentication, there is an increasing demand for an
enhanced security system based on facial recognition that is reliable. Traditional
security methods like PINs or passwords are vulnerable to hacking or theft, and even
conventional facial recognition systems can be fooled by spoofing attempts, such as
using photographs or videos of authorized users. Studies suggest that top-tier facial
recognition algorithms can have error rates of around 5% when subjected to spoofing
attacks, underscoring the vulnerabilities these systems face, especially when
unauthorized individuals attempt to use fake images or videos for access.
This project addresses these challenges by implementing a smart lock system that
integrates facial detection, recognition, and liveness detection to provide a modern
security solution that is both reliable and convenient. The system utilizes two models:
a face_recognition model based on dlib for face detection and recognition, and a
YOLOv8X-cls-based liveness detection model. It captures input from a live camera
feed, detects the face, and matches it against a pre-registered database of authorized
users. If the face matches an authorized user, the system performs liveness detection
to ensure the face is real, preventing spoofing attempts. If a fake or unauthorized user
is detected, the system captures an image and sends it to the user via Telegram,
allowing the user to decide whether to lock or unlock the door remotely via the
Telegram bot.
The system incorporates several libraries and frameworks: OpenCV for live camera
feed and image processing, NumPy for handling numeric operations, and
face_recognition for implementing face detection and recognition using the dlib
CNN model. Multiple images of each user are used to improve recognition accuracy.
TeleBot facilitates communication with users for sending alerts, images, and enabling
remote door unlock commands. The deep learning models are supported by
TensorFlow and Keras, powering both facial recognition and liveness detection
models.
Unique Functionality of the Project:
1. Combined face detection and liveness detection using two models.
2. Real-time alerts based on live camera feeds.
3. Remote access control through Telegram.
4. Multiple image training for improved recognition accuracy.
5. Use of YOLOv8X-cls for advanced liveness detection.
3
6. Robust anti-spoofing mechanism based on deep learning.
4
A. Author Link of Year Data Features Model/ Results Drawback
published Sensors/ in their
work Used Project
(Research
Paper/
Patent)
Muhammad Face 2020 Hierarchica Raspberry Resilience Limited
Waseem Recognitio l Network Pi to Dataset
n for Smart (HN) Random
Sundar Ali Door Lock Framework Pre- Faces No
Khowaja System trained Liveness
using Architectu Detection
Farhan Bashir Hierarchica res &
l Network | FaceNet
IEEE
Conference
Publication
| IEEE
Xplore
Zhiguo Zhu Application 2020 Hybrid OpenCV Cost- Lack of
of attitude Approach - effectiven Specificity
Yao Cheng tracking Retro and Efficient ess
algorithm Modern Attitude Absence of
for face Lock Tracking Hybrid Experiment
recognition System: Algorith Design al Data
based on m
OpenCV in (EATA)
the
intelligent
door lock -
ScienceDir
ect
Phawinee, Face 2019 Control Raspberry Real- Vulnerabilit
Suphawimon recognition Sensing Pi Time y to
in an Module: Image Spoofing
Cai, JinFangb intelligent Camera Streamin
door lock Mobile Sensor g: Complexity
Guo, ZheYu with Applicatio of Setup
5
ResNet n CNN and
model Maintenanc
based on e
Drawbacks in these existing projects
1. Vulnerability to Spoofing: Without robust liveness detection, the system can be easily
fooled by images or videos of authorized users. This oversight leaves it open to spoofing
attacks, potentially allowing unauthorized access.
2. Complex Setup and Maintenance: Implementing the system requires technical expertise,
including software installation and hardware configuration. This complexity may pose
challenges for users without a technical background.
3. Dataset Limitations: The system's accuracy depends on the quality and diversity of the
training dataset. A limited or biased dataset can lead to lower recognition rates for users
whose features differ from those in the dataset.
3. Project
This project is based on creating a smart lock system to establish a reliable
security system that can be used in different fields by integrating face detection,
face recognition, and liveness detection. The system uses deep learning models
and combines them with real-time monitoring using the camera. The project
overcomes the problems faced with the current security system, such as
spoofing attacks.
Key Features:
1. Face Detection and Recognition: The system captures live video input
using a camera and processes the frames to detect faces. Once a face is
detected, the system matches it against authorized user images, which
have been pre-stored as embeddings. This step utilizes the
face_recognition library, which is based on dlib and employs a
convolutional neural network (CNN) model for accurate face detection
and recognition.
6
3. Alert and Remote Control via Telegram: When an unauthorized or
spoofed face is detected, the system takes a snapshot and sends it to the
user via Telegram using the TeleBot library. The user can then remotely
unlock or keep the door locked using the bot interface.
Technical Components:
Workflow / Architecture:
1. Camera Activation: The system begins by capturing live video input
through a connected camera, providing a continuous stream of footage for
analysis.
2. Face Detection: Utilizing OpenCV, the system detects and locates faces
within the video feed, identifying regions of interest where faces are
present.
7
3. Face Recognition: The detected face is extracted, and the
face_recognition library compares it with stored images of authorized
users, using multiple images per user to enhance recognition accuracy.
4. Authorization Check:
o If the face matches an authorized user:
Liveness Detection: The system performs liveness detection
using a YOLOv8 model trained on a custom dataset to verify
the face is live, analyzing dynamic traits such as blinking or
head movement.
Unlock Door: If the face is confirmed as live, the door is
unlocked for access.
o If the face is not recognized as authorized or is deemed a spoof:
Capture Snapshot: The system takes a snapshot of the
detected face for documentation.
Notification: A notification, along with the snapshot, is sent
to the user via a Telegram bot.
User Decision: The user can then decide to lock or unlock
the door remotely through the Telegram interface.
8
89=
3.2 Working Example (Add Real time Photographs of the working project)
9
4. Experimental Setup
10
4.1 Libraries and Frameworks:
OpenCV: Used for real-time computer vision tasks, including face
detection and image processing.
face_recognition: A high-level library for face recognition based on dlib,
utilizing a CNN model for accurate face detection and recognition.
YOLOv8: Employed for the liveness detection model, trained on a
custom dataset to distinguish live faces from spoofed images.
NumPy: Used for numerical operations and efficiently handling arrays,
especially in image processing tasks.
TensorFlow and Keras: Utilized for building and training deep learning
models, including the liveness detection model based on YOLO
architecture.
TeleBot: A library for integrating Telegram messaging functionality,
enabling notifications and remote control commands.
Models:
1. Face Recognition Model: The face_recognition library employs a CNN-
based architecture for efficient face detection and recognition, ensuring
high accuracy through the use of multiple images per user.
2. Liveness Detection Model: A YOLOv8 model trained on a custom
dataset to analyze dynamic features and confirm the authenticity of the
detected face, preventing spoofing attempts.
Integration:
The system integrates the above components, allowing for real-time video
capture, processing, and interaction through a Telegram bot. The
workflow facilitates face detection, recognition, liveness verification, and
user notifications, creating a comprehensive smart lock solution.
11
Fig a. Confusion Matrix for anti spoofing model
12
5. Comparison with the Existing Work
Future Work:
13
2. Database Integration: Adding a database for managing user data and
access logs would facilitate better security management and adaptability
over time.
References:
5.Polash Kumar Das; Bin Hu; Chang Liu; Kaixin Cui; Prabhat
Ranjan; Gang Xiong(2019)
https://ieeexplore.ieee.org/abstract/document/8955089
14
1.
15