-
Notifications
You must be signed in to change notification settings - Fork 0
/
ageGender.py
226 lines (216 loc) · 12.1 KB
/
ageGender.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ageGender.ui'
#
# Created by: PyQt5 UI code generator 5.12.3
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_AgeGender(object):
def setupUi(self, AgeGender):
AgeGender.setObjectName("AgeGender")
AgeGender.resize(775, 740)
self.centralwidget = QtWidgets.QWidget(AgeGender)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout_3 = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout_3.setObjectName("gridLayout_3")
self.line = QtWidgets.QFrame(self.centralwidget)
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.gridLayout_3.addWidget(self.line, 3, 0, 1, 3)
self.stackedWidget = QtWidgets.QStackedWidget(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(1)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.stackedWidget.sizePolicy().hasHeightForWidth())
self.stackedWidget.setSizePolicy(sizePolicy)
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(145, 145, 145))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(145, 145, 145))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(145, 145, 145))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(145, 145, 145))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
self.stackedWidget.setPalette(palette)
self.stackedWidget.setObjectName("stackedWidget")
self.viewfinderPage = QtWidgets.QWidget()
self.viewfinderPage.setObjectName("viewfinderPage")
self.gridLayout_5 = QtWidgets.QGridLayout(self.viewfinderPage)
self.gridLayout_5.setObjectName("gridLayout_5")
self.viewfinder = QCameraViewfinder(self.viewfinderPage)
self.viewfinder.setObjectName("viewfinder")
self.gridLayout_5.addWidget(self.viewfinder, 0, 0, 1, 1)
self.stackedWidget.addWidget(self.viewfinderPage)
self.previewPage = QtWidgets.QWidget()
self.previewPage.setObjectName("previewPage")
self.gridLayout_4 = QtWidgets.QGridLayout(self.previewPage)
self.gridLayout_4.setObjectName("gridLayout_4")
self.imagePreview = QtWidgets.QLabel(self.previewPage)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.imagePreview.sizePolicy().hasHeightForWidth())
self.imagePreview.setSizePolicy(sizePolicy)
self.imagePreview.setMinimumSize(QtCore.QSize(400, 400))
self.imagePreview.setFrameShape(QtWidgets.QFrame.Box)
self.imagePreview.setText("")
self.imagePreview.setObjectName("imagePreview")
self.gridLayout_4.addWidget(self.imagePreview, 0, 0, 1, 1)
self.message = QtWidgets.QLabel(self.previewPage)
self.message.setText("")
self.message.setObjectName("message")
self.gridLayout_4.addWidget(self.message, 1, 0, 1, 1)
self.stackedWidget.addWidget(self.previewPage)
self.gridLayout_3.addWidget(self.stackedWidget, 1, 0, 2, 1)
self.captureWidget = QtWidgets.QTabWidget(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.captureWidget.sizePolicy().hasHeightForWidth())
self.captureWidget.setSizePolicy(sizePolicy)
self.captureWidget.setMinimumSize(QtCore.QSize(180, 400))
self.captureWidget.setObjectName("captureWidget")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
self.gridLayout = QtWidgets.QGridLayout(self.tab_2)
self.gridLayout.setObjectName("gridLayout")
self.uploadImage = QtWidgets.QPushButton(self.tab_2)
self.uploadImage.setObjectName("uploadImage")
self.gridLayout.addWidget(self.uploadImage, 0, 0, 1, 1)
spacerItem = QtWidgets.QSpacerItem(20, 161, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem, 9, 0, 1, 1)
self.ImGender = QtWidgets.QLabel(self.tab_2)
self.ImGender.setObjectName("ImGender")
self.gridLayout.addWidget(self.ImGender, 1, 0, 1, 1)
self.ImAge = QtWidgets.QLabel(self.tab_2)
self.ImAge.setObjectName("ImAge")
self.gridLayout.addWidget(self.ImAge, 3, 0, 1, 1)
self.ImAgeAcc = QtWidgets.QLabel(self.tab_2)
self.ImAgeAcc.setObjectName("ImAgeAcc")
self.gridLayout.addWidget(self.ImAgeAcc, 4, 0, 1, 1)
self.ImGenderAcc = QtWidgets.QLabel(self.tab_2)
self.ImGenderAcc.setObjectName("ImGenderAcc")
self.gridLayout.addWidget(self.ImGenderAcc, 2, 0, 1, 1)
self.captureWidget.addTab(self.tab_2, "")
self.tab = QtWidgets.QWidget()
self.tab.setObjectName("tab")
self.gridLayout_2 = QtWidgets.QGridLayout(self.tab)
self.gridLayout_2.setObjectName("gridLayout_2")
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout_2.addItem(spacerItem1, 5, 0, 1, 1)
self.startCamera = QtWidgets.QPushButton(self.tab)
self.startCamera.setObjectName("startCamera")
self.gridLayout_2.addWidget(self.startCamera, 0, 0, 1, 1)
self.VageAcc = QtWidgets.QLabel(self.tab)
self.VageAcc.setObjectName("VageAcc")
self.gridLayout_2.addWidget(self.VageAcc, 4, 0, 1, 1)
self.ageValue = QtWidgets.QLabel(self.tab)
self.ageValue.setObjectName("ageValue")
self.gridLayout_2.addWidget(self.ageValue, 3, 0, 1, 1)
self.genderValue = QtWidgets.QLabel(self.tab)
self.genderValue.setObjectName("genderValue")
self.gridLayout_2.addWidget(self.genderValue, 1, 0, 1, 1)
self.VgenderAcc = QtWidgets.QLabel(self.tab)
self.VgenderAcc.setObjectName("VgenderAcc")
self.gridLayout_2.addWidget(self.VgenderAcc, 2, 0, 1, 1)
self.captureWidget.addTab(self.tab, "")
self.gridLayout_3.addWidget(self.captureWidget, 2, 1, 1, 2)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.genderWidget = genderWidget(self.centralwidget)
self.genderWidget.setMinimumSize(QtCore.QSize(205, 200))
self.genderWidget.setObjectName("genderWidget")
self.horizontalLayout.addWidget(self.genderWidget)
spacerItem2 = QtWidgets.QSpacerItem(58, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem2)
self.line_2 = QtWidgets.QFrame(self.centralwidget)
self.line_2.setFrameShape(QtWidgets.QFrame.VLine)
self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_2.setObjectName("line_2")
self.horizontalLayout.addWidget(self.line_2)
self.ageWidget = ageWidget(self.centralwidget)
self.ageWidget.setMinimumSize(QtCore.QSize(580, 200))
self.ageWidget.setObjectName("ageWidget")
self.horizontalLayout.addWidget(self.ageWidget)
self.gridLayout_3.addLayout(self.horizontalLayout, 5, 0, 2, 3)
AgeGender.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(AgeGender)
self.menubar.setGeometry(QtCore.QRect(0, 0, 775, 25))
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
self.menuDevices = QtWidgets.QMenu(self.menubar)
self.menuDevices.setObjectName("menuDevices")
AgeGender.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(AgeGender)
self.statusbar.setObjectName("statusbar")
AgeGender.setStatusBar(self.statusbar)
self.actionExit = QtWidgets.QAction(AgeGender)
self.actionExit.setObjectName("actionExit")
self.actionStartCamera = QtWidgets.QAction(AgeGender)
self.actionStartCamera.setObjectName("actionStartCamera")
self.actionStopCamera = QtWidgets.QAction(AgeGender)
self.actionStopCamera.setObjectName("actionStopCamera")
self.actionSettings = QtWidgets.QAction(AgeGender)
self.actionSettings.setObjectName("actionSettings")
self.menuFile.addAction(self.actionStartCamera)
self.menuFile.addAction(self.actionStopCamera)
self.menuFile.addSeparator()
self.menuFile.addAction(self.actionSettings)
self.menuFile.addSeparator()
self.menuFile.addAction(self.actionExit)
self.menubar.addAction(self.menuFile.menuAction())
self.menubar.addAction(self.menuDevices.menuAction())
self.retranslateUi(AgeGender)
self.stackedWidget.setCurrentIndex(1)
self.captureWidget.setCurrentIndex(1)
self.actionExit.triggered.connect(AgeGender.close)
self.actionSettings.triggered.connect(AgeGender.configureCaptureSettings)
self.actionStartCamera.triggered.connect(AgeGender.startCamera)
self.actionStopCamera.triggered.connect(AgeGender.stopCamera)
self.uploadImage.clicked.connect(AgeGender.takeImage)
QtCore.QMetaObject.connectSlotsByName(AgeGender)
def retranslateUi(self, AgeGender):
_translate = QtCore.QCoreApplication.translate
AgeGender.setWindowTitle(_translate("AgeGender", "Age and Gender estimation"))
self.uploadImage.setText(_translate("AgeGender", "Upload Photo"))
self.ImGender.setText(_translate("AgeGender", "Gender :"))
self.ImAge.setText(_translate("AgeGender", "Age :"))
self.ImAgeAcc.setText(_translate("AgeGender", "Accuracy :"))
self.ImGenderAcc.setText(_translate("AgeGender", "Accuracy :"))
self.captureWidget.setTabText(self.captureWidget.indexOf(self.tab_2), _translate("AgeGender", "Image"))
self.startCamera.setText(_translate("AgeGender", "Start"))
self.VageAcc.setText(_translate("AgeGender", "Accuracy :"))
self.ageValue.setText(_translate("AgeGender", "Age :"))
self.genderValue.setText(_translate("AgeGender", "Gender :"))
self.VgenderAcc.setText(_translate("AgeGender", "Accuracy :"))
self.captureWidget.setTabText(self.captureWidget.indexOf(self.tab), _translate("AgeGender", "Video"))
self.menuFile.setTitle(_translate("AgeGender", "File"))
self.menuDevices.setTitle(_translate("AgeGender", "Devices"))
self.actionExit.setText(_translate("AgeGender", "Exit"))
self.actionStartCamera.setText(_translate("AgeGender", "Start Camera"))
self.actionStopCamera.setText(_translate("AgeGender", "Stop Camera"))
self.actionSettings.setText(_translate("AgeGender", "Settings"))
from PyQt5.QtMultimediaWidgets import QCameraViewfinder
from agewidget import ageWidget
from genderwidget import genderWidget
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
AgeGender = QtWidgets.QMainWindow()
ui = Ui_AgeGender()
ui.setupUi(AgeGender)
AgeGender.show()
sys.exit(app.exec_())