forked from dguari1/Auto-eFace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auto-eFACE.py
973 lines (751 loc) · 47.4 KB
/
Auto-eFACE.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 23 14:24:31 2017
@author: guarind
"""
#import cv2
import os
import sys
#import numpy as np
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5 import QtCore
from PyQt5.QtCore import QFile, QTextStream
from mini_Emotrics import Emotrics
from settings_window import ShowSettings
#from utilities import get_info_from_txt
#from ProcessLandmarks import GetLandmarks
from ThumbNailViewer import ThumbNailViewer
from reportcard_window import ReportCardInit
class PatientPhotograph(object):
#this class contains all the information associated with a photo
def __init__(self):
self._photo = None #this is a open cv image element
self._file_name = None #is the physical address of the photo
self._name = '' #this is the file name
self._extension = '' #this is the file extension
self._ID = '' #this is the photo ID, there are eight different types of photos
self._shape = None #this is the landmark localization provided by dlib
self._lefteye = None #this si the position and diameter of left iris
self._righteye = None #this si the position and diameter of right iris
self._points = None
self._boundingbox = None #this is the facial bounding-box provided by dlib
self._Tag = '' #this is the tag that goes in the Emotrics window
self._OpenEmotrics = True #this informs the main prgram if it should open Emotrics
#for landmark localization. Emotrics will be open only
#if the user double clikc on a photo
self._NewPatient = False #this variable is used to indicate if new photos
#from new patients are beeing droped to the app.
#In that case, the patient information is removed
#so that it wont be shown next time the user
#opens the results window
class Patient(object):
#this class compiles the patient information
def __init__(self):
self._Rest = PatientPhotograph()
self._SmallSmile = PatientPhotograph()
self._LargeSmile = PatientPhotograph()
self._EyeBrow = PatientPhotograph()
self._EyeClosureGently = PatientPhotograph()
self._EyeClosureTight = PatientPhotograph()
self._PuckeringLips = PatientPhotograph()
self._DentalShow = PatientPhotograph()
#additional info that is needed for processing
self._Patient_ID = None #Patient ID
self._MRN = None #Medical Record Number
self._HealthySide = None #healthy side of the face
self._CalibrationType='Iris'
self._CalibrationValue=11.77
self._ModelName = 'MEE'
class window(QtWidgets.QWidget):
def __init__(self):
super(window, self).__init__()
self.setWindowTitle('auto-eFACE')
scriptDir = os.path.dirname(os.path.realpath(sys.argv[0]))
self.setWindowIcon(QtGui.QIcon(scriptDir + os.path.sep + 'include' +os.path.sep +'icon_color'+ os.path.sep + 'meei_3WR_icon.ico'))
#self.setStyleSheet('background:Aliceblue')
self._CalibrationType = 'Iris' #_CalibrationType can be 'Iris' or 'Manual'
self._CalibrationValue = 11.77 #calibration parameter
self._ModelName = 'MEE' #_ModelType can be 'iBUGS' or 'MEE'
#Each photogaph will have its own class that stores all the relevant
#information, this class will be updated everytime the user double
#clicks on a Thumbnail viewer element. The report card will be generated
#with the information stored in these elements, so they all have to
#be filled before generating the report card
self._Rest = PatientPhotograph()
self._SmallSmile = PatientPhotograph()
self._LargeSmile = PatientPhotograph()
self._EyeBrow = PatientPhotograph()
self._EyeClosureGently = PatientPhotograph()
self._EyeClosureTight = PatientPhotograph()
self._PuckeringLips = PatientPhotograph()
self._DentalShow = PatientPhotograph()
self._Patient = Patient() #this variable contains information about all photos
#these are the windows that will show the Emotris app
self.show_me_rest = None
self.show_me_smallsmile = None
self.show_me_largesmile = None
self.show_me_eyebrow = None
self.show_me_eyeclosuregently = None
self.show_me_eyeclosuretight= None
self.show_me_puckeringlips = None
self.show_me_dentalshow = None
#initialize the User Interface
self.initUI()
def initUI(self):
scriptDir = os.path.dirname(os.path.realpath(sys.argv[0]))
spacerh = QtWidgets.QWidget(self)
spacerh.setFixedSize(15,0)
spacerv = QtWidgets.QWidget(self)
spacerv.setFixedSize(0,15)
#the image will be displayed in the custom ImageViewer
self.Rest = ThumbNailViewer(self._ModelName, self._Rest)
self.Rest.WidgetName = "Rest"
self.Rest.dropped.connect(self.pictureDropped)
self.Rest.setMinimumWidth(100)
self.Rest.setMinimumHeight(150)
RestBox = QtWidgets.QGroupBox('Rest')
RestBox.setStyleSheet(self.getStyleSheet(scriptDir + os.path.sep + 'include' + os.path.sep + 'GroupBoxStyle.qss'))
RestLayout = QtWidgets.QGridLayout()
RestLayout.addWidget(self.Rest,0,0,1,1)
RestBox.setLayout(RestLayout)
self.SmallSmile = ThumbNailViewer(self._ModelName, self._SmallSmile)
self.SmallSmile.WidgetName = "SmallSmile"
self.SmallSmile.dropped.connect(self.pictureDropped)
self.SmallSmile.setMinimumWidth(100)
self.SmallSmile.setMinimumHeight(150)
SmallSmileBox = QtWidgets.QGroupBox('Best Smile')
SmallSmileBox.setStyleSheet(self.getStyleSheet(scriptDir + os.path.sep + 'include' + os.path.sep + 'GroupBoxStyle.qss'))
SmallSmileLayout = QtWidgets.QGridLayout()
SmallSmileLayout.addWidget(self.SmallSmile,0,0,1,1)
SmallSmileBox.setLayout(SmallSmileLayout)
self.LargeSmile = ThumbNailViewer(self._ModelName, self._LargeSmile)
self.LargeSmile.WidgetName = "LargeSmile"
self.LargeSmile.dropped.connect(self.pictureDropped)
self.LargeSmile.setMinimumWidth(100)
self.LargeSmile.setMinimumHeight(150)
LargeSmileBox = QtWidgets.QGroupBox('Biggest Smile')
LargeSmileBox.setStyleSheet(self.getStyleSheet(scriptDir + os.path.sep + 'include' + os.path.sep + 'GroupBoxStyle.qss'))
LargeSmileLayout = QtWidgets.QGridLayout()
LargeSmileLayout.addWidget(self.LargeSmile,0,0,1,1)
LargeSmileBox.setLayout(LargeSmileLayout)
self.EyeBrow = ThumbNailViewer(self._ModelName, self._EyeBrow)
self.EyeBrow.WidgetName = "EyeBrow"
self.EyeBrow.dropped.connect(self.pictureDropped)
self.EyeBrow.setMinimumWidth(100)
self.EyeBrow.setMinimumHeight(150)
EyeBrowBox = QtWidgets.QGroupBox('Brow Elevation')
EyeBrowBox.setStyleSheet(self.getStyleSheet(scriptDir + os.path.sep + 'include' + os.path.sep + 'GroupBoxStyle.qss'))
EyeBrowLayout = QtWidgets.QGridLayout()
EyeBrowLayout.addWidget(self.EyeBrow,0,0,1,1)
EyeBrowBox.setLayout(EyeBrowLayout)
self.EyeClosureGently = ThumbNailViewer(self._ModelName, self._EyeClosureGently)
self.EyeClosureGently.WidgetName = "EyeClosureGently"
self.EyeClosureGently.dropped.connect(self.pictureDropped)
self.EyeClosureGently.setMinimumWidth(100)
self.EyeClosureGently.setMinimumHeight(150)
EyeClosureGentlyBox = QtWidgets.QGroupBox('Gentle Eye Closure')
EyeClosureGentlyBox.setStyleSheet(self.getStyleSheet(scriptDir + os.path.sep + 'include' + os.path.sep + 'GroupBoxStyle.qss'))
EyeClosureGentlyLayout = QtWidgets.QGridLayout()
EyeClosureGentlyLayout.addWidget(self.EyeClosureGently,0,0,1,1)
EyeClosureGentlyBox.setLayout(EyeClosureGentlyLayout)
self.EyeClosureTight = ThumbNailViewer(self._ModelName, self._EyeClosureTight)
self.EyeClosureTight.WidgetName = "EyeClosureTight"
self.EyeClosureTight.dropped.connect(self.pictureDropped)
self.EyeClosureTight.setMinimumWidth(100)
self.EyeClosureTight.setMinimumHeight(150)
EyeClosureTightBox = QtWidgets.QGroupBox('Tight Eye Closure')
EyeClosureTightBox.setStyleSheet(self.getStyleSheet(scriptDir + os.path.sep + 'include' + os.path.sep + 'GroupBoxStyle.qss'))
EyeClosureTightLayout = QtWidgets.QGridLayout()
EyeClosureTightLayout.addWidget(self.EyeClosureTight,0,0,1,1)
EyeClosureTightBox.setLayout(EyeClosureTightLayout)
self.PuckeringLips = ThumbNailViewer(self._ModelName, self._PuckeringLips)
self.PuckeringLips.WidgetName = "PuckeringLips"
self.PuckeringLips.dropped.connect(self.pictureDropped)
self.PuckeringLips.setMinimumWidth(100)
self.PuckeringLips.setMinimumHeight(150)
PuckeringLipsBox = QtWidgets.QGroupBox('Pucker Lips')
PuckeringLipsBox.setStyleSheet(self.getStyleSheet(scriptDir + os.path.sep + 'include' + os.path.sep + 'GroupBoxStyle.qss'))
PuckeringLipsLayout = QtWidgets.QGridLayout()
PuckeringLipsLayout.addWidget(self.PuckeringLips,0,0,1,1)
PuckeringLipsBox.setLayout(PuckeringLipsLayout)
self.DentalShow = ThumbNailViewer(self._ModelName, self._DentalShow)
self.DentalShow.WidgetName = "DentalShow"
self.DentalShow.dropped.connect(self.pictureDropped)
self.DentalShow.setMinimumWidth(100)
self.DentalShow.setMinimumHeight(150)
DentalShowBox = QtWidgets.QGroupBox('Show Teeth')
DentalShowBox.setStyleSheet(self.getStyleSheet(scriptDir + os.path.sep + 'include' + os.path.sep + 'GroupBoxStyle.qss'))
DentalShowLayout = QtWidgets.QGridLayout()
DentalShowLayout.addWidget(self.DentalShow,0,0,1,1)
DentalShowBox.setLayout(DentalShowLayout)
#the main window consist of the toolbar and the ImageViewer
#layout = QtWidgets.QVBoxLayout()
layout = QtWidgets.QGridLayout()
#layout.addWidget(self.Rest_title,0,0,1,1)
#layout.addWidget(self.Rest,1,0,1,2)
layout.addWidget(RestBox,0,0,1,1)
layout.addWidget(spacerv,0,1,2,1)
layout.addWidget(EyeBrowBox,0,2,1,1)
layout.addWidget(spacerv,0,3,2,1)
layout.addWidget(EyeClosureGentlyBox,0,4,1,1)
layout.addWidget(spacerv,0,5,2,1)
layout.addWidget(EyeClosureTightBox ,0,6,1,1)
layout.addWidget(spacerh,1,0,1,6)
layout.addWidget(SmallSmileBox,2,0,1,1)
layout.addWidget(LargeSmileBox,2,2,1,1)
layout.addWidget(PuckeringLipsBox,2,4,1,1)
layout.addWidget(DentalShowBox,2,6,1,1)
#toolbar
loadAction = QtWidgets.QAction('Load images from folder', self)
loadAction.setIcon(QtGui.QIcon(scriptDir + os.path.sep + 'include' +os.path.sep +'icon_color'+ os.path.sep + 'load_icon2.png'))
loadAction.triggered.connect(self.load_folder)
saveAction = QtWidgets.QAction('Save results', self)
saveAction.setIcon(QtGui.QIcon(scriptDir + os.path.sep + 'include' +os.path.sep +'icon_color'+ os.path.sep + 'save_icon2.png'))
#saveAction.triggered.connect(self.save_results)
settingsAction = QtWidgets.QAction('Change settings', self)
settingsAction.setIcon(QtGui.QIcon(scriptDir + os.path.sep + 'include' +os.path.sep +'icon_color'+ os.path.sep + 'settings-icon2.png'))
settingsAction.triggered.connect(self.settings)
ReportAction = QtWidgets.QAction('Generate report', self)
ReportAction.setIcon(QtGui.QIcon(scriptDir + os.path.sep + 'include' +os.path.sep +'icon_color'+ os.path.sep + 'report_card.png'))
ReportAction.triggered.connect(self.report_card)
exitAction = QtWidgets.QAction('Exit', self)
exitAction.setIcon(QtGui.QIcon(scriptDir + os.path.sep + 'include' +os.path.sep +'icon_color'+ os.path.sep + 'exit_icon2.png'))
exitAction.triggered.connect(self.close_app)
addImagesAction = QtWidgets.QPushButton(self)
addImagesAction.setIcon(QtGui.QIcon(scriptDir + os.path.sep + 'include' +os.path.sep +'icon_color'+ os.path.sep + 'snapshot_icon.png'))
addImagesAction.setIconSize(QtCore.QSize(40,40))
addImagesAction.setToolTip('Load images from file')
menu = QtWidgets.QMenu()
addRestImage = menu.addAction('Rest')
addRestImage.triggered.connect(lambda state, x = 'Rest': self.load_image(x))
addBrowElevationImage = menu.addAction('Brow Elevation')
addBrowElevationImage.triggered.connect(lambda state, x = 'BrowElevation': self.load_image(x))
addGentleEyeClosureImage = menu.addAction('Gentle Eye Closure')
addGentleEyeClosureImage.triggered.connect(lambda state, x = 'GentleEyeClosureImage': self.load_image(x))
addTightEyeClosureImage = menu.addAction('Tight Eye Closure')
addTightEyeClosureImage.triggered.connect(lambda state, x = 'TightEyeClosureImage': self.load_image(x))
addBestSmileImage = menu.addAction('Best Smile')
addBestSmileImage.triggered.connect(lambda state, x = 'BestSmileImage': self.load_image(x))
addBiggestSmiletImage = menu.addAction('Biggest Smile')
addBiggestSmiletImage.triggered.connect(lambda state, x = 'BiggestSmiletImage': self.load_image(x))
addPuckerLipsImage = menu.addAction('Pucker Lips')
addPuckerLipsImage.triggered.connect(lambda state, x = 'PuckerLipsImage': self.load_image(x))
addShowTeethImage = menu.addAction('Show Teeth')
addShowTeethImage.triggered.connect(lambda state, x = 'ShowTeethImage': self.load_image(x))
menu_font = menu.font()
menu_font.setPointSize(16)
menu.setFont(menu_font)
addImagesAction.setMenu(menu)
#create the toolbar and add the actions
self.toolBar = QtWidgets.QToolBar(self)
self.toolBar.addWidget(addImagesAction)
self.toolBar.addActions((loadAction,ReportAction, saveAction, settingsAction, exitAction))
#set the size of each icon to 50x50
self.toolBar.setIconSize(QtCore.QSize(50,50))
for action in self.toolBar.actions():
widget = self.toolBar.widgetForAction(action)
widget.setFixedSize(50, 50)
self.toolBar.setMinimumSize(self.toolBar.sizeHint())
self.toolBar.setStyleSheet('QToolBar{spacing:5px;}')
LargeLayout = QtWidgets.QVBoxLayout(self)
LargeLayout.addWidget(self.toolBar)
LargeLayout.addLayout(layout)
self.setLayout(LargeLayout)
self.show()
self.move(QtWidgets.QApplication.desktop().screen().rect().center()- self.rect().center())
#this function read the style sheet used to presents the GroupBox,
#it is located in .\include\GroupBoxStyle.qss
def getStyleSheet(self, path):
f = QFile(path)
f.open(QFile.ReadOnly | QFile.Text)
stylesheet = QTextStream(f).readAll()
f.close()
return stylesheet
def load_image(self,image_type):
#load a file using the widget
name,_ = QtWidgets.QFileDialog.getOpenFileName(
self,'Load Image',
'',"Image files (*.png *.jpg *.jpeg *.tif *.tiff *.PNG *.JPG *.JPEG *.TIF *.TIFF)")
if not name:
pass
else:
print(image_type)
#this portion has to be updated once we define the tags for each photo
def load_folder(self):
#the user will provide a folder where all the photos are located, these
#photos will be loaded onto the corresponding boxes
name = QtWidgets.QFileDialog.getExistingDirectory(self, 'Select directory')
if not name:
pass
else:
Files = os.listdir(name)
ext=('.png', '.jpg', '.jpeg', '.bmp','tif', 'tiff', '.PNG', '.JPG', '.JPEG', '.BMP', 'TIF', 'TIFF')
Files = [i for i in Files if i.endswith(tuple(ext))]
#and sort them
Files.sort()
#let's verify that at least one valid image exists in the folder, if that is the case then we need to clean up the
#screen and empty all infor from previous patient from memory
new_patient = False #variable that will indicate if any of the images are in the folder, in that case a new patient should be created
#Tags used to identify each photo. These tags can be updated later on!!!!!
tag_Rest = '1'
tag_EyeBrow = '2'
tag_EyeClosureGently ='3'
tag_EyeClosureTight ='4'
tag_SmallSmile = '5'
tag_LargeSmile ='6'
tag_PuckeringLips ='7'
tag_DentalShow ='8'
for file in Files:
#search for tags in local files.
if tag_Rest in file:
new_patient = True
elif tag_EyeBrow in file:
new_patient = True
elif tag_EyeClosureGently in file:
new_patient = True
elif tag_EyeClosureTight in file:
new_patient = True
elif tag_SmallSmile in file:
new_patient = True
elif tag_LargeSmile in file:
new_patient = True
elif tag_PuckeringLips in file:
new_patient = True
elif tag_DentalShow in file:
new_patient = True
if new_patient :
#reset everything
self._Rest = PatientPhotograph()
self._SmallSmile = PatientPhotograph()
self._LargeSmile = PatientPhotograph()
self._EyeBrow = PatientPhotograph()
self._EyeClosureGently = PatientPhotograph()
self._EyeClosureTight = PatientPhotograph()
self._PuckeringLips = PatientPhotograph()
self._DentalShow = PatientPhotograph()
self._Patient = Patient() #this variable contains information about all photos
#these are the windows that will show the Emotris app
self.show_me_rest = None
self.show_me_smallsmile = None
self.show_me_largesmile = None
self.show_me_eyebrow = None
self.show_me_eyeclosuregently = None
self.show_me_eyeclosuretight= None
self.show_me_puckeringlips = None
self.show_me_dentalshow = None
#update with new information located in the folder
for file in Files:
#search for tags in local files.
if tag_Rest in file:
self.Rest.setBackground()
self.Rest.picture_loaded(name + os.path.sep + file, 'Rest')
elif tag_EyeBrow in file:
self.EyeBrow.setBackground()
self.EyeBrow.picture_loaded(name + os.path.sep + file, 'EyeBrow')
elif tag_EyeClosureGently in file:
self.EyeClosureGently.setBackground()
self.EyeClosureGently.picture_loaded(name + os.path.sep + file, 'EyeClosureGently')
elif tag_EyeClosureTight in file:
self.EyeClosureTight.setBackground()
self.EyeClosureTight.picture_loaded(name + os.path.sep + file, 'EyeClosureTight')
elif tag_SmallSmile in file:
self.SmallSmile.setBackground()
self.SmallSmile.picture_loaded(name + os.path.sep + file, 'SmallSmile')
elif tag_LargeSmile in file:
self.LargeSmile.setBackground()
self.LargeSmile.picture_loaded(name + os.path.sep + file, 'LargeSmile')
elif tag_PuckeringLips in file:
self.PuckeringLips.setBackground()
self.PuckeringLips.picture_loaded(name + os.path.sep + file, 'PuckeringLips')
elif tag_DentalShow in file:
self.DentalShow.setBackground()
self.DentalShow.picture_loaded(name + os.path.sep + file, 'DentalShow')
else:
pass
def pictureDropped(self, photograph):
# print(photograph._file_name)
# show_me = Emotrics(photograph, self._CalibrationType, self._CalibrationValue)
# show_me.exec_()
#
# print(photograph._ID)
#user if adding photos from new patient, remove informaiton from previous patient
if photograph._NewPatient:
self._Patient = Patient() #this variable contains information about all photos
if photograph._ID == "Rest":
#the user wants to modify the Rest photo
#verify that the window is not already open
if self.show_me_rest is not None:
self.show_me_rest.close() #if it is, close it
if photograph._OpenEmotrics is True: #Emotrics should be open
self.show_me_rest = Emotrics(photograph, self._CalibrationType, self._CalibrationValue)
self.show_me_rest.exec_()
self._Rest._photo = photograph._photo
self._Rest._file_name = photograph._file_name
self._Rest._name = photograph._name
self._Rest._extension = photograph._extension
self._Rest._ID = photograph._ID
self._Rest._shape = self.show_me_rest.displayImage._shape
self._Rest._lefteye = self.show_me_rest.displayImage._lefteye
self._Rest._righteye = self.show_me_rest.displayImage._righteye
self._Rest._points = self.show_me_rest.displayImage._points
self._Rest._boundingbox = self.show_me_rest.displayImage._boundingbox
#modify thumbnail view to indicate that landmark position information is now avaliable
self.Rest.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(204,255,204)))
#the window is now closed, let's remove it from memory
self.show_me_rest = None
else:
#Emotrics doesn't need to be open, all the information is already avaliable
self._Rest._photo = photograph._photo
self._Rest._file_name = photograph._file_name
self._Rest._name = photograph._name
self._Rest._extension = photograph._extension
self._Rest._ID = photograph._ID
self._Rest._shape = photograph._shape
self._Rest._lefteye = photograph._lefteye
self._Rest._righteye = photograph._righteye
self._Rest._points = photograph._points
self._Rest._boundingbox = photograph._boundingbox
elif photograph._ID == "SmallSmile":
#the user wants to modify the small smile photo
#verify that the window is not already open
if self.show_me_smallsmile is not None:
self.show_me_smallsmile.close() #if it is, close it
if photograph._OpenEmotrics is True: #Emotrics should be open
self.show_me_smallsmile = Emotrics(photograph, self._CalibrationType, self._CalibrationValue)
self.show_me_smallsmile.exec_()
self._SmallSmile._photo = photograph._photo
self._SmallSmile._file_name = photograph._file_name
self._SmallSmile._name = photograph._name
self._SmallSmile._extension = photograph._extension
self._SmallSmile._ID = photograph._ID
self._SmallSmile._shape = self.show_me_smallsmile.displayImage._shape
self._SmallSmile._lefteye = self.show_me_smallsmile.displayImage._lefteye
self._SmallSmile._righteye = self.show_me_smallsmile.displayImage._righteye
self._SmallSmile._points = self.show_me_smallsmile.displayImage._points
self._SmallSmile._boundingbox = self.show_me_smallsmile.displayImage._boundingbox
#modify thumbnail view to indicate that landmark position information is now avaliable
self.SmallSmile.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(204,255,204)))
#the window is now closed, let's remove it from memory
self.show_me_smallsmile = None
else:
#Emotrics doesn't need to be open, all the information is already avaliable
self._SmallSmile._photo = photograph._photo
self._SmallSmile._file_name = photograph._file_name
self._SmallSmile._name = photograph._name
self._SmallSmile._extension = photograph._extension
self._SmallSmile._ID = photograph._ID
self._SmallSmile._shape = photograph._shape
self._SmallSmile._lefteye = photograph._lefteye
self._SmallSmile._righteye = photograph._righteye
self._SmallSmile._points = photograph._points
self._SmallSmile._boundingbox = photograph._boundingbox
elif photograph._ID == "LargeSmile":
#the user wants to modify the large smile photo
#verify that the window is not already open
if self.show_me_largesmile is not None:
self.show_me_largesmile.close() #if it is, close it
if photograph._OpenEmotrics is True: #Emotrics should be open
self.show_me_largesmile = Emotrics(photograph, self._CalibrationType, self._CalibrationValue)
self.show_me_largesmile.exec_()
self._LargeSmile._photo = photograph._photo
self._LargeSmile._file_name = photograph._file_name
self._LargeSmile._name = photograph._name
self._LargeSmile._extension = photograph._extension
self._LargeSmile._ID = photograph._ID
self._LargeSmile._shape = self.show_me_largesmile.displayImage._shape
self._LargeSmile._lefteye = self.show_me_largesmile.displayImage._lefteye
self._LargeSmile._righteye = self.show_me_largesmile.displayImage._righteye
self._LargeSmile._points = self.show_me_largesmile.displayImage._points
self._LargeSmile._boundingbox = self.show_me_largesmile.displayImage._boundingbox
#modify thumbnail view to indicate that landmark position information is now avaliable
self.LargeSmile.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(204,255,204)))
#the window is now closed, let's remove it from memory
self.show_me_largesmile = None
else:
#Emotrics doesn't need to be open, all the information is already avaliable
self._LargeSmile._photo = photograph._photo
self._LargeSmile._file_name = photograph._file_name
self._LargeSmile._name = photograph._name
self._LargeSmile._extension = photograph._extension
self._LargeSmile._ID = photograph._ID
self._LargeSmile._shape = photograph._shape
self._LargeSmile._lefteye = photograph._lefteye
self._LargeSmile._righteye = photograph._righteye
self._LargeSmile._points = photograph._points
self._LargeSmile._boundingbox = photograph._boundingbox
elif photograph._ID == "EyeBrow":
#the user wants to modify the eye brow photo
#verify that the window is not already open
if self.show_me_eyebrow is not None:
self.show_me_eyebrow.close() #if it is, close it
if photograph._OpenEmotrics is True: #Emotrics should be open
self.show_me_eyebrow = Emotrics(photograph, self._CalibrationType, self._CalibrationValue)
self.show_me_eyebrow.exec_()
self._EyeBrow._photo = photograph._photo
self._EyeBrow._file_name = photograph._file_name
self._EyeBrow._name = photograph._name
self._EyeBrow._extension = photograph._extension
self._EyeBrow._ID = photograph._ID
self._EyeBrow._shape = self.show_me_eyebrow.displayImage._shape
self._EyeBrow._lefteye = self.show_me_eyebrow.displayImage._lefteye
self._EyeBrow._righteye = self.show_me_eyebrow.displayImage._righteye
self._EyeBrow._points = self.show_me_eyebrow.displayImage._points
self._EyeBrow._boundingbox = self.show_me_eyebrow.displayImage._boundingbox
#modify thumbnail view to indicate that landmark position information is now avaliable
self.EyeBrow.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(204,255,204)))
#the window is now closed, let's remove it from memory
self.show_me_eyebrow = None
else:
#Emotrics doesn't need to be open, all the information is already avaliable
self._EyeBrow._photo = photograph._photo
self._EyeBrow._file_name = photograph._file_name
self._EyeBrow._name = photograph._name
self._EyeBrow._extension = photograph._extension
self._EyeBrow._ID = photograph._ID
self._EyeBrow._shape = photograph._shape
self._EyeBrow._lefteye = photograph._lefteye
self._EyeBrow._righteye = photograph._righteye
self._EyeBrow._points = photograph._points
self._EyeBrow._boundingbox = photograph._boundingbox
elif photograph._ID == "EyeClosureGently":
#the user wants to modify the gentle eye closure photo
#verify that the window is not already open
if self.show_me_eyeclosuregently is not None:
self.show_me_eyeclosuregently.close() #if it is, close it
if photograph._OpenEmotrics is True: #Emotrics should be open
self.show_me_eyeclosuregently = Emotrics(photograph, self._CalibrationType, self._CalibrationValue)
self.show_me_eyeclosuregently.exec_()
self._EyeClosureGently._photo = photograph._photo
self._EyeClosureGently._file_name = photograph._file_name
self._EyeClosureGently._name = photograph._name
self._EyeClosureGently._extension = photograph._extension
self._EyeClosureGently._ID = photograph._ID
self._EyeClosureGently._shape = self.show_me_eyeclosuregently.displayImage._shape
self._EyeClosureGently._lefteye = self.show_me_eyeclosuregently.displayImage._lefteye
self._EyeClosureGently._righteye = self.show_me_eyeclosuregently.displayImage._righteye
self._EyeClosureGently._points = self.show_me_eyeclosuregently.displayImage._points
self._EyeClosureGently._boundingbox = self.show_me_eyeclosuregently.displayImage._boundingbox
#modify thumbnail view to indicate that landmark position information is now avaliable
self.EyeClosureGently.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(204,255,204)))
#the window is now closed, let's remove it from memory
self.show_me_eyeclosuregently = None
else:
#Emotrics doesn't need to be open, all the information is already avaliable
self._EyeClosureGently._photo = photograph._photo
self._EyeClosureGently._file_name = photograph._file_name
self._EyeClosureGently._name = photograph._name
self._EyeClosureGently._extension = photograph._extension
self._EyeClosureGently._ID = photograph._ID
self._EyeClosureGently._shape = photograph._shape
self._EyeClosureGently._lefteye = photograph._lefteye
self._EyeClosureGently._righteye = photograph._righteye
self._EyeClosureGently._points = photograph._points
self._EyeClosureGently._boundingbox = photograph._boundingbox
elif photograph._ID == "EyeClosureTight":
#the user wants to modify the tight eye closure photo
#verify that the window is not already open
if self.show_me_eyeclosuretight is not None:
self.show_me_eyeclosuretight.close() #if it is, close it
if photograph._OpenEmotrics is True: #Emotrics should be open
self.show_me_eyeclosuretight = Emotrics(photograph, self._CalibrationType, self._CalibrationValue)
self.show_me_eyeclosuretight.exec_()
self._EyeClosureTight._photo = photograph._photo
self._EyeClosureTight._file_name = photograph._file_name
self._EyeClosureTight._name = photograph._name
self._EyeClosureTight._extension = photograph._extension
self._EyeClosureTight._ID = photograph._ID
self._EyeClosureTight._shape = self.show_me_eyeclosuretight.displayImage._shape
self._EyeClosureTight._lefteye = self.show_me_eyeclosuretight.displayImage._lefteye
self._EyeClosureTight._righteye = self.show_me_eyeclosuretight.displayImage._righteye
self._EyeClosureTight._points = self.show_me_eyeclosuretight.displayImage._points
self._EyeClosureTight._boundingbox = self.show_me_eyeclosuretight.displayImage._boundingbox
#modify thumbnail view to indicate that landmark position information is now avaliable
self.EyeClosureTight.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(204,255,204)))
#the window is now closed, let's remove it from memory
self.show_me_eyeclosuretight = None
else:
#Emotrics doesn't need to be open, all the information is already avaliable
self._EyeClosureTight._photo = photograph._photo
self._EyeClosureTight._file_name = photograph._file_name
self._EyeClosureTight._name = photograph._name
self._EyeClosureTight._extension = photograph._extension
self._EyeClosureTight._ID = photograph._ID
self._EyeClosureTight._shape = photograph._shape
self._EyeClosureTight._lefteye = photograph._lefteye
self._EyeClosureTight._righteye = photograph._righteye
self._EyeClosureTight._points = photograph._points
self._EyeClosureTight._boundingbox = photograph._boundingbox
elif photograph._ID == "PuckeringLips":
#the user wants to modify the puckering lips photo
#verify that the window is not already open
if self.show_me_puckeringlips is not None:
self.show_me_puckeringlips.close() #if it is, close it
if photograph._OpenEmotrics is True: #Emotrics should be open
self.show_me_puckeringlips = Emotrics(photograph, self._CalibrationType, self._CalibrationValue)
self.show_me_puckeringlips.exec_()
self._PuckeringLips._photo = photograph._photo
self._PuckeringLips._file_name = photograph._file_name
self._PuckeringLips._name = photograph._name
self._PuckeringLips._extension = photograph._extension
self._PuckeringLips._ID = photograph._ID
self._PuckeringLips._shape = self.show_me_puckeringlips.displayImage._shape
self._PuckeringLips._lefteye = self.show_me_puckeringlips.displayImage._lefteye
self._PuckeringLips._righteye = self.show_me_puckeringlips.displayImage._righteye
self._PuckeringLips._points = self.show_me_puckeringlips.displayImage._points
self._PuckeringLips._boundingbox = self.show_me_puckeringlips.displayImage._boundingbox
#modify thumbnail view to indicate that landmark position information is now avaliable
self.PuckeringLips.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(204,255,204)))
#the window is now closed, let's remove it from memory
self.show_me_puckeringlips = None
else:
#Emotrics doesn't need to be open, all the information is already avaliable
self._PuckeringLips._photo = photograph._photo
self._PuckeringLips._file_name = photograph._file_name
self._PuckeringLips._name = photograph._name
self._PuckeringLips._extension = photograph._extension
self._PuckeringLips._ID = photograph._ID
self._PuckeringLips._shape = photograph._shape
self._PuckeringLips._lefteye = photograph._lefteye
self._PuckeringLips._righteye = photograph._righteye
self._PuckeringLips._points = photograph._points
self._PuckeringLips._boundingbox = photograph._boundingbox
elif photograph._ID == "DentalShow":
#the user wants to modify the deltal show photo
#verify that the window is not already open
if self.show_me_dentalshow is not None:
self.show_me_dentalshow.close() #if it is, close it
if photograph._OpenEmotrics is True: #Emotrics should be open
self.show_me_dentalshow = Emotrics(photograph, self._CalibrationType, self._CalibrationValue)
self.show_me_dentalshow.exec_()
self._DentalShow._photo = photograph._photo
self._DentalShow._file_name = photograph._file_name
self._DentalShow._name = photograph._name
self._DentalShow._extension = photograph._extension
self._DentalShow._ID = photograph._ID
self._DentalShow._shape = self.show_me_dentalshow.displayImage._shape
self._DentalShow._lefteye = self.show_me_dentalshow.displayImage._lefteye
self._DentalShow._righteye = self.show_me_dentalshow.displayImage._righteye
self._DentalShow._points = self.show_me_dentalshow.displayImage._points
self._DentalShow._boundingbox = self.show_me_dentalshow.displayImage._boundingbox
#modify thumbnail view to indicate that landmark position information is now avaliable
self.DentalShow.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(204,255,204)))
#the window is now closed, let's remove it from memory
self.show_me_dentalshow = None
else:
#Emotrics doesn't need to be open, all the information is already avaliable
self._DentalShow._photo = photograph._photo
self._DentalShow._file_name = photograph._file_name
self._DentalShow._name = photograph._name
self._DentalShow._extension = photograph._extension
self._DentalShow._ID = photograph._ID
self._DentalShow._shape = photograph._shape
self._DentalShow._lefteye = photograph._lefteye
self._DentalShow._righteye = photograph._righteye
self._DentalShow._points = photograph._points
self._DentalShow._boundingbox = photograph._boundingbox
def report_card(self):
# if self._Rest._shape is None or self._SmallSmile._shape is None or self._LargeSmile._shape is None or self._EyeBrow._shape is None or self._EyeClosureGently._shape is None or self._EyeClosureTight._shape is None or self._DentalShow._shape is None:
#
# QtWidgets.QMessageBox.warning(self,"Warning",
# "Landmark information from some images is still missing.\nDouble click in a photograph to estimate the landmarks.",
# QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.NoButton)
#
# else:
# #lets update the information about all the photos and pass it to
# #the part of the program that will do all the calculations
# self._Patient._Rest = self._Rest
# self._Patient._SmallSmile = self._SmallSmile
# self._Patient._LargeSmile = self._LargeSmile
# self._Patient._EyeBrow = self._EyeBrow
# self._Patient._EyeClosureGently = self._EyeClosureGently
# self._Patient._EyeClosureTight = self._EyeClosureTight
# self._Patient._PuckeringLips = self._PuckeringLips
# self._Patient._DentalShow = self._DentalShow
#
# self._Patient._CalibrationType = self._CalibrationType
# self._Patient._CalibrationValue = self._CalibrationValue
# self._Patient._ModelName = self._ModelName
#
#
#
# ReportC = ReportCardInit(self._Patient)
# ReportC.exec_()
# I modified this function on 1/4/2020 to reflect the fact that the program doesn't need the SmallSmilePhoto
# code before this comment uses requires the information for the SmallSmilePhoto
#if self._Rest._shape is None or self._SmallSmile._shape is None or self._LargeSmile._shape is None or self._EyeBrow._shape is None or self._EyeClosureGently._shape is None or self._EyeClosureTight._shape is None or self._DentalShow._shape is None:
if self._Rest._shape is None or self._LargeSmile._shape is None or self._EyeBrow._shape is None or self._EyeClosureGently._shape is None or self._EyeClosureTight._shape is None or self._DentalShow._shape is None:
QtWidgets.QMessageBox.warning(self,"Warning",
"Landmark information from some images is still missing.\nDouble click in a photograph to estimate the landmarks.",
QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.NoButton)
else:
#lets update the information about all the photos and pass it to
#the part of the program that will do all the calculations
self._Patient._Rest = self._Rest
#self._Patient._SmallSmile = self._SmallSmile
self._Patient._LargeSmile = self._LargeSmile
self._Patient._EyeBrow = self._EyeBrow
self._Patient._EyeClosureGently = self._EyeClosureGently
self._Patient._EyeClosureTight = self._EyeClosureTight
self._Patient._PuckeringLips = self._PuckeringLips
self._Patient._DentalShow = self._DentalShow
self._Patient._CalibrationType = self._CalibrationType
self._Patient._CalibrationValue = self._CalibrationValue
self._Patient._ModelName = self._ModelName
ReportC = ReportCardInit(self._Patient)
ReportC.exec_()
def settings(self):
#this new window allows the user to:
#1) modify the calibration parameter used to compute all the real-life measurements
#2) Select the model used for landmakr estimation
#we send the current values to the window so that the values can be preserved when a new photo is loaded
Settings = ShowSettings(self, self._ModelName, self._CalibrationType, self._CalibrationValue)
Settings.exec_()
#get values from the window and update appropiate parameters
if Settings.tab1._checkBox1.isChecked() == True:
self._CalibrationType = 'Iris'
self._CalibrationValue = float(Settings.tab1._IrisDiameter_Edit.text())
elif Settings.tab1._checkBox2.isChecked() == True:
self._CalibrationType = 'Manual'
self._CalibrationValue = float(Settings.tab1._Personalized_Edit.text())
if Settings.tab2._checkBox2.isChecked() == True:
self._ModelName = 'iBUG'
elif Settings.tab2._checkBox1.isChecked() == True:
self._ModelName = 'MEE'
def close_app(self):
#ask is the user really wants to close the app
choice = QtWidgets.QMessageBox.question(self, 'Message',
'Do you want to exit?', QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No)
if choice == QtWidgets.QMessageBox.Yes :
self.close()
app.exec_()
else:
pass
def closeEvent(self, event):
event.accept()
#verify if any of the Emotrics windows in still open
if self.show_me_rest is not None:
self.show_me_rest.close() #if it is, close it
if self.show_me_smallsmile is not None:
self.show_me_smallsmile.close() #if it is, close it
if self.show_me_largesmile is not None:
self.show_me_largesmile.close() #if it is, close it
if self.show_me_eyebrow is not None:
self.show_me_eyebrow.close() #if it is, close it
if self.show_me_eyeclosuregently is not None:
self.show_me_eyeclosuregently.close() #if it is, close it
if self.show_me_eyeclosuretight is not None:
self.show_me_eyeclosuretight.close() #if it is, close it
if self.show_me_puckeringlips is not None:
self.show_me_puckeringlips.close() #if it is, close it
if self.show_me_dentalshow is not None:
self.show_me_dentalshow.close() #if it is, close it
if __name__ == '__main__':
if not QtWidgets.QApplication.instance():
app = QtWidgets.QApplication(sys.argv)
else:
app = QtWidgets.QApplication.instance()
app.setStyle(QtWidgets.QStyleFactory.create('Cleanlooks'))
GUI = window()
GUI.show()
app.exec_()