OVIDIUS University of Constant a [616588]

Ministry of National Education
"OVIDIUS" University of Constant a
Faculty of Mathematics and Computer Science
Degree Program: Computer Science
Home Assistant for Elderly People
Scienti c Adviser:
Conf. dr. Pelican Elena
Student: [anonimizat] a
2018

Abstract
Indiferent de varst a, foarte multe persoane sufer a de pierderi de memorie, severe
sau mai put in severe. Aceasta problem a este mult mai ^ nt^ alnit a la persoanele ^ naintate
^ n v^ arst a.Un studiu f acut ^ n 2017 arat a c a, mondial, num arul persoanelor care au
Alzheimer sau o dement  a asociat a este estimat la 44 de milioane. Doar 1 din 4 persoane
bolnave de Alzheimer au fost diagnosticate. Mai mult de unul din 6 ^ ngrijitor ai bolii
Alzheimer  si dement iei au trebuit s a renunt e la munc a ^ n ^ ntregime e pentru a deveni
un ^ ngrijitor ^ n primul r^ and, e pentru c a ^ ndatoririle au devenit prea ^ mpov ar atoare.
Unul dn 3 ^ ngrijitori are 65 de ani sau mai mult. ^Intre 200 si 2015 decesurile din
cauza bolilor de inim a au sc azut cu 11% ^ n timp ce cele de Alzheimer au crescut cu
123%. Aceasta crunt a boal a omoar a mai mult dec^ a cancerul de s^ an  si cel de prostat a
combinat.
No matter the age, many people su ers from memory loss, severe or not. This
problem is much more common to older people. A 2017 study shows that, worldwide,
the number of persons who su ers from Alzheimer or a related dementia is estimated
to 44 millions. Just 1 in 4 people who su ers from Alzheimer have been diagnosed.
More that 1 in 6 caretakers of Alzheimer and dementia had to give entirely up work,
either to be a caretaker or beacuse it was to burdensome. On in 3 caretakers is 65
or older. Between 2000 and 2015 deaths from heart diseases have decreased by 11%,
while deaths from Alzheimer's disease have increased by 123%. This cruel disease kills
more than breast and prostate cancer combined.

Outline
Outline 1
1 Introduction 2
2 Content 3
2.1 Reminder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Chatbot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Face Recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Application 12
4 Conclusions 14
4.1 Future works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
References 15
1

Chapter 1
Introduction
This idea came to life from the desire of easing the lives of elderly people. How
will it ease their lives? Simple! This application is designed to the needs of the
elderly,having features that will help them throughout the day.
Seeing how my grandmothers have a hard time remembering some things that
are important or trying to use smartphone, I thoight that maybe I could desing an
app that would be easy for them to use and that would help them remembering the
forgotten things. As the idea started to form in my mind, I thought that I sould also
add a feature for the people that su ers from alzheimer, so I added face recognition.
Up until now the application contain three functional features:
.Reminder
.Chatbot
.Face recognition
Reminder
I thought of the application to have a reminder activity that will help the user remember
activities or events. For example this part of the application could be used for taking
pills, or checking every night before bedtime if the doors and windows are closed.
Chatbot
The application has integrated a chatbot functionality mainly to help entertaining the
elders, helping them in di erent activities and socialize with them.
Face recognition
The last functionality is it for a rather extreme case. I thought about integrating a
facial recgnition in the application so it can be used mostly by people who su ers from
alzheimer and they cannot recognize even their family.
2

