Ejemplo n.º 1
0
  def register_face(self):
    name = self.ui.nameInput.text()
    if name == '':
      msg_box = QMessageBox()
      msg_box.setIcon(QMessageBox.Critical)
      msg_box.warning(self, 'Error', 'Person name cannot be empty!')
      return

    confirm_msg = 'Register face of {:s} into {:s}?'.format(name,
                                                           self.cur_face_registry)
    reply = QMessageBox.question(self, 'Register face', confirm_msg,
                                   QMessageBox.No, QMessageBox.Yes)
    if reply == QMessageBox.Yes:
      logger.info('Registering {:s}'.format(name))
      try:
        self.face_recognizer.register_face(self.cur_face_registry,
                                           self.cur_saved_image_path, name)
        self.parent().ui.statusbar.showMessage(
          'Successfully registered the face', 2000)

      except Exception as e:
        msg_box = QMessageBox()
        msg_box.setIcon(QMessageBox.Critical)
        msg_box.warning(self, 'Error', str(e))
      # Clean up the captured image and show the video stream again
      self.ui.nameInput.clear()
      # self.ui.nameInput.setText('')
      self.retake_picture()
    else:
      pass
Ejemplo n.º 2
0
 def register_faces(self):
     self.stop_camera()
     registration_dialog = FaceRegistrationView(
         parent=self, face_recognizer=self.face_recognizer)
     registration_dialog.exec_()
     logger.info('Done registering faces')
     self.start_camera()
Ejemplo n.º 3
0
 def setup_opencv_camera(self):
     if len(QCamera.availableDevices()) > 0:
         camera_addr = str(QCamera.availableDevices()[0])
         self.camera = cv2.VideoCapture(0)
         if self.camera.isOpened():
             self.camera.set(cv2.CAP_PROP_BUFFERSIZE, 1)
             self.camera.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
             self.camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
             logger.info('Opened the camera {}'.format(camera_addr))
         else:
             logger.error(
                 'Failed to open the camera {}'.format(camera_addr))
Ejemplo n.º 4
0
  def create_registry(self):
    name = self.ui.registryNameInput.text()
    if name == '':
      self.msg_box.setIcon(QMessageBox.Critical)
      self.msg_box.warning(self, 'Error', 'Album name cannot be empty!')
      return

    name = name.replace(' ', '_')
    confirm_msg = 'Are you sure that you want to create album {}?'.format(name)
    reply = QMessageBox.question(self, 'Create album', confirm_msg,
                                 QMessageBox.Yes, QMessageBox.No)
    if reply == QMessageBox.Yes:
      print('Creating registry {}'.format(name))
      registry = self.face_recognizer.create_face_registry(name)
      if registry is not None:
        logger.info('Successfully created face registry {}'.format(registry))
    self.close()
Ejemplo n.º 5
0
 def delete_current_picture(self):
   if self.cur_saved_image_path is not None:
     if os.path.exists(self.cur_saved_image_path):
       os.remove(self.cur_saved_image_path)
       logger.info('Deleted {}'.format(self.cur_saved_image_path))
     self.cur_saved_image_path = None
Ejemplo n.º 6
0
 def reject(self):
   self.camera.stop()
   logger.info('Cleaning up captured images...')
   self.delete_current_picture()
   QDialog.reject(self)
Ejemplo n.º 7
0
 def image_saved(self, id, file_path):
   self.cur_saved_image_path = file_path
   logger.info('Image saved at {}'.format(file_path))
Ejemplo n.º 8
0
 def stop(self):
     self.timer.stop()
     logger.info('Stopping the app')
     self.running = False
     self.stop_camera()