예제 #1
0
def checkface():

    i = 0
    failcount = 0
    picpath = "G:/tiaozhanbei/baiduapi/checktest/test"

    #cv2.imshow("capture", frame)
    time.sleep(5)
    while (1):
        print("开始检测!")
        #cv2.waitKey(0)
        time.sleep(5)
        ret, frame = cap.read()
        cv2.imwrite(picpath + str(i) + ".jpg", frame)
        face_num = facecheck.fa_check((picpath + str(i) + ".jpg"))
        if (face_num > 0):
            print("检测成功!开始拍照")
            time.sleep(2)
            ret, frame = cap.read()
            cv2.imwrite(picpath + str(i) + ".jpg", frame)
            face_num = facecheck.fa_check((picpath + str(i) + ".jpg"))
            print("总共有", face_num, "张人脸")
            if (face_num > 0):
                print("拍照成功!下一个同学!")
                time.sleep(5)
                i += 1
                continue
            else:
                print("拍照失败,重新检测")
                os.remove(picpath + str(i) + ".jpg")
                time.sleep(5)
                continue
        else:
            print("检测不到人脸,5秒后重新检测")
            os.remove(picpath + str(i) + ".jpg")
            time.sleep(5)
            failcount += 1  #failcount次检测不到人之后关闭程序
            if (failcount == 2):
                print("谢谢使用!")
                print("开始考勤")
                classKQ.Classqiandao()
                break
            continue

    cap.release()
    cv2.destroyAllWindows()
예제 #2
0
def checkface(capc, ui, conn):

    #i = 0
    global failcount
    failcount = 0
    picpath = "G:/tiaozhanbei/baiduapi/checktest/test0"

    #cv2.imshow("capture", frame)
    time.sleep(5)
    while (1):

        ui.label_11.setText("开始检测!")
        #cv2.waitKey(0)
        time.sleep(1)
        ret, frame = capc.read()
        cv2.imwrite(picpath + ".jpg", frame)

        face_num = facecheck.fa_check((picpath + ".jpg"))

        if (face_num > 0):
            ui.label_11.setText("检测成功,开始拍照!")
            time.sleep(2)
            ret, frame = capc.read()
            cv2.imwrite(picpath + ".jpg", frame)
            face_num = facecheck.fa_check((picpath + ".jpg"))
            print("总共有", face_num, "张人脸")
            if (face_num > 0):
                ui.label_11.setText("拍照成功,开始核实身份!")
                failcount = 0
                classKQsearch.Classqiandao(picpath + ".jpg", ui, conn)
                print("下一个同学!")
                time.sleep(5)
                continue
            else:
                print("拍照失败,重新检测")
                os.remove(picpath + ".jpg")
                time.sleep(5)
                continue
        else:
            print("检测不到人脸,5秒后重新检测")
            os.remove(picpath + ".jpg")
            time.sleep(5)
            continue
예제 #3
0
def checkface(capc,ui,conn):
    #i = 0
    global  failcount
    failcount = 0
    picpath=CONFIG.test_face
    #cv2.imshow("capture", frame)
    time.sleep(5)
    while (1):
        ui.label_11.setText("开始检测!")
        #cv2.waitKey(0)
        time.sleep(1)
        ret, frame= capc.read()
        # print(frame)
        # 将摄像头拍摄的图像进行保存
        cv2.imwrite(picpath+".jpg", frame)
        face_num = facecheck.fa_check((picpath+".jpg"))

        if(face_num>0):
            ui.label_11.setText("检测成功,开始拍照!")
            time.sleep(2)
            ret, frame = capc.read()
            cv2.imwrite(picpath + ".jpg", frame)
            face_num = facecheck.fa_check((picpath + ".jpg"))
            print("总共有",face_num,"张人脸")
            if(face_num>0):
                ui.label_11.setText("拍照成功,开始核实身份!")
                failcount = 0
                classKQsearch.Classqiandao(picpath + ".jpg",ui,conn)
                print("下一个同学!")
                time.sleep(5)
                continue
            else:
                print("拍照失败,重新检测")
                os.remove(picpath + ".jpg")
                time.sleep(5)
                continue
        else:
            print("检测不到人脸,2秒后重新检测")
            # os.remove(picpath + ".jpg")
            time.sleep(2)
            continue