Chapter 2
Content
The application was build using [1]. It is written in java.
2.1 Reminder
For this feature I used the SqLite library, two recievers and a service. Using the
Sqlite library the reminder creates the "Aletheia" database and a table that will store
all the necessary informations for reminders, such as: the date, time, name of the
reminder, repetition, type of repetition and repetition interval.
public i n t addReminder ( Reminder reminder ) f
SQLiteDatabase db = t h i s . getWritableDatabase ( ) ;
ContentValues values = new ContentValues ( ) ;
values . put (KEY TITLE , reminder . g e t T i t l e ( ) ) ;
values . put (KEY DATE , reminder . getDate ( ) ) ;
values . put (KEY TIME , reminder . getTime ( ) ) ;
values . put (KEY REPEAT , reminder . getRepeat ( ) ) ;
values . put (KEY REPEAT NO , reminder . getRepeatNo ( ) ) ;
values . put (KEY REPEAT TYPE, reminder . getRepeatType ( ) ) ;
values . put (KEY ACTIVE, reminder . getActive ( ) ) ;
long ID = db . i n s e r t (TABLE REMINDERS, null , values ) ;
db . c l o s e ( ) ;
return ( i n t ) ID ;
gnn[ 0 . 5cm]
For recieving the noti cation I used BroadcastReciever in combination with Wake-
fulBroadcastReciever and IntentService. The last two are used for recieving noti cation
even if the user is no longer in the application. Because the WakefulBroadcastReciever
is deprecated for teh latter versions I had to use it just for versions below API 22
3

Content Chatbot
(Android Oreo), so for the versions above API 22, I used the IntentService.
2.2 Chatbot
For this feature I used the Bot and Chat libraries. The dictionary of the chatbot
is built using AIML les and for the exchange between the bot and the human I used
an Adapter. Below is an example of the chatbot dictionary le:
<?xml v e r s i o n ="1.0" encoding="UTF 8"?>
<aiml>
<category > <pattern >DAY</pattern >
<template >Today i s <date format="% A" jformat="EEEEEEEEEE"/ ></template >
</category >
<category > <pattern >YEAR</pattern >
<template >This i s <date format="% Y" jformat=" YYYY"/ ></template >
</category >
<category > <pattern >MONTH </pattern >
<template >This i s <date format="%B" jformat=" M M M M M M M M M "/ ></template >
</category >
<category > <pattern >TIME</pattern >
<template >The time i s <date format="%I :%M %p" jformat="h :m m a"/ ></template >
</category >
<category > <pattern >DATE</pattern >
<template >Today i s <date format="%B %d , % Y" jformat=" M M M M M M M M M dd , YYYY"/ ></template >
</category >
<category > <pattern >DATE AND TIME </pattern >
<template >The date and time i s <date/ ></template >
</category >
</aiml >
2.3 Face Recognition
For this feature I used the [4] for the integration of the Eigenfaces algorithm. I
used the algorithm from [6]. PCA (Principal Component Analysis) is a method of
identifying patterns in data. We use PCA to obtain a set of eigenfaces. For a dataset
with N images, each image must have the same resolution
M=n1xn2
and is transformed into a vector
i
4

Content Face Recognition
of dimmensions M x 1.
Then it is calculated the mean vector
'i= i ;i=1;N
which is substraced from all the vectors that forms the dataset. That means that the
data is "centered".
The rst singular image is de ned by the principal singurlars vectors, looks like the
mean vector. From here we conclude that there is no bene t from substracting the
mean vector from all the others vectors.
The PCA algorithm is applied to the vectors set of big dimmensions
'1;'2;:::;' N
. A set of orthonomal vector
u1;u2;:::;u N
which will best describe the patterns from the dataset is sought for.
Let A:m x n be a centered data matrix, where each column has random values of
mean 0.
Let SVD decomposition for A,
A=UVT
.
The right singular vectors
vi
are named principal components directions.
The vector
z1=Av1=1u1
has the biggest variation from all the liniar normalized combinations belonging to the
column A:
var(z1) =var(Av1) =!2
1
m
We remind that for a vector/sample x of length n, we have
var(x) =1
nnX
i=1(xix)2
, where
x
is the mean of the vector x.
5

