-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.py
More file actions
91 lines (78 loc) · 3.31 KB
/
report.py
File metadata and controls
91 lines (78 loc) · 3.31 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from PyQt5.QtGui import QImage
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import (QWidget,QGridLayout, QHBoxLayout,QPushButton,QFileDialog,
QLabel, QApplication, QMainWindow, QAction, qApp,QVBoxLayout,QCheckBox,QTextEdit,QTableView,QTableWidget)
from PyQt5.QtGui import QPixmap,QIcon
from PyQt5.QtCore import (Qt,QThread,QFile)
from PyQt5 import QtSql
import numpy as np
import datetime
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
import random
class report(QWidget):
def __init__(self,db_view):
self.db_view=db_view
super().__init__()
self.initUI()
def initUI(self):
totalCount=0
luggageCount=0
actions=0
self.setGeometry(300, 20, 700, 700)
self.setWindowTitle('Daily Report')
query = QtSql.QSqlQuery()
query.exec("SELECT sessionID FROM logs");
if(query.last()):
self.sessionID=query.value(0)
queryStr=("SELECT svalue FROM logs WHERE sessionID=%d AND stype='luggage' "%self.sessionID)
query.exec(queryStr)
while (query.next()):
luggageCount+=1
queryStr=("SELECT svalue FROM logs WHERE sessionID=%d AND stype='actions' "%self.sessionID)
query.exec(queryStr)
while (query.next()):
actions+=1
queryStr=("SELECT svalue FROM logs WHERE sessionID=%d AND stype='tracking' "%self.sessionID)
query.exec(queryStr)
if(query.last()):
totalCount=query.value(0)
queryStr=("SELECT svalue,date,time FROM logs WHERE sessionID=%d AND stype='count' "%self.sessionID)
query.exec(queryStr)
countingValues=[]
while (query.next()):
countingValues.append([query.value(2),query.value(0)])
# print(countingValues)
lbl = QLabel(self)
text="<center><img src='logo.png' height=70>"
if(luggageCount==-1):
luggageCount=0
if(actions==-1):
actions=0
# text+="<table><tr><td> Total Counts</td><td> Abandoned objects </td></tr>"
# text+="<tr><td> "+str(totalCount)+"</td><td>"+str(luggageCount)+" </td></tr></table>"
#
# text+="<table><tr><td>Falling</td><td> Boxing </td></tr>"
# text+="<tr><td> "+str(totalCount)+"</td><td>"+str(luggageCount)+" </td></tr></table>"
text+="<h4> Total number of counts: <b style='color:red'>"+str(totalCount)+"</b></h4>"
text+="<h4>Total number of Abandoned objects <b style='color:red'>"+str(luggageCount)+"<b></h4>"
# text+="<h4>Total number of Actions <b style='color:red'>"+str(actions)+"<b></h4>"
if(len(countingValues)>0):
data=np.asarray(countingValues)
x=np.arange(len(data))
fig, ax = plt.subplots()
plt.xticks(x, data[:,0])
start, end = ax.get_xlim()
ax.xaxis.set_ticks(np.arange(start, end, 10))
ax.plot(x, data[:,1])
ax.grid(True)
fig.autofmt_xdate()
plt.savefig('report.jpg')
text+="<h2><img src='report.jpg' width=700></h2>"
text+="</center>"
# plt.show()
lbl.setFixedWidth(700)
lbl.setText(text)
self.setStyleSheet("background-color:#FFF;");