Final Project Report Smart Home
Final Project Report Smart Home
A PROJECT PHASE-II
REPORT ON
“APPROACH FOR LOAD MONITORING AND
ACTIVITY RECOGNITION IN SMART HOMES”
Submitted in partial fulfillment of the requirements for the VIII Semester
Bachelor of Engineering
In
ARAVIND S (1VK19CS010)
MATHISHA A (1VK19CS023)
Under the Guidance of
Prof. Soumya George
Assistant professor, Dept. of CSE,
VKIT, Bengaluru
CERTIFICATE
This is to certify that the Project Work Phase II entitled “Approach for Load Monitoring
and Activity Recognition in Smart Homes” carried out by Akanksha N Raj bearing the USN:
(1VK19CS004), Aravind S bearing the USN: (1VK19CS010) , Darshan C Gowda bearing the
USN: (1VK19CS013), Mathisha A bearing the USN: (1VK19CS023) the bonafide student of
Vivekananda Institute of Technology, Bengaluru in partial fulfillment of VIII semester Project
Work Phase II (18CSP83) for the award of Bachelor of Engineering in Computer Science and
Engineering of the Visveswaraya Technological University, Belagavi during the year 2022-23.
The Project Work Phase II report has been approved as it satisfies the academic requirements in
respect of project work prescribed for the said degree.
External Viva-voice:
1]
2]
ABSTRACT
A smart home is a home automation system that integrates various technologies to create
a more efficient, comfortable, and secure living environment. In this project, we propose
the use of Raspberry Pi to build a smart home.
This concept can be taken around in any field out there to make life of humans easier and
smarter. Same can be done in our security system of houses where it will become easy to
handle the safety with easy to access Smart Door Locks. This project sheds light on
building a door locking system that can recognize the face of the owner of the house and
family members who will have access to pass through the door in the house. It can be
done by using face recognition algorithms which are gaining much importance in this era
of Artificial Intelligence. This article presents the design and end-to-end implementation
of a voice-activated smart home controller for intelligent devices, deployed in a real
environment and validated in an experimental setup of motorized blinds.
i
ACKNOWLEDGEMENT
The completion of any work is a showcase of constant dedication and co-operation of many
people who lent their hands which went seen or unseen.
We whole heartedly express our sincere thanks to our honorable Principal Dr. D V
Chandrashekar, Vivekananda Institute of Technology for the encouragement and support.
We express our heart full gratitude to Dr. Vidya A, Professor and Head, Department of
Computer science & Engineering, VKIT, for giving us guidance, valuable advice and support
for making this a great success.
We extend my gratitude to our guide Prof. Soumya George, Asst. Professor, Department of
Computer Science & Engineering, VKIT for her valuable advice, support and constructive
suggestions.
We would like to express our gratitude to our beloved project coordinator Prof. Trupti G,
Asst. Professor, Dept. of Computer Science and Engineering for her valuable guidance
and support.
We also thank to all our professors and the entire department of Computer Science &
Engineering for their co-operation and suggestions.
The report would be incomplete if we do not thank our parents and friends for their continuous
encouragement and moral support.
ii
TABLE OF CONTENTS
Abstract i
Acknowledgement ii
iii
LIST OF FIGURES
iv
APPROACH FOR LOAD MONITORING AND ACTIVITY RECOGNITION IN SMART HOMES
CHAPTER 1
INTRODUCTION
In the present scenario the crimes are increasing exponentially, arising a need of
security. Security can also be described as a condition so that one can develop
and progress freely and with a faith that no harm may be done. Hence we are
introducing any automatic door lock security system and home automation for the
security purpose. Camera is now enormously being used and with the
development of its content that is used in various applications. One of such is
automatic door lock security system using camera. “To implement a system that
exerts better surveillance and security by inculcating alerting system and face
recognition with appropriate notification sent to the owner using IoT.”
The project's scope is to develop an approach for load monitoring and activity
recognition in smart homes using Raspberry Pi. The project aims to enable
homeowners to control various aspects of their home, such as lighting, and
security devices, remotely using a mobile or web-based interface.
The project will involve designing and building hardware modules, including
sensors and actuators, to interact with the physical components of the home. The
project's scope is limited to a single home or apartment and does not involve
controlling the energy supply to the home or integrating with other smart home
systems. The primary focus of the project is to provide homeowners with a
convenient and efficient way to control and monitor their home, enhance their
security, and reduce their energy consumption. The project will also aim to be
scalable and adaptable, allowing homeowners to expand the system's capabilities
as needed.
1.4 OBJECTIVES
• To design and implement face authenticated real time security system.
• The captured image is compared and verified with the database, if found
matching then the access to locking device is allowed.
Chapter 2: This chapter describes the literature survey and the background
preparation done to understand more about this project.
Chapter 4: This chapter describe the existing system and its limitations and
here it tries to improve the existing system. It explains the proposed system
and its architecture.
Finally, this project explains the problem in hand for the system that is
being designed.
LITERATURE SURVEY
Literature Survey is the most important step in the software development
process. Before developing the tool it is necessary to determine the time factor,
economy and company strength. Once these things are satisfied, then next step is
to determine which operating system and language can be used for developing the
tool. Once the programmer start building the tool the programmers need lot of
external support. This support can be obtained from senior programmers, from
book or from websites.
Prashanth, et al., [1] They have proposed in recent years, with the demand for
better security, computers have played a large role. Due to their precision, large
memory banks and high computing power, considerable development has been
made in the area of face recognition. Computers now surpass humans in many
face recognition tasks. A human being can remember limited number of faces.
But a computer doesn't have any limits and can hence be used where large
databases of facial records are needed. Such a facial recognition system has many
potential applications including crowd and airport surveillance, private security
and improved human-computer interaction. Such a system is perfectly suited to
fix security issues and offer flexibility to smart house control. This project is
aimed to be a complete system for face recognition: easy to build, cheap cost and
effective. Main purpose is to be set as an alert for home visitors and provide
information about the visitors in a dynamic website and phone application. It can
also be used in other fields like industries, offices and even airports for
identifying wanted people. Among the other bio-metric techniques, face
recognition method offers one great advantage which is user friendliness.
Jiang, et al., [2] They presents an Internet of Things (IoT) based face detection
system. The main objective is to build a fully automated human face detection
system for images with complex backgrounds. This system can capture images
and run face detection algorithms on each IoT smart camera device, which is
required to write face detection program code. The raspberry Pi 3 board is used as
the gateway of IoT smart camera device with a camera on it. The final detected
faces will be sent to remote devices, e.g. cell phones and laptops. Two main steps
are used to detect faces: 1) cascade classifiers for face detection first and then 2)
spatial correlation for detection results improvement. The experimental results
showed that our smart camera system gives comparable face detection
performance. The average precision of 85.7%. Several promising directions for
future research based on IoT are also concluded.
Prayag, et al., [3] In today's world, home security is of utmost priority. IOT
(Internet of Things) being an emerging technology can be used along with facial
recognition to make our task of providing smart home security easier, simpler and
foolproof. The idea behind this paper is to develop an efficient face recognition
system. The system uses Local Binary Pattern Histograms to recognize the person
from the local database created for the family members of the house. Security,
monitoring and control to automation in real time are the key components of this
system. The hardware required to implement this system are Raspberry Pi 3
microprocessor, external web camera, speaker and stepper motor.
Suraj, et al., [4] The Internet of Things (IoT) has made it possible to set up a
smart home security through which you can decide who can enter your home
using your smartphone and web application. It's also made it simple and
relatively affordable to monitor your home anytime and anywhere. the key issue
in a traditional home security system is, it is easily breakable and quite outdated.
To tackle this problem, we propose a smart home security system, which is IoT as
well as face recognition enabled. In this system, the web camera is used which is
connected to the raspberry pi accompanied by sensors such as Passive Infrared
(Pir) and Ultrasonic sensor. On motion detection camera captures an image of the
person in front of the door then real-time face recognition is done using local
binary pattern (LBP). If person's image matches with one of the home members
then the door will unlock, else doorbell will ring. if an intruder tries to break door
then an alarm will be raised at the same time SMS and Email containing image of
the intruder will be sent to the homeowner. Face recognition works well in multi-
face recognition and stranger identification, which meet the requirement of home
security. This system is battery powered in case of power failure. Furthermore,
the house owner can keep track of activity happening in the house using android
and web application connected to the raspberry pi using the internet. Using
Android application or web application owner can also add new person's faces
into the databases e.g., guests.
Nashwan, et al., [5] A real-time recognition system is proposed that will equip
for handling images very quickly. The main objective of this is to protect home,
office by recognizing people. For this purpose, the PIR sensor is used to detect
movement in the specific area. Afterwards, the Raspberry Pi will capture the
images. Then, the face will be detected and recognized in the captured image.
Finally, the images and notifications will be sent to a smartphone based IoT by
using Telegram application. The proposed systems are real-time, fast and has low
computational cost. The experimental results show that the proposed face
recognition system can be used in a real time system.
Narumol, et al., [6] They have proposed the image enhancement method using
the data matching with histogram shaping technique. The experiments were
conducted using images with 1,280 × 720 pixel collected from CCTV
surveillance video system. Type of images (.jpg) is in RGB24 form and first
frame's surveillance video file. The results showed that the proposed method
using images enhancement technique can improve the quality of images from
surveillance video system using the proposed image enhancement based on
histogram shaping technique.
Amritha, et al., [7] It is important to own a reliable security system that can
secure our assets as well as to protect our privacy. The traditional security system
needs an individual to use a key, identification (ID) card or password to access an
area such as home and workplace. However, the present security system has
many weaknesses wherever it is simply cast and taken. Most doors are controlled
by persons with the employment of keys, security cards, countersign or pattern to
open the door. The aim is to assist users for improvement of the door security of
sensitive locations by using face detection and recognition. The proposed system
mainly consists of subsystems namely image capture, face detection and
recognition, email notification and automatic door access management. Face
Recognition supported OpenCV is brought up because it uses Eigen faces and
reduces the scale of face images without losing vital features, facial images for
many persons can be stored in the database. The door lock can also be accessed
remotely from any part of the world by using Telegram android application. The
captured image from pi camera will be sent to the authorized person through
email for safety purposes.
Mahesh, et al., [8] They have proposed designing and development of anti-theft
as well as driver surveillance embedded system that uses biometric authentication
to access the vehicle. This system contains camera which take the image of a
person trying to get access of vehicle and compare with authorized person's
image and then allowing or denying access. In The case of denial of vehicle
access or even if there is an accident occurs, camera will capture the images and
email it to the owner or authorizer. This will help to catch thieves, also allows the
surveillance of driver and also the inner part of vehicle. The recent work on
proposed embedded system is written. The system is designed and developed
using raspberry pi, high resolution camera, vibration sensor and open source
software.
Shreyak, et al., [9] The management of the attendance can be a great burden on
the teachers if it is done by hand. To resolve this problem, smart and auto
attendance management system is being utilized. But authentication is an
important issue in this system. The smart attendance system is generally executed
with the help of biometrics. Face recognition is one of the biometric methods to
improve this system. Being a prime feature of biometric verification, facial
recognition is being used enormously in several such applications, like video
monitoring and CCTV footage system, an interaction between computer &
humans and access systems present indoors and network security. By utilizing
this framework, the problem of proxies and students being marked present even
though they are not physically present can easily be solved. The main
implementation steps used in this type of system are face detection and
recognizing the detected face. This proposes a model for implementing an
Meena, et al., [12] They have focused on home automation using IoT. The IoT
devices controls and monitors the electronic, electrical and the mechanical
systems used in various types of buildings. The devices connected to the cloud
server are controlled by a single admin which facilitate a number of users to
which a number of sensor and control nodes are connected. The admin can access
and control all the nodes connected to each user but a single user can control only
the nodes to which the user itself is connected. This whole system using Internet
of Things (iot) will allow mobile devices and computers to remotely control all
the functions and features of home appliances from anywhere around the world
using the internet connection. The system designed is economical and can be
expanded as it allows connection and controlling of a number of different
devices. Most of the electronic devices are manually monitored on regular basis
to ensure the optimal operation. To install new application specific devices not
only increases the cost but also replaces the old device.
Karma, et al., [13] They have presented a dual lock system using radio-frequency
identification (RFID) and fingerprint recognition. It is a secure and reliable
locking system which can be implemented in home, offices, school and in any
kind of organization. Even if the users lost the RFID card, they can unlatch the
lock with their fingerprints. Only the registered users are able to access using their
fingerprints and the RFID tags. If any unauthorized persons try to have an access,
first of all short message service (SMS) will send a text message to an owner
using global system for mobile communications (GSM), and at the same time a
TTL camera will take a snap of that person and store it in a SD card for reference
of the owner. The core of the system is the Arduino Mega 2560 which is
interfaced with a fingerprint scanner module, a RFID card reader module, the TTL
camera, an SD card module, a GSM shield, a liquid crystal display (LCD) and an
electric door strike.
devices. The selected platform is very flexible and user-friendly. The sensing of
different variables inside the house is conducted using the NodeMCU-ESP8266
microcontroller board, which allows real time data sensing, processing and
uploading/downloading to/from the EmonCMS cloud server.
Muhammad, et al., [16] They have proposed the IoT based system the user is
transmitting his confidential data over the network which may contain passwords
and other information, which are as crucial as the secrets or valuables behind the
door. This crypto Lock not only protects our valuables behind the door but also it
protects our data which is being transmitted over the network. It gives easy
remote access, controls unauthorized access and gives a complete sense of
security.
K. Lova, et al., [18] They describes the overall notion of the IOT based sensing
systems and monitoring systems for implementing an automated home. The
proposed prototype uses Node MCU board with internet being remotely
controlled by Android OS smart phone. Node MCU is the heart of this system
and it can perform as a micro web server and it acts as an interface for the wide
range of hardware modules. To control lights, fans and other home appliances
which are connected to the relay system, the system offers switching
functionalities. It is also used for environmental monitoring by sensing and
analyzing data about temperature and humidity. Another notifying feature in this
system designed is the intrusion detection which is offered by this system using
motion sensor. All these activities are controlled by using Android mobile app-
Blynk.
Nikolay, et al., [19] They have introduced one home automation solution,
describing a combination of the chosen hardware components and a possible
software solution. A major hardware element in the project presented is a
Raspberry Pi microcomputer. Which is connected to sensors for data collection.
The microcomputer runs a described software system for organizing and
processing this data, configures different home authentication.
A. Z. M, et al., [23] In this IoT based home automation system through which
home security, room air quality check, and emergency assistance can be obtained.
This system can automatically provide home safety, but the user can also control
the system manually if desired. The system uses the NodeMCU module as the
mainboard and has a mobile application for remote monitoring. In addition to air
quality detection, the system can detect CFCs used in the air conditioning system
to avoid accidents. If any unwanted incident occurs, the system will immediately
turn off the home's main power connection and send the house's status in the form
of a notification to the user's mobile app.
Harsh, et al., [24] There aim is to develop home automation system based on
IOT using Wi-Fi based microcontroller. As scope of technology is widening
every day, they are making our tech advance in mobile, robotics, Machine
Learning, then why an exception for our home. Today's houses are gradually
transferring from ordinary/human's input- based appliances to smart/IOT enabled
appliances to be controlled remotely. At Present, existing home automation
systems use technology that is limited to only that device. So, in a nutshell, they
are making there devices IOT enabled not our homes. As far as this is concerned,
NodeMCU (ESP8266) microcontroller along with Relays is used to control
electrical switches remotely from the server which is built on Node.js. User can
control switches using a Web Application after authenticating.
Waheb, et al., [25] They have proposed a low-cost Wi-Fi based automation
system for Smart Home (SH) in order to monitor and control home appliances
remotely using Android- based application. An Arduino Mega microcontroller
provided with Wi-Fi module is utilized to build the automation system. In
addition, several sensors are used to monitor the temperature, humidity and
motion in home. A relay board is exploited to connect the HAS with home under
controlled appliances. The proposed automation system, can easily and efficiently
control the electrical appliances via Wi-Fi and Virtuino mobile application.
System requirements are the prerequisites that are often used as a guideline as
opposed to an absolute rule. Requirements can be classified as functional
requirements, non-functional requirements, software requirements and hardware
requirements. The project will also aim to be scalable and adaptable, allowing
homeowners to expand the system's capabilities as needed. “To implement a
system that exerts better surveillance and security by inculcating alerting system
and face recognition with appropriate notification sent to the owner using IoT.”
• Pi Camera
• Fire sensor
• Gas sensor
• IR sensor
• Relay
• DC Motor
• Power supply
• Buzzer
• Water Pump
• H-Bridge
The 5MP Raspberry Pi 3 Model B Camera Module Rev 1.3 with Cable
equips flexible cable for attaching with Raspberry Pi 3 Model B. The 5MP
camera module is perfect for small Raspberry Pi projects.
The high-definition 5MP camera delivers outstanding photos but can also shoot
video, ideal for drones or a CCTV project. The lightweight camera board allows
for it is useful in more practical roles, such as a hidden camera, even a camera for
a Pi-phone. This Raspberry Pi Camera Module is a custom designed add-on for
Raspberry Pi. It attaches to Raspberry Pi by way of one of the two small sockets
on the board upper surface. This interface uses the dedicated CSI interface,
therefore it is designed especially for interfacing to cameras. The CSI bus is
capable of extremely high data rates, and it exclusively carries pixel data.
FIRE SENSOR
A fire-sensor is one kind of detector which is mainly designed for
detecting as well as responding to the occurrence of a fire or flame. This sensor
module is used in fire or flame alarms.
GAS SENSOR
• The sensing circuit consists of an MQ5 sensor which senses LPG leakage of
the order 200ppm to 1000ppm (capable of causing explosions) and is
connected to the microcontroller to be supplied with 5V DC.
IR SENSOR
More advanced security systems include passive infrared (PIR) motion
detectors. The "motion sensing" feature on most lights (and security systems) is a
passive system that detects infrared energy. These sensors are therefore known as
PIR (passive infrared) detectors or pyro electric sensors. These sensors "see" the
infrared energy emitted by an intruder's body heat. When an intruder walks into
the field of view of the detector, the sensor detects a sharp increase in infrared
energy.
DC Motor
BUZZER
➢ Raspbian OS
➢ Open CV
➢ Python Language
RASPBIAN OS
Although the Raspberry Pi’s operating system is closer to the Mac than
Windows, it’s the latter that the desktop most closely resembles It might seem a
little alien at first glance, but using Raspbian is hardly any different to using
Windows (barring Windows 8 of course). There’s a menu bar, a web browser, a
file manager and no shortage of desktop shortcuts of pre-installed applications.
Raspbian is an unofficial port of Debian Wheezy armhf with compilation settings
adjusted to produce optimized "hard float" code that will run on the Raspberry Pi.
This provides significantly faster performance for applications that make heavy
use of floating point arithmetic operations. All other applications will also gain
some performance through the use of advanced instructions of the ARMv6 CPU
in Raspberry Pi. Although Raspbian is primarily the efforts of Mike Thompson
(MP Thompson) and Peter Green (plug wash), it has also benefited greatly from
the enthusiastic support of Raspberry Pi community members who wish to get the
maximum performance from their device.
OpenCV
OpenCV is a library of programming functions mainly aimed at real-time
computer vision. It is developed by Intel research center and subsequently
supported by1Willow Garage and now maintained by itseez. It is written in C++
and its primary interface is also in C++. Its binding is in Python, Java, Matlab.
OpenCV runs on a variety of platform i.e. Windows, Linux, MacOS, OpenBSD in
desktop and Android, IOS and Blackberry in mobile. It is used in diverse purpose
for facial recognition, gesture recognition, object identification, mobile robotics,
segmentation etc. It is a combination of OpenCV C++ API and Python language.
In our project we are using OpenCV version 2 OpenCV is used to gesture control
to open a camera and capture the image. It is also used in the image to text and
voice conversion technique.
It has a modular structure, which means that the package includes several shared
or static libraries. We are using image processing module that includes linear and
non-linear image filtering, geometrical image transformations (resize, affine and
perspective warping, and generic table-based remapping), color space conversion,
histograms, and so on. Our project includes libraries such as Viola-Jones or Haar
classifier, LBPH (Lower Binary Pattern histogram) face recognizer, Histogram of
oriented gradients (HOG).
Python Introduction
Python is a general-purpose interpreted, interactive, object-oriented, and high-
level programming language. It was created by Guido van Rossum during 1985-
1990. Like Perl, Python source code is also available under the GNU General
Public License (GPL). This tutorial gives enough understanding on Python
• People usually are outside the home for many reasons like travelling and
they want to control some devices from a far distance.
• For example they want to turn off the light and operate some electronic
devices at room and get feedback about the temperature and total control on
their home.
• No automatic motion detected device control.
• There is no environmental condition based device controlling and
monitoring.
• No Device status update to the family members.
CHAPTER 5
SYSTEM DESIGN
Until the 1990s systems design had crucial and respected role in the data
processing industry. In the 1990s standardization of hardware and software resulted
in the ability to build modular systems. The increasing importance of software
running on generic platforms has enhanced the discipline of software engineering.
Object-oriented analysis and design methods are becoming the most widely used
methods for computer systems design. The UML has become the standard language
in object-oriented analysis and design. It is widely used for modelling software
systems and is increasingly used for high designing non-software systems and
organizations.
The design will contain the specification of all the modules, their
interaction with other modules and the desired output from each module. The
output of the design process is a description of the software architecture.
The figure 4.1 shows a general block diagram describing the activities
performedby this project.
5.2 IMPLEMENTATION
This phase of the system is conducted with the idea that whatever is designed
should be implemented; keeping in mind that it fulfills user requirements, objective
and scope of the system. The implementation phase produces the solution to the
user problem.
In this system we have proposed webcam, sensors and Raspberry Pi board and the
cubeactivator along with its driver circulatory are connected together.
Camera:
Raspberry PI :
MODULES DESCRIPTION
The proposed system contains 4 different modules:
• Face Detection
• Face Recognition
• OTP
• Door Lock.
The total system is divided into 3 modules- Database creation, Training the dataset,
Testing, sending alert messages as an extension.
1. Database Creation
a) Initialize the camera and set an alert message to grab the attention of the
students.
c) convert the image into gray scale, detect the face and
2. Training
a) Initialize LBPH face recognizer.
b) Get faces and Id’s from database folder to train the LBPH face recognizer.
3. Testing
Load Haar classifier, LBPH face recognizer and trained data from xml or yml
file.
This system uses Viola Jones algorithm for face detection which uses modified
Haar Cascades for detection. Raspberry Pi is the main component in the project. We
will beusing USB webcam to capture photos. We can access Raspberry Pi’s console
either by using SSH in laptop or by using Keyboard and mouse with the display
device like TV connected to Pi. Firstly, the algorithm needs a lot of positive images
and negative images to train the Haar cascades classifier. Positive images are images
with clear faceswhere negative images are those without any faces.
i. Haar Cascades:
Each feature is represented as a single value obtained from the difference of the
sums of pixels in white rectangle from the sum of all pixels in the black rectangle.
All different possible sizes and locations of classifier is used for calculating of
plenty of features. As the number of classifiers increase the arithmetic computations
seems to take a long time. To avoid this, we use the concept of Integral Image. In
Image Processing Integral image is a data structure which is summed area table and
algorithm for quickly and efficiently generating sum of values in a rectangular grid
subset. Integral image is derived by using the formula.
Integral Image: To solve the complexity of the number of classifiers applied for
calculation we use Ad boost machine learning algorithm, which is inbuilt in
OpenCV library that is cascade classifier, to eliminate the redundancy of the
classifiers. Any classifier which has a probability of 50% of more in detection is
treated as weak classifier. The Sum of all weak classifier gives a strong classifier
which makes the decision about detection. Although it is very vague to classify with
one strong classifier we use the cascade of classifiers. Classification takes place in
stages, if the selected region fails in the first stage, we discard it. We don’t use the
classifiers on that region which is discarded. The region which passes all the stages
i.e. all strong classifiers is treated as the detected face. Detected Faces are passed to
the Face recognition phase.
In this phase we use Local Binary Patterns algorithm for face recognition. Local
binary patterns are simple at the same time very efficient texture operator which
assigns the pixels of the image by comparing with the adjacent pixels as threshold
and which results in a binary result. The detected integral image is subjected to this
Local binary pattern which results in decimals are represented as histogram for
every integral image. Face recognition is extremely vulnerable to the environment
changes like brightness, facial expressions and position. Face pre-processing is the
module which reduces the problems that makes the picture unclear to recognize the
face such as less brightness and contrast problems and noise in the image and make
sure the facial features always be in a constant position. times, firstly for the whole
face and the other two for side faces.
2. Discretize each cell into angular bins according to the gradient orientation.
3. Each cell's pixel contributes weighted gradient to its corresponding angular bin.
4. Groups of adjacent cells are considered as spatial regions called blocks. The
grouping of cells into a block is the basis for grouping and normalization of
histograms.
5. Normalized group of histograms represents the block histogram. The set of these
blockhistograms represent the descriptor.
STEP - 3: OTP
If Face Didn’t Match with Database, Face Intimation will be Sent to Owner
of theFace with SMS or E mail alert.
PYTHON CODE
Face Recognition With Raspberry Pi and OpenCV
from imutils.video import VideoStream
from imutils.video import FPS
import face_recognition
import imutils
import pickle
import time
import cv2
currentname = "unknown"
train_model.py
encodingsP = "encodings.pickle"
print("[INFO] loading encodings + face detector...")
data = pickle.loads(open(encodingsP, "rb").read())
vs = VideoStream(usePiCamera=True).start()
time.sleep(2.0)
fps = FPS().start()
while True:
frame = vs.read()
frame = imutils.resize(frame, width=500)
boxes = face_recognition.face_locations(frame)
encodings = face_recognition.face_encodings(frame, boxes)
names = []
for encoding in encodings:
matches = face_recognition.compare_faces(data["encodings"],
encoding)
name = "Unknown" #if face is not recognized, then print Unknown
if True in matches:
matchedIdxs = [i for (i, b) in enumerate(matches) if b]
counts = {}
for i in matchedIdxs:
name = data["names"][i]
counts[name] = counts.get(name, 0) + 1
name = max(counts, key=counts.get)
if currentname != name:
currentname = name
print(currenttname)
names.append(name)
for ((top, right, bottom, left), name) in zip(boxes, names):
cv2.rectangle(frame, (left, top), (right, bottom),
(0, 255, 225), 2)
y = top - 15 if top - 15 > 15 else top + 15
cv2.putText(frame, name, (left, y), cv2.FONT_HERSHEY_SIMPLEX,
.8, (0, 255, 255), 2)
cv2.imshow("Facial Recognition is Running", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
fps.update()
fps.stop()
print("[INFO] elasped time: {:.2f}".format(fps.elapsed()))
print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))
cv2.destroyAllWindows()
vs.stop()
def setup():
ADC.setup(0x48)
LCD.init(0x27, 1)
GPIO.setup(fire, GPIO.IN)
GPIO.setup(gas, GPIO.IN)
GPIO.setup(buzzer, GPIO.OUT)
global Buzz
Buzz = GPIO.PWM(buzzer, 440)
def loop():
while True:
firetmp = ADC.read(0)
gaslvl = ADC.read(1)
lvls = "Gas: " +str(gaslvl)+", Fire: "+str(firetmp)
digFire = GPIO.input(fire)
digGas = GPIO.input(gas)
if digFire == 0 or digGas == 0:
warning = 'DOH! Something is not okay!!\nLevels: '+lvls
print(warning)
time_end = time.time() + 30
while time.time() < time_end:
clearLCD()
LCD.write(0, 0, 'DOH! Something ')
LCD.write(0, 1, 'is not Okay! ')
time.sleep(3)
clearLCD()
LCD.write(0, 0, '*****Danger*****')
LCD.write(0, 1, 'Fire:'+str(firetmp)+' Gas:'+str(gaslvl))
time.sleep(3)
else:
print (lvls) # display fire and gas levels in command line
LCD.write(0, 0, 'Gas: '+str(gaslvl))
LCD.write(0, 1, 'Fire: '+str(firetmp))
time.sleep(3)
LCD.write(0, 0, 'Everything Is Ok')
LCD.write(0, 1, '**')
Buzz.start(50)
time.sleep(2)
Buzz.stop()
time.sleep(1)
clearLCD()
def clearLCD():
LCD.write(0, 0, ' ')
LCD.write(0, 1, ' ')
time.sleep(.1)
if __name__ == '__main__':
try:
setup()
loop()
except KeyboardInterrupt:
pass
TESTING
Testing is finding out how well something works. In terms of human
beings, testing tells what level of knowledge or skill has been acquired. In computer
hardware and software development, testing is used at key checkpoints in the
overall process to determine whether objectives are being met. For example, in
software development, product objectives are sometimes tested by product user
representatives. When the design is complete, coding follows and the finished code
is then tested at the unit or module level by each programmer, at the component
level by the group of programmers involved and at the system level when all
components are combined together.
There are several types of testing and few of them are listed below:
• Unit Testing
• Integration Testing
• Functional Testing
• Acceptance Testing
Unit Testing
Unit testing is a level of software testing where individual units/
components of software are tested. The purpose is to validate that each unit of the
software performs as designed. A unit is the smallest testable part of any software.
It usually has one or a few inputs and usually a single output. In procedural
programming, a unit may be an individual program, function, procedure, etc. In
object-oriented programming, the smallest unit is a method, which may belong to
a base/ super class, abstract class or derived/ child class.The main device we have
used is Raspberry pi which is used to build and run the respective functions. We
are using Raspberry pi because of the compatibility to the ARM processor. The
below image is the testing of the components with Raspberry pi. We get the
indication of working through.
Integration Testing
Integration testing (sometimes called integration and testing, abbreviated
I&T) is the phase in software testing in which individual software modules are
combined and tested as a group. Integration testing is conducted to evaluate
the compliance of a system or component with specified functional
requirements. It occurs after unit testing and before validation testing.
Integration testing takes as its input modules that have been unit tested, groups
them in larger aggregates, applies tests defined in an integration test plan to those
aggregates, and delivers as its output the integrated system ready for system
testing. In proposed system we are integrating camera, headphones and SD card
with power supply. Some of the USB ports are used if necessary.
Functional Testing
A functional test is a form of integration test in which the application is
run "literally". You would have to make sure that an email was actually sent in a
functional test, because it tests your code end to end. It is often considered best
practice to write each type of tests for any given codebase. Unit testing often
provides the opportunity to obtain better "coverage": it's usually possible to
supply a unit under test with arguments and/or an environment which causes all of
its potential code paths to be executed. This is usually not as easy to do with a set
of integration or functional tests, but integration and functional testing provides a
measure of assurance that your "units" work together, as they will be expected to
when your application is run in production.Functional tests are typically written
using the WebTest package, which provides APIs for invoking HTTP(S) requests
to your application. We also use py.test and pytest- cov to provide simple testing
and coverage reports.
Acceptance Testing
Acceptance Testing is often the final step before rolling out the
application. Usually the end users who will be using the applications test the
application before ‘accepting’ the application. This type of testing gives the end
users the confidence that the application being delivered to them meets their
requirements.
Test Cases
A test case is a set of conditions or variables under which a tester will
determine whether a system under test satisfies requirements or works correctly.
The process of developing test cases can also help find problems in the
requirements or design of an application.
• As far as possible, write test cases in such a way that you test only one thing
at a time.
• Do not overlap or complicate test cases. Attempt to make your test cases
‘atomic’.
• Ensure that all positive scenarios and negative scenarios are covered.
Language:
REFERENCES
[1] Prashanth Balraj Balla, K.T.Jadhao, 2018 International Conference on Smart City and
Emerging Technology (ICSCET) “IoT Based Facial Recognition Security System” 5-5 Jan
2018
[2] Jiang Lu, 2017 IEEE SmartWorld, Ubiquitous Intelligence & Computing, Advanced &
Trusted Computed, Scalable Computing & Communications, Cloud & Big Data Computing,
Internet of People and Smart City Innovation, “A smart system for face detection with spatial
correlation improvement in IoT environment”
[4] Nashwan Adnan, 2018 6th International Istanbul Smart Grids and Cities Congress and
Fair (ICSG), “A face recognition method in the Internet of Things for security applications in
smart homes and cities”
[5] Narumol Chumuang, 2018 International Conference on Digital Arts, Media and
Technology (ICDAMT), “CCTV based surveillance system for railway station security”, 11
June 2018
[6] Amritha Nag, 2018 3rd International Conference for Convergence in Technology (I2CT)
“IOT Based Door Access Control Using Face Recognition”, 12 November 2018
[7] Shreyak Sawhney, 2019 9th International Conference on Cloud Computing, Data
Science & Engineering (Confluence) “Real-Time Smart Attendance System using Face
Recognition Techniques”, 29 July 2019
[8] Sameer Alani, Sarmad Nozad Mahmood 2021 “IoT based implemented comparison
analysis of two well-known network platforms for smart home automation” IEEE Xplore: 29
July 2021
[11] Karma Tshomo, 2019 5th International Conference for Convergence in Technology
“Dual Door Lock System Using Radio-Frequency Identification and Fingerprint
Recognition”, June 06,2020
[12] Majid Al-Kuwari “Smart-home automation using IoT-based sensing and
monitoringplatform”, 07 June 2018
[13] Jinsung Byun, “An intelligent self-adjusting sensor for smart home services
based onZigBee communications”, october 9 2019
[14] Muhammad AhtshamNanjing, “IoT Based Door Lock Surveillance System Using
Cryptographic Algorithms”, May 9 2019
[15] Majid Al-Kuwari, “Smart-home automation using IoT-based sensing and monitoring
platform”, 12 April 2018
[25] Hayyan Alsibai, “IOT based facial recognition system for home security using LBPH
algorithm”, 20 September 2019
APPENDIX
SNAPSHOT
When fire is detected the buzzer will ring and alert message will go to owner.
When gas is detected the buzzer will ring and alert message will go to owner.
When person enters the home the IR Sensor will detect the movement, fan
and light will on automatically.