Content Face Recognition
Finding the maximum varience vectors is equivalent, in liniar algebra terms, with
maximization of Rayleight coecients
2
1= max
v6=0vTATAv
vTv=kAvk2
kvk2
,
v1=argmax
v6=0kAvk2
kvk2
The normalized variable
ui=1
1Av1
is called the rst principal component of A.
Then, we want to determine the vector with the second biggest varience wich is
perpendicular to the rst vector. This is obtain by calculating the biggest varience of
the "de
ated" matrix,
A A1u1vT
1
and so on…
We will explain the pick of
ukand k
. From the SVD decomposition of the matrix A we have
A=UVT
, where A is of dimensions N x N, and
 =diag(1;2;::::; r;0;:::::0)
with
1:::r>0
, r = rang(A),
Let
u1;u2;:::u N
a subspace of U of dimmension N. Then each vector
'i
can be written as:
'i=fi1u1+fi2u2+:::+fiNuN;i=1;N
. We obtain the relation:
fij='T
iuj=<uj;'i>
6

Content Face Recognition
We know that for a symmetric and positive-de ned matrix B, we have
(B) =1;::::; n[0;1);minkxk2<Bx;x>maxkxk2and max
= max
kxk6=0<Bx;x>
kxk2= max
kxk26=0xTBx
kxk2
.
But
max(AAT) =2
1;where 1
is the biggest singular value of the matrix A.We have
wTAATw= (ATw)T(ATw) =kATwk2=NX
i=1j'T
1wj2
So we obtain:
max
w6=0wT(AAT)w
wTw= max
kwk=1wT(AAT)w= max
kwk=1NX
i=1j'T
iwj2
. So we are looking for
max
kwk=1NX
i=1j'T
iwj2
.
We have:
AAT=UVTVTUT=UTUT
, using this we obtain:
wT(AAT)w
wTw=xTTx
xtx=1
1×1
1+2
2×2
2+:::+r
rxr
r
x2
1+x2
2+:::+x2
N
.
We suppose that
12:::r
and we obtain:
max
x6=1
1×1
1+2
2×2
2+:::+r
rxr
r
x2
1+x2
2+:::+x2
N=2
1=1
where
1
is the biggest eigen value of A. So we have x with
x1= 1andx i= 0;i= 2;::::;N
7

Content Face Recognition
. Then
w=Ux=u1;
where is the eigen vector for the matrix
AAT;
corresponding to
1:
For the second principal component we use the same reasoning. We are searching
for
max
kwk=1;wTu1=0NX
i=1j'Twj2
. Analogous, we obtain:
max
w6=0;wTu1=0wT(AAT)w
wTw= max
x6=0;xTUTu1=01
1×1
1+2
2×2
2+:::+r
rxr
r
x2
1+x2
2+:::+x2
N
= max
x6=0;x1=01
1×1
1+2
2×2
2+:::+r
rxr
r
x2
1+x2
2+:::+x2
N=2
2=2:
So we have x with
x2= 1andx i= 0
for i = 1,3,…,N and
w=Ux=u2:
Continuing with the same reasoning as before we obtain
u3;u4;:::;u N:
The dimmension of the covarience matrix C is M x M, where M is the resolution of
one image. Because in practice the number M is very big, the computational e ort to
determine M eigen values and M eiegn vectors for the matrix C este imense. In this
case we want the reduction of the dimmension and of the computational volume.
Let
L=ATA;
a matrix of the dimmension N x N. Usually, N – the number of images in the dataset
is much smaller that the dimmension of a vector M, and it is much easier to compute
8

