Professional Documents
Culture Documents
Face ATM
Face ATM
Automated Teller Machines are widely used nowadays by people. But It’s hard to
carry their ATM card everywhere, people may forget to have their ATM card or
forget their PIN number. The ATM card may get damaged and users
can have a situation where they can’t get access to their money. In our proposal,
use of biometrics for authentication instead of PIN and ATM card is encouraged.
Here, The Face ID is preferred to high priority, as the combination of these
biometrics proved to be the best among the identification and verification
techniques. The implementation of ATM machines comes with the issue of being
accessed by illegitimate users with valid authentication code. This project
provides service to the user only when the user is legitimate or the user is verified
by the legitimate user of the ATM card. The users are verified by comparing the
image taken in front of the ATM machine, to the images which are present in the
database. If the user is legitimate the new image is used to train the model for
further accuracy. This system uses openCV to process the image being obtained
and Haar Cascade Classifier to detect the faces in the image. The face recognition
is done using Local Binary Pattern.
2
Chapter 1
Introduction
2
To overcome these problems,the project ’ATM Security system based on
Face recognition, PIN and OTP’ consists of conventional features ie is
Personal Iden- tification Number (PIN) along with additional features like
face recognition and one-time password (OTP) is used. Database holds
information about a user’s ac- count details, images of his/her face and a
mobile number which will improve security to a large extent.
First, the user will come to the ATM machine and a live image is
captured through the Web Camera interfaced with System defining as the
ATM sys- tem, which is compared with the images stored in the database. If
the face is recognised, then the user is notified to type the PIN. If the PIN
matches, an OTP will be sent to the corresponding registered mobile
number. If the user correctly enters the OTP, the transaction can proceed.
Therefore, the combination of face recognition algorithm,PIN and an OTP
drastically reduces the chances of fraud. Inorder to obtain better accuracy
deep learning based linear discrimint classifica- tion method is utilized. And
excecuted the same in OS.
2
Chapter 2
Literature Survey
DC Motor is used for closing the door of ATM. Some other additional
security measures are used. This will prevent the robbery and the person
4
involving in robbery can be easily caught. Software implementation is
deployed using two software packages, first one is the Keil Vision 3.0.
Second one is the Flash magic simulator. Keil Vision Debugger accurately
simulates on-chip peripherals. This system helps in rapid reaction and
minimization of loss by detecting the ATM machine at real-time when it has
been stolen can be found through GSM technol- ogy.
In paper [4], the finger print recognition is done with curvelet transform
by finding the Euclidean distance between the two corresponding finger
codes. The test finger code is compared with the entire finger codes in the
database. If it
matches, an OTP will be send to the corresponding registered mobile
number.Preprocessing is done by using built in mathlab function imread. Histogram
equalization method
helps in improving the global contrast of an image by moving slightly the
inten- sity distribution on a histogram. This permits areas of lower local
contrast to gain a higher contrast without affecting the global contrast.
Histogram equalization fulfill this by effectively spreading out the most
frequent intensity values. The feature extraction can be done using curvelet
transform and by using FFT.
The paper [6] suggests fisher faces algorithm for face recognition.
Compared to globality based supervised dimensionality reduction methods
such as Fisher Discriminant Analysis (FDA), locality based ones including
Local Fisher Discrim- inant Analysis (LFDA) have attracted increasing
interests since they aim to pre- serve the intrinsic data structures and are
able to handle multimodally distributed data. However, both FDA and
LFDA are usually solved via a ratio trace form to approximate the trace
ratio, which is the Fisher’s original objective criterion.
6
acquired on YALE and ORL database shows that this is an efficient method.
account holder are displayed. User needs to select one of the bank accounts for the
transaction. If user wants to transfer the money or debit the money from ac- count
he will get OTP on registered mobile number. The GSM module generates OTP
for enforce authenticate transaction from the bank side.
7
Chapter 3
Design Phase
The system contains System board as the main processor. The system is
used to contain the dedicated operating system which is compatible with the
System board. The Human face is captured by the Web Camera which can
be directly interfaced with the System board. The monitor displays the mes-
sages for user interface.
8
9
3.2 System Overview
The algorithm needs a lot of positive images (images of faces) and negative
im- ages (images without faces) to train the classifier. Then it is required to
extract features from it. Features are nothing but numerical information
extracted from the images that can be used to distinguish one image from
another; for example, histogram (distribution of intensity values) is one of
the features that can be used to define several characteristics of an image
even without looking at the image, such as dark or bright image, the
intensity range of the image, contrast, and so on. Using Haar features is a
efficient method for face detection. These features are just like the
convolution kernel. The convolution can be summarized by locating a
Webxel from the image, then crop out a sub-image with the selected
Webxel as the center from the source image with the same size as the
convolution kernel. Cal- culate an element-wise product between the values
of the kernel and sub- image. Add the result of the product. Put the resultant
value into the new image at the same place where you Webcked up the
Webxel location.
Each feature is a single value obtained by subtracting the sum of the
Webxels under the white rectangle from the sum of the Webxels under the
black rectangle. Now, all possible sizes and locations of each kernel are
used to calculate plenty of features. Each feature calculation, requires to
find the sum of the Webxels under the white and black rectangles. The
concept of integral image is very useful to solve this. Integral images are
those images in which the Webxel value at any (x,y) location is the sum of
the all Webxel values present before the current Webxel.
The first feature selected seems to focus on the property that the region of
the eyes is often darker than the region of the nose and cheeks. The second
feature selected relies on the property that the eyes are darker than the
bridge of the nose.
Face Recognition
Face recognition is an easy task for humans. Face recognition based on the
geo- metric features of face is probably the most intuitive approach to face
recognition. One of the first automated face recognition systems was marker
points (position of eyes, ears, nose etc.) were used to build a feature vector
(distance between the points, angle between them etc). The recognition was
performed by calculating the euclidean distance between feature vectors of
a probe and reference image. Some of the latest work on geometric face
recognition was, a 22-dimensional fea- ture vector and experiments on large
datasets have shown that geometrical fea- tures alone may not carry enough
information for face recognition.
(1) Data Gathering: Gather face data (face images in this case) of the
people you want to identify.
(2) Train the Recognizer: Feed that face data and respective names of each
face to the recognizer so that it can learn.
(3) Recognition: Feed new faces of that people and see if the face
recognizer, just trained before, recognizes them.
OpenCV has two built-in face recognizers. The names of those face
recognizers are: EigenFaces and FisherFaces.
This algorithm considers the fact that not all parts of a face are equally
im- portant or useful for face recognition. Indeed, when you look at
someone, you recognize that person by his distinct features, like the eyes,
nose, cheeks or fore- head; and how they vary respect to each other. Focus
is on the areas of maximum change. For example, from the eyes to the nose
there is a significant change, and same applies from the nose to the mouth.
When multiple faces are given, compar- ison is done by looking at these
areas, because by catching the maximum variation among faces, they help
to differentiate one face from the other. This is how EigenFaces recognizer
works. It looks at all the training images of all the people as a whole and
tries to extract the components which are relevant and useful and discards
the rest. These important features are called principal components.
One thing to note here is that FisherFaces only prevents features of one
person from becoming dominant, but it still considers illumination changes
as a useful feature. But light variation is not a useful feature to extract as it
is not part of the actual face, another face recognizer Algorithm must be
used.
Table of Contents
1.OpenCV-Python
Overview
Installation
2. Images as Arrays
Binary Image
Grayscale Image
Colored Image
3. Images and OpenCV
Importing Images in OpenCV
Savings images
Basic Operations on Images
4. Face Detection
Overview
Haar feature-based cascade classifiers
Face Detection with OpenCV-Python
OpenCV-Python
Overview
OpenCV was started at Intel in the year 1999 by Gary Bradsky. The first release came
a little later in the year 2000. OpenCV essentially stands for Open Source Computer
Vision Library.Although it is written in optimized C/C++, it has interfaces for
Python and Java along with C++. OpenCV boasts of an active user base all over the
world with its use increasing day by day due to the surge in computer vision
applications.OpenCV-Python is the python API for OpenCV. You can think of it as a
python wrapper around the C++ implementation of OpenCV. OpenCV-Python is not
only fast (since the background consists of code written in C/C++) but is also easy to
code and deploy(due to the Python wrapper in foreground). This makes it a great
choice to perform computationally intensive programs.
Installation
OpenCV-Python supports all the leading platforms like Mac OS, Linux, and
Windows. It can be installed in either of the following ways:
Unofficial pre-built OpenCV packages for Python.
Packages for standard desktop environments (Windows, macOS, almost any
GNU/Linux distribution) run pip install opencv-python if you need only main
modules run pip install opencv-contrib-python if you need both main and contrib
module (check extra modules listing from OpenCV documentation)
You can either use Jupyter notebooks or any Python IDE of your choice for writing
the scripts. Images as Arrays
An image is nothing but a standard Numpy array containing pixels of data points.
More the number of pixels in an image, the better is its resolution. You can think of
pixels to be tiny blocks of information arranged in the form of a 2 D grid, and the
depth of a pixel refers to the color information present in it. In order to be processed
by a computer, an image needs to be converted into a binary form. The color of an
image can be calculated as follows:
Number of colors/ shades = 2^bpp where bpp represents bits per pixel.
Naturally, more the number of bits/pixels, more possible colors in the images. The
following table shows the relationship more clearly.
Let us now have a look at the representation of the different kinds of images:
Binary Image
A binary image consists of 1 bit/pixel and so can have only two possible colors, i.e.,
black or white. Black is represented by the value 0 while 1 represents white.
Fig 11 Binary image
Grayscale image
A grayscale image consists of 8 bits per pixel. This means it can have 256 different
shades where 0 pixels will represent black color while 255 denotes white. For
example, the image below shows a grayscale image represented in the form of an
array. A grayscale image has only 1 channel where the channel represents dimension
2. Rectangle
For a rectangle, we need to specify the top left and the bottom right coordinates.
#Draw a blue rectangle with a thickness of 5 px
rectangle= cv2.rectangle(img,(384,0),(510,128),(0,0,255),5)
plt.imshow(rectangle)
3. Circle
For a circle, we need to pass its center coordinates and radius value. Let us draw a
circle inside the rectangle drawn above
These Haar Features are like windows and are placed upon images to compute a
single feature. The feature is essentially a single value obtained by subtracting the
sum of the pixels under the white region and that under the black. The process can
be easily visualized in the example below.
For demonstration purpose, let's say we are only extracting two features, hence we
have only two windows here.
The first feature relies on the point that the eye region is darker than the
adjacent cheeks and nose region.
The second feature focuses on the fact that eyes are kind of darker as
compared to the bridge of the nose.
Thus, when the feature window moves over the eyes, it will calculate a single value.
This value will then be compared to some threshold and if it passes that it will
conclude that there is an edge here or some positive feature.
2. 'Integral Images' concept
The algorithm proposed by Viola Jones uses a 24X24 base window size, and that
would result in more than 180,000 features being calculated in this window. Imagine
calculating the pixel difference for all the features? The solution devised for this
computationally intensive process is to go for the Integral Image concept. The
integral image means that to find the sum of all pixels under any rectangle, we
simply need the four corner values.
This means, to calculate the sum of pixels in any feature window, we do not need to
sum them up individually. All we need is to calculate the integral image using the 4
corner values.
The example below will make the process transparent.
3. 'Adaboost' : to improve classifier accuracy
As pointed out above, more than 180,000 features values result within a 24X24
window.However, not all features are useful for identifying a face. To only select the
best feature out of the entire chunk, a machine learning algorithm called Adaboost is
used. What it essentially does is that it selects only those features that help to
improve the classifier accuracy. It does so by constructing a strong classifier which is
a linear combination of a number of weak classifiers. This reduces the amount of
features drastically to around 6000 from around
180,000.
4. Using 'Cascade of Classifiers'
Another way by which Viola Jones ensured that the algorithm performs fast is by
employing a cascade of classifiers. The cascade classifier essentially consists of stages
where each stage consists of a strong classifier. This is beneficial since it eliminates
the need to apply all features at once on a window. Rather, it groups the features into
separate sub-windows and the classifier at each stage determines whether or not the
sub-window is a face. In case it is not, the sub-window is discarded along with the
features in that window. If the sub-window
moves past the classifier, it continues to the next stage where the second stage of
features is applied. The process can be understood with the help of the diagram
below.
The Paul- Viola algorithm can be visualized as follows:
Face Detection with OpenCV-Python
Now we have a fair idea about the intuition and the process behind Face recognition.
Let us now use OpenCV library to detect faces in an image.
Load the necessary Libraries
import numpy as np
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
Loading the image to be tested in grayscale
We shall be using the image below:
Since we know that OpenCV loads an image in BGR format, so we need to convert it
into R
Since we know that OpenCV loads an image in BGR format, so we need to convert it
into RBG
format to be able to display its true colors. Let us write a small function for that.
def convertToRGB(image):
return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
Haar cascade files
OpenCV comes with a lot of pre-trained classifiers. For instance, there are classifiers
for smile, eyes, face, etc. These come in the form of xml files and are located in the
opencv/data/haarcascades/ folder. However, to make things simple, you can also
access them from here. Download the xml files and place them in the data folder in
the same working directory as the jupyter notebook.
Loading the classifier for frontal face
Face detection
We shall be using the detectMultiscale module of the classifier. This function will
return a rectangle with coordinates(x,y,w,h) around the detected face. This function
has two important parameters which have to be tuned according to the data.
haar_cascade_face=cv2.CascadeClassifier('data/haarcascade/haarcascade_frontalfac
e_descalefactor
In a group photo, there may be some faces which are near the camera than
others. Naturally, such faces would appear more prominent than the ones behind.
This factor compensates for that min Neighbors This parameter specifies the number
of neighbors a rectangle should have to be called a face.
Our next step is to loop over all the coordinates it returned and draw rectangles
around them using Open CV. We will be drawing a green rectangle with a thickness
of 2
for (x,y,w,h) in faces_rects:
cv2.rectangle(test_image, (x, y), (x+w, y+h), (0, 255, 0), 2)
Finally, we shall display the original image in colored to see if the face has been
detected correctly or not.
#convert image to RGB and show image
plt.imshow(convertToRGB(test_image))
faces_rects = haar_cascade_face.detectMultiScale(test_image_gray, scaleFactor = 1.2,
mi
# Let us print the no. of faces found
print('Faces found: ', len(faces_rects))
Faces found: 1
Here, it is. We have successfully detected the face of the baby in the picture. Let us
now create a generalized function for the entire face detection process.
Face Detection with generalized function
Testing the function on new image
This time test image is as follows:
def detect_faces(cascade, test_image, scaleFactor = 1.1):
# create a copy of the image to prevent any changes to the original one.
image_copy = test_image.copy()
#convert the test image to gray scale as opencv face detector expects gray images
gray_image = cv2.cvtColor(image_copy, cv2.COLOR_BGR2GRAY)
# Applying the haar classi_er to detect faces
faces_rect = cascade.detectMultiScale(gray_image, scaleFactor=scaleFactor,
minNeigh
for (x, y, w, h) in faces_rect:
cv2.rectangle(image_copy, (x, y), (x+w, y+h), (0, 255, 0), 15)
return image_copy
TESTING THE FUNCTION ON NEW IMAGE:
#loading image
test_image2 = cv2.imread('baby2.jpg')
# Converting to grayscale
test_image_gray = cv2.cvtColor(test_image, cv2.COLOR_BGR2GRAY)
# Displaying grayscale image
plt.imshow(test_image_gray, cmap='gray')
#call the function to detect faces
faces = detect_faces(haar_face_cascade, test_image2)
#convert to RGB and display image
plt.imshow(convertToRGB(faces))
Implementation Phase
4.1.1 Ubuntu
4.1.2 OpenCV
Open Source Computer Vision Library is released under a BSD license
and hence it’s free for both academic and commercial use. It has C++, C,
Python and Java interfaces and supports Windows, Linux, Mac OS, iOS
and Android. OpenCV was designed for computational efficiency and with
a strong focus on real-time applications. Written in optimized C/C++, the
library can take advan- tage of multi-core processing. Enabled with
OpenCL, it can take advantage of the hardware acceleration of the
underlying heterogeneous compute platform.
4.1.3 Python
Python is an interpreted, object-oriented, high-level programming
language with dynamic semantics. Its high-level built in data structures,
combined with dynamic tyWebng and dynamic binding, make it very
attractive for RaWebd Applica- tion Development, as well as for use as a
scripting or glue language to connect existing components together.
Python’s simple, easy to learn syntax emphasizes readability and therefore
reduces the cost of program maintenance. Python sup- ports modules and
packages, which encourages program modularity and code reuse. The
Python interpreter and the extensive standard library are available in source
or binary form without charge for all major platforms, and can be freely
distributed.
Used Python for Face Detection codes in
openCV. Version used: Python 3.7.2
4.1.4 Keras
4.1.5 Matplotlib
4.1.6 Scikit-learn
Face Detection phase was done using OpenCV with the help of python
pro- gramming language. Face Detection was implemented in Windows
Operating System as an initial stage using the Webcamera of the Laptop.
So, during image capture using Webcamera, the computer detected the
available faces from the im- age, using Haar Algorithm.
Further, it was implemented onto System hardware using the Web Camera
6.1Conclusion
Facial recognition has proven to be one of the most secure methods of all
biometric systems to a point for high level security and to avoid ATM
robberies and provide security for ATM.
6.1Future Scope
This project can be used for real time security applications like in ATM
security systems, military applications, high security companies. This can
also be used in bank locker access. Lighting provided to the system is a key
factor to be taken care of. Usage of high-speed computers can improve the
efficiency.
Bibliography
[6]L. Wang,H. Ji, Y. Shi, " Face recognition using maximum local fisher discriminant
analysis",
40
18th IEEE International Conference on Image Processing, 2011.
40
[8]H. R. Babaei, O. Molalapata and A.H.Y Akbar Pandor, "Face
Recognition Application for Au- tomatic Teller Machines (ATM)",
International Conference on Information and Knowledge Manage- ment
(ICIKM), 2012.
[9]https://docs.opencv.org/2.4/modules/contrib/doc/facerec/facerec-
tutorial.htmlface- recognition
[10] https://www.superdatascience.com/opencv-face-
recognition/ [11]https://www.rankred.com/face-
recognition-algorithms-techniques/
[12] https://www.pyimagesearch.com/2018/06/18/face-recognition-with-
opencv-python-and- deep-learning/
[13] https://towardsdatascience.com/facial-recognition-using-deep-learning-a74e9059a150
CODING
import face_recognition
import cv2
from time import sleep
import os
#os.system("python steganography.py unmerge --img=res/Decrypted.png
--output=output2.png")
READ_API_KEY=' '
CHANNEL_ID= ' '
c=["ARUL","PRIYA","","","","","","","",""]
b=[5000,10000]
def checkface():
name=""
top = 4
right = 4
bottom = 4
left = 4
image_1 = face_recognition.load_image_file("1.jpg")
image_1_face_encoding = face_recognition.face_encodings(image_1)[0]
image_2 = face_recognition.load_image_file("output2.png")
image_2_face_encoding = face_recognition.face_encodings(image_2)[0]
known_face_encodings = [
image_1_face_encoding,
image_2_face_encoding,
]
known_face_names = [
"0","1"
]
face_locations = []
face_encodings = []
face_names = []
video_capture = cv2.VideoCapture(0)
process_this_frame = True
for ig in range(0,50):
ret, frame = video_capture.read()
small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
rgb_small_frame = small_frame[:, :, ::-1]
if process_this_frame:
face_locations = face_recognition.face_locations(rgb_small_frame)
face_encodings = face_recognition.face_encodings(rgb_small_frame,
face_locations)
for face_encoding in face_encodings:
matches = face_recognition.compare_faces(known_face_encodings,
face_encoding)
name = "Unknown"
if True in matches:
first_match_index = matches.index(True)
name = known_face_names[first_match_index]
face_names.append(name)
process_this_frame = not process_this_frame
for (top, right, bottom, left), name in zip(face_locations, face_names):
top *= 4
right *= 4
bottom *= 4
left *= 4
cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255),
cv2.FILLED)
font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)
cv2.imshow('Video', frame)
cv2.waitKey(1)
video_capture.release()
cv2.destroyAllWindows()
return name
while True:
s=input("ENTER 1 FOR FACE TRANSACTION \n ENTER 2 FOR OTHER
TRANSACTION")
if s==1:
a=checkface()
print(a)
if a=="":
print("YOUR FACE IS NOT RECOGNISED")
else:
print("SUCESSFULLY AUTHENTICATED")
v=int(a)
print(c[v])
#print(b[v])
t=input("ENTER THE AMOUNT TO TAKE:")
if t<b[v]:
print("AMOUNT PROCESSED SUCESSFULLY")
b[v]=b[v]-t
print("Your Balance amount is")
print(b[v])
else:
o=raw_input("ENTER SECRET PIN:")
TS = urllib2.urlopen("https://api.thingspeak.com/channels/994271/feeds.json?
api_key=OULT2DMARL34REDR&results=1")
response = TS.read()
data=json.loads(response)
#b = data['channel']['field1']
b=data['feeds'][0]['field1']
u=b[0:4]
if o in u:
print(b[4:])
print("processed Sucessfully")