-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadData.py
77 lines (56 loc) · 1.66 KB
/
readData.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
from matplotlib import pyplot as plt
import matplotlib as mpl
import datetime as dt
import numpy as np
cred = credentials.ApplicationDefault()
faces = []
f = []
final = []
pfinal = []
rightEyes = []
leftEyes = []
times = []
blinks = []
cred = credentials.Certificate("C:/Users/Conor's Laptop/Downloads/FYPFirebaseProject-fbd67ba91d2b.json")
firebase_admin.initialize_app(cred)
db = firestore.client()
# get the specific journey
users_ref = db.collection(u'users/1gsLjv0VLbSqKahPDB1lpEgtgck1/Journeys/2020-04-21 09:44:01/Journey')
docs = users_ref.stream()
for doc in docs:
faces.append(doc.to_dict())
#find the specific journeys information
for face in faces:
f.append(face['journeyInformationss'])
for info in f:
final.append(info)
for i in range(len(final)):
for l in final[i]:
pfinal.append(l)
# traverse list to break down into lists for both eyes and the times
for i in range(len(pfinal)):
rightEyes.append(pfinal[i]['rightEye'] * 100)
leftEyes.append(pfinal[i]['leftEye'] * 1000)
r = pfinal[i]['time'].split(" ")[1]
times.append(dt.datetime.strptime(r, r'%H:%M:%S'))
# find numbers of binks at 10% treashold
b=0
for r in rightEyes:
if r < 10:
b += 1
blinks.append(b)
else:
blinks.append(b)
# graph the values
times.sort()
dates = mpl.dates.date2num(times)
plt.title('10% Threshold')
plt.ylabel('Eye Open %')
plt.xlabel('Time')
plt.plot_date(times, blinks, 'b-', label = 'Blinks')
plt.plot_date(dates, rightEyes,'b-' ,color='k', label = 'Eyes Open Probability %')
plt.legend()
plt.show()