Content Face Recognition
N eigen values and N eigen vectors for a matrix of dimmesion N x N.
For the matrix L we conssider the eigen vectors
vi;Lvi=ivi:
So
(ATA)vi=ivi$A(ATA)vi=Aivi$(AAT)Avi=iAvi:
So we have
(AATAvi=iAvi;
that means that
Avi
is eigen vector for the matrix C.
We are searching for N eigen vectors,
vi;
for the matrix L. Of those N eigen vectors obtained, we keep nly the rst k, correspond-
ing to the biggest k eiegn values, which are enough to characterize the initial data set.
The other N – k vectors, corresponding to the smallest eigen values are eliminated
because the information is not semin cative. So the base of the orthonormat vectors
from
RM:u1;u2;:::;u N
(this will be used to obtain the images/vectors) will be truncated to
u1;u2;:::;u kwithK <N
To identify a new image

, being represented by the eigen vectors, we have:
!i=uT
i( );i= 1 :k:
The coecients
!i
forms the vector

T= [!1;!2;::::;! k]:
The vector

9

Content Face Recognition
describes the contributtion of each eiegn faces in the representation of the image

and is used for classifying the image
:
The Eigenfaces algorithm
Step1: All images are transformed into vectors:
1;2;:::;N
Step2: Then it is calculated the mean vector
=1
NNX
i=1i
Step3: The mean vector is subtracted from all the vectors from dataset:
'i= i ;i=1;N
Step4: We obtain the covariance matrix:
C=1
NNX
i=1'i'T
i=1
NAAT
Step5:We obtain the eigen vectors
ui=1;N
of the matrix C and we keep the rst k vectors, which correspond to the biggest k eigen
values.
Step6: We then obtain the vector:

T
i= [!i
1;!i
2;:::;!i
k]
, with
'i'^'i=kX
j=1!i
jui
j
10

Content Face Recognition
Step7: Being given an image

, it is normalized:
'=
Step8:

is projected on the space of eigen vectors:
^'i=kX
j=1!juj
Step9:
^'
is represented as

T
i= [!1;!2;:::;! k]
Step10: We are searching for a
i021;:::;N
that satisfy
ki0k= min
1iNkik
11

Chapter 3
Application
I gave this application the name of "Aletheia", which is a greek word that can be
translasted as truth or disclosure. But there is also a literal meaning to the word, the
state of not being hidden or being evident.
The reason why I chose this word was because, being the oposite of the word
lethe that can be translated to forgetfulness, oblivion or concealment, I believe that it
captures the essence of what this application is built for.
General
The minimum sdk version for the application is 15, the target version is 22.
For the design of the application I used icons from [3] and som styling for the buttons
and datetimepicker from [2] and [5].
Reminder
.a date picker, so the user can choose the data of a certain event or activity
.a time picker, so the user can choose the time of the said activity or event
.a repeat function, so the user can choose if the activity he is creating is a repeating
one or not
.a repetition interval, so the user can choose the interval of the repeating activity
.the type of repetition, e.g hourly, daily, weekly etc.
Chatbot
.the list layout that allows the conversation to be seen
.an adapter that helps the interaction between the bot and the user
.the dictionary of the bot
Face recognition
12

Application Application
.you can take a picture or you can choose one from the gallery
.you can add persons to the "visitors" group or you can create a new group
.the identi cation of the person
General
13

Chapter 4
Conclusions
4.1 Future works
In the future I plan to integrae
.speech recognition so the user can communicate easily with the chatbot without
needing to write. I plan to integrate both speech-to-text and text-to-speech so it
will make a more enjoyable communication between the man and machine.
.google maps so that the users can know the path back home, or to the doctor
or to the store, or anywhere else. This feature will have a table that contains
some crucial information such as: the home address, the doctor address, the
store address, the park address. With this data I wil draw the minimum distance
between two points such as: the user wants to go to the store from home, he will
select the destination location and the app will shortly show the most favorable
route to the destination from the current location.
.a medical log so that if the user knows what pills they have alergies to, etc.
14

References
[1] Android studio.
[2] Getbase
oatingactionbutton.
[3] Material design icons.
[4] Opencv library.
[5] Wdualle rmaterial datetime picker.
[6] Elena Pelican si L acr amioara Lit a. Algoritmi pentru recunoa sterea fet elor . MA-
TRIX ROM BUCURES TI, 2015.
15

Similar Posts