Example #1
0
    def messFault(self):
        print("self.flg", self.flg)
        self.flg = self.flg + 1
        if self.flg == 1:
            # name_sex只返回一个结果
            name_sex = teacher_data.search_teacher(mydb,
                                                   self.retname[1])  # 查询姓名性别
            userid = name_sex[0][0]
            username = name_sex[0][1]
            # 显示至界面
            globVar.load_Face(userid)
            identityImage = QtGui.QImage('buffImage.jpg')
            fitImage = identityImage.scaled(256,
                                            256,
                                            aspectRatioMode=Qt.KeepAspectRatio)
            self.identityView.setPixmap(QPixmap.fromImage(fitImage))

            self.nameText.setText(username)
            self.IDText.setText(userid)

            self.id_print = userid
            self.name_print = username
            # self.teacher_id = userid
            self.teacher_id = name_sex[0][0]
            self.teacher_sex = name_sex[0][2]
        if self.flg == 2:
            # name_sex只返回一个结果
            name_sex = teacher_data.search_teacher(mydb,
                                                   self.retname[2])  # 查询姓名性别
            userid = name_sex[0][0]
            username = name_sex[0][1]
            # 显示至界面
            globVar.load_Face(userid)
            identityImage = QtGui.QImage('buffImage.jpg')
            fitImage = identityImage.scaled(256,
                                            256,
                                            aspectRatioMode=Qt.KeepAspectRatio)
            self.identityView.setPixmap(QPixmap.fromImage(fitImage))

            self.nameText.setText(username)
            self.IDText.setText(userid)

            self.id_print = userid
            self.name_print = username
            # self.teacher_id = userid
            self.teacher_id = name_sex[0][0]
            self.teacher_sex = name_sex[0][2]
            self.PM_Fault.setText("重新识别!")
        if self.flg == 3:
            QMessageBox.information(self, "警告", "您有可能不在教师名单!")
            self.PM_Fault.setText("身份信息错误")

            self.faceReco.setEnabled(True)
            self.PM_True.setEnabled(False)
            self.PM_Fault.setEnabled(False)
            self.identityView.clear()
            self.nameText.clear()
            self.IDText.clear()
            self.timer_camera.start()
Example #2
0
def teacher_female():
    teachers = teachers_id()
    teacher = np.random.choice(teachers)  # 随机选取教师
    print(teacher)
    name_sex = teacher_data.search_teacher(mydb, teacher)  # 查询姓名性别
    if (len(name_sex[0][2]) == 0):
        name_sex[0][2] = '男'
        exam, location, main_deputy = assignation.pre_assignation(mydb, 'cet4', teacher, name_sex[0][2])
    if (exam != None):
        if (main_deputy):
            ptr = name_sex[0][1] + ' 作为主监考员被分配到 ' + exam + ' 考场'
            print(ptr)
        else:
            ptr = name_sex[0][1] + ' 作为副监考员被分配到 ' + exam + ' 考场'
            print(ptr)
Example #3
0
def pre_assignation(mydb,exam_table,teacher_id,teacher_sex):
    if (exam_table == 'CET4' or exam_table == 'cet4'):
        exam_table = 'cet4'
    elif (exam_table == 'CET6' or exam_table == 'cet6'):
        exam_table = 'cet6'

    sql='SELECT exam_id FROM '+exam_table+' WHERE main_invigilation=%s OR deputy_invigilation=%s'
    sql_val=(str(teacher_id),str(teacher_id))
    results=database_comment.SearchTable(mydb,sql,sql_val)

    if(len(results)==0):
       exam,main_deputy = assignation(mydb=mydb, exam_table=exam_table, teacher_id=teacher_id, teacher_sex=teacher_sex)
       if(exam!=None):
           exam_select=exam_information.search_all_exam(mydb,exam_table,exam)
           location=exam_select[0][10]
           tes = teacher_data.search_teacher(mydb,teacher_id)
           exam_information.add_invigilation_table(mydb,exam_select,teacher_id,tes[0][1],main_deputy)
           return exam,location,main_deputy
    return None,False,None
Example #4
0
 def faceRecogn(self):
     if self.exLevel.currentText() == "请选择等级":
         QMessageBox.information(self, "警告", "请选择考试等级!")
     else:
         self.exLevel.setEnabled(False)
         self.assignment.setEnabled(False)
         self.print.setEnabled(False)
         self.timer_camera.stop()
         # retname:教师工号
         self.retname, top_k_idx = faceOpera.identityRecognition(
             comPic[:, :, ::-1], globVar.known_face_encodings,
             globVar.known_face_IDs, 0.65)
         print("self.retname", self.retname)
         print("self.top_k_idx", top_k_idx)
         # name_sex只返回一个结果
         if str(self.retname) == '0':
             QMessageBox.information(self, "警告", "没有识别到人脸,请重新识别")
             self.timer_camera.start()
         else:
             self.flg = 0
             name_sex = teacher_data.search_teacher(
                 mydb, self.retname[0])  # 查询姓名性别
             userid = name_sex[0][0]
             username = name_sex[0][1]
             # 显示至界面
             globVar.load_Face(userid)
             identityImage = QtGui.QImage('buffImage.jpg')
             fitImage = identityImage.scaled(
                 256, 256, aspectRatioMode=Qt.KeepAspectRatio)
             self.identityView.setPixmap(QPixmap.fromImage(fitImage))
             self.nameText.setText(username)
             self.IDText.setText(userid)
             self.id_print = userid
             self.name_print = username
             self.teacher_id = name_sex[0][0]
             self.teacher_sex = name_sex[0][2]
             self.faceReco.setEnabled(False)
             self.PM_Fault.setEnabled(True)
             self.PM_True.setEnabled(True)
Example #5
0
from time import sleep
import numpy as np


def teachers_id():
    results = teacher_data.search_teacher_all(mydb)
    teachers = []
    for i in results:
        teachers.append(i[0])
    return teachers


if __name__ == '__main__':
    teachers = teachers_id()
    #print(teachers)
    for i in range(1000):
        teacher = np.random.choice(teachers)  #随机选取教师
        #print(teacher)
        name_sex = teacher_data.search_teacher(mydb, teacher)  #查询姓名性别
        #print(name_sex)
        exam, main_deputy = pre_assignation(mydb, 'cet4', teacher,
                                            name_sex[0][2])  #分配考场和职位
        if (exam != None):
            if (main_deputy):
                ptr = name_sex[0][1] + ' 作为主监考员被分配到 ' + exam + ' 考场'
                print(ptr)
            else:
                ptr = name_sex[0][1] + ' 作为副监考员被分配到 ' + exam + ' 考场'
                print(ptr)
        sleep(5)