Beispiel #1
0
    def run(self):
        # self.finishSignal.emit([1, 2, 3])

        self.pwin.have_check_in_num += 1

        self.pwin.add_log(
            '[%s] Student [%s] checked succeed.' %
            (get_current_time(), self.student_info.get('name', self.uid)))
        checked_voice(self.uid)
Beispiel #2
0
    def close_camera(self):
        """关闭相机"""
        self.add_log('[%s] Close camera.' % get_current_time())
        if not self.camera.isOpened():
            show_dialog('Warn', 'Please open camera first')
        else:
            self.camera_timer.stop()
            self.camera.release()
            self.ui.camera_area.setText('Camera')

            self.close_others()
Beispiel #3
0
 def start_check_in(self):
     """开始签到"""
     self.add_log(
         '[%s] %s check in.' %
         (get_current_time(), 'Stop' if self.check_in_flag else 'Start'))
     if not self.camera.isOpened():
         show_dialog('Warn', 'Please open camera first')
     else:
         self.check_in_flag = not self.check_in_flag
         self.ui.start_check_in_btn.setText(
             '%s Check In' % ('Stop' if self.check_in_flag else 'Start'))
Beispiel #4
0
 def open_face_rectangle(self):
     """打开/关闭人脸框"""
     self.add_log('[%s] %s face rectangle.' %
                  (get_current_time(),
                   'Close' if self.face_rectangle_flag else 'Open'))
     if not self.camera.isOpened():
         show_dialog('Warn', 'Please open camera first')
     else:
         self.face_rectangle_flag = not self.face_rectangle_flag
         self.ui.face_rect_btn.setText(
             '%s Face' % ('Close' if self.face_rectangle_flag else 'Open'))
Beispiel #5
0
 def manual_check_in(self, connect):
     """手动签到,为那些没有录入数据的用户保留"""
     if not self.check_in_flag:
         show_dialog('Warn', 'Please start check in first.')
     else:
         checkWithSid(sid=connect, time=datetime2str(datetime.now()))
         self.have_check_in_num += 1
         show_dialog('Success',
                     'Student %s check in by manual success.' % connect)
         self.add_log('[%s] Student %s check in by manual success.' %
                      (get_current_time(), connect))
         self.ui.check_in_num.display(self.have_check_in_num)
Beispiel #6
0
    def __init__(self):
        """
        face_rectangle_flag: 是否打开人脸方框
        have_check_in_num: 已经签到的人数
        face_cascade: 检测文件
        """
        super().__init__()

        self.ui = Ui_FaceR_Client()
        self.ui.setupUi(self)

        self.add_log('[%s] System initialization in progress.' %
                     get_current_time())
        self.init()

        self.camera_timer = QTimer()
        # 网络摄像头
        # self.camera = cv2.VideoCapture("http://*****:*****@192.168.137.76:8081/")
        self.camera = cv2.VideoCapture(0, cv2.CAP_DSHOW)
        # 分辨率
        self.camera.set(cv2.CAP_PROP_FRAME_WIDTH, 1366)
        self.camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 768)

        self.face_cascade = cv2.CascadeClassifier(
            os.path.split(os.path.split(os.path.realpath(__file__))[0])[0] +
            '/static/xml/haarcascade_frontalface_default.xml')
        self.face_rectangle_flag = False

        self.check_in_flag = False
        self.have_check_in_num = 0

        self.algorithm = 'MTCNN-Plus'
        self.face_locations = []

        self.init_bind_event()

        # 先把相机关了
        self.close_camera()
        self.add_log('[%s] System initialization succeed.' %
                     get_current_time())
Beispiel #7
0
    def export_result(self):
        try:
            # 导出excel
            filepath = QFileDialog.getSaveFileName(
                self, "Save File",
                os.path.join(os.path.expanduser("~"),
                             'Desktop/1559117605.zip'), "Zip (*.zip);;")[0]

            with open(filepath, 'wb') as f:
                f.write(
                    requests.get(
                        'https://facer.yingjoy.cn/static/analyse/1559117605.zip'
                    ).content)

            show_dialog('Success', 'Export data success.')

            self.add_log('[%s] Export result succeed.' % get_current_time())

        except Exception as e:
            show_dialog('Warn', 'Export fail.')
            self.add_log('[%s] Export result fail.' % get_current_time())
            print(e)
Beispiel #8
0
 def open_camera(self):
     """打开摄像头"""
     self.add_log('[%s] Open camera.' % get_current_time())
     self.ui.camera_area.setText('Waiting...')
     flag = self.camera.open(0)
     if not flag:
         QtWidgets.QMessageBox.warning(
             self,
             u"Warning",
             u"没有检测到相机",
             buttons=QtWidgets.QMessageBox.Ok,
             defaultButton=QtWidgets.QMessageBox.Ok)
     self.camera_timer.start(20)
Beispiel #9
0
 def upload_result(self):
     """上传结果到服务器,后面再写吧"""
     show_dialog('Success', 'Upload result success.')
     self.add_log('[%s] Upload result success.' % get_current_time())