class MainWindow(QMainWindow): def __init__(self, camera): super().__init__() self.title = "3DMM" # self.setWindowIcon(QtGui.QIcon('images/1UP.ico')) # self.setFixedSize(1200, 700) # self.setGeometry(500, 100, 1200, 700) # self.right_label = RightLabel(self, self.model) self.camera = camera self.main_widget = MainWidget(self.camera, True) # self.initUI() def initUI(self): count = 0 # self.addToolBarBreak() def activate(self): self.main_widget.activate() def deactivate(self): self.main_widget.deactivate() def closeEvent(self, event): self.camera.deactivate() self.main_widget.deactivate() event.accept()
class MainWindow(QMainWindow): def __init__(self, expression_to_neutral=False): super().__init__() self.expression_to_neutral = expression_to_neutral if self.expression_to_neutral: self.title = "From Expression to Neutral" else: self.title = "3DMM" self.setWindowIcon(QtGui.QIcon('images/1UP.ico')) self.setFixedSize(1200, 700) self.camera = Camera() self.progress_bar = QProgressBar(self) self.count = 0 self.toolbar = self.addToolBar('Main Window') # self.toolbar_emotions = self.addToolBar('Emotions') self.expression = "neutral" self.picture_taken = False self.bool_onclick = None self.portrait = None self.model = Model(None, self.expression, self, self.expression_to_neutral) self.video_widget = VideoWidget(self.camera) self.right_label = RightLabel(self, self.model) self.main_widget = MainWidget(self.video_widget, self.right_label, self.camera) self.setCentralWidget(self.main_widget) self.model.progress_bar.connect(self.set_progress_bar, type=Qt.QueuedConnection) self.combo_box = QComboBox(self) self.initUI() def initUI(self): self.build_toolbar() # self.addToolBarBreak() def get_expression(self): return self.expression def get_bool_onclick(self): return self.bool_onclick def get_combo_box(self): return self.combo_box def set_progress_bar(self): if self.count <= 2: self.progress_bar.setValue(self.count * 50) self.count = self.count + 1 return self.count = 0 self.set_progress_bar() def build_toolbar(self): slide_bar = QSlider(Qt.Horizontal) slide_bar.setMinimum(0) slide_bar.setMaximum(8) slide_bar.setValue(3) slide_bar.valueChanged.connect(self.camera.setZoom) self.toolbar.addWidget(slide_bar) take_photo = QAction(QIcon('images/get_photo.png'), 'Take_Picture', self) take_photo.setShortcut('Ctrl+Q') take_photo.triggered.connect(self.on_click) self.toolbar.addAction(take_photo) # self.progress_bar.setHidden(True) self.toolbar.addWidget(self.progress_bar) self.toolbar.addSeparator() # build slide fo upload pre-built patterns.looking for the pattern class if self.expression_to_neutral: self.combo_box.addItem("Face") else: self.combo_box.addItem("Neutral") self.combo_box.addItem("Surprise") self.combo_box.addItem("Happy") self.combo_box.addItem("Contempt") self.combo_box.addItem("Sadness") self.combo_box.addItem("Disgust") self.combo_box.addItem("Angry") self.combo_box.addItem("Fear") self.toolbar.addWidget(self.combo_box) self.combo_box.activated[str].connect(self.combo_changed) self.toolbar.addSeparator() def activate(self): self.main_widget.activate() self.show() def deactivate(self): self.main_widget.deactivate() def closeEvent(self, event): self.camera.deactivate() self.main_widget.deactivate() event.accept() def on_click(self): # self.progress_bar.setHidden(False) self.picture_taken = True self.bool_onclick = True self.portrait = self.camera.get_current_frame() self.portrait = resizeImage(self.portrait, 600) image = ndimage.gaussian_filter(self.portrait, sigma=(1.3, 1.3, 0), order=0) image = Image.fromarray(image) scipy.misc.imsave('expression_code/imgs/outfile.jpg', image) self.model.set_image('expression_code/imgs/outfile.jpg') self.right_label.activate() def combo_changed(self, text): self.bool_onclick = False self.expression = text.lower() if self.picture_taken: self.right_label.activate()
glLightfv(GL_LIGHT0, GL_POSITION, (-40, 200, 100, 0.0)) glLightfv(GL_LIGHT0, GL_AMBIENT, (0.2, 0.2, 0.2, 1.0)) glLightfv(GL_LIGHT0, GL_DIFFUSE, (0.5, 0.5, 0.5, 1.0)) glEnable(GL_LIGHT0) glEnable(GL_LIGHTING) glEnable(GL_COLOR_MATERIAL) glEnable(GL_DEPTH_TEST) glShadeModel(GL_SMOOTH) glTranslate(0, -2, -5) glRotatef(1, 70, 70, 1) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() mainWid.deactivate() sys.exit(app.exec_()) quit() # glRotatef(1, 3, 1, 1) nose = frontal_camera.get_nose() scale = frontal_camera.get_scale() frame_shape = frontal_camera.get_current_frame() if nose is not None and (nose[0] != nose_tmp[0] or nose[1] != nose_tmp[1]): z1 = z z = scale[2] if abs(z) < 2000: z = 2000 elif abs(z) > 8500: