Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 opencv人脸检测验证码_Python 2.7 - Fatal编程技术网

Python 2.7 opencv人脸检测验证码

Python 2.7 opencv人脸检测验证码,python-2.7,Python 2.7,请我正在使用人脸检测作为验证码系统。如果网络摄像头中未检测到人脸,如何让系统打印错误消息。另外,尝试检测人脸的次数为3次,这样在3次尝试后,它将在python中关闭 from Tkinter import * import numpy as np import cv2 import Tkinter as tk import tkMessageBox import random import webbrowser def Request_1(event): #messagebox

请我正在使用人脸检测作为验证码系统。如果网络摄像头中未检测到人脸,如何让系统打印错误消息。另外,尝试检测人脸的次数为3次,这样在3次尝试后,它将在python中关闭

from Tkinter import *
import numpy as np
import cv2
import Tkinter as tk
import tkMessageBox
import random
import webbrowser




def Request_1(event):    
#messagebox gestures
    trials = 0
    while trials<3:

        tkMessageBox.showinfo("ATTENTION!!!", "press letter a when you see     the yellow box on your nose")

        #this aspect is to generate random requests for the captcha system
        detector2= cv2.CascadeClassifier('haarcascade_mcs_nose.xml')

        cap = cv2.VideoCapture(0)
        access = True

        while(access):
        #reads the image
            ret2, img2 = cap.read()
            gray2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
            # Detect faces in the image . the image is read and convertedd to grayscale
            faces2 = detector2.detectMultiScale(gray2, 1.3, 5)
            if(len(faces2)!=0):
                for (x,y,w,h) in faces2:
                    cv2.rectangle(img2,(x,y),(x+w,y+h),(0,255,255),1)
                    cv2.imshow('frame',img2)
                    break
            if cv2.waitKey(1) & 0xFF == ord('a'):        
            #grant access to webpage   
                cap.release()
                cv2.destroyAllWindows()

                new=2
                url="file:///C:/Users/jayrush/Desktop/lmarku/index.html";
                webbrowser.open(url, new=new);
                break
            if(len(faces2)==0):
                trials=trials+1
                print("Access Denied")






#defining the interface of the captcha
#INTERFACE 
root = Tk()
root.title("Face Detection CAPTCHA")
root.geometry("350x50")
bottomFrame = Frame(root)
bottomFrame.pack()

button_1 = Button(bottomFrame, fg="blue", text="I am not a robot")
button_1.bind("<Button-1>", Request_1)
button_1.pack()


status = Label(root, fg="red", text="Starting captcha...", bd=1,     relief=SUNKEN, anchor=W)
status.pack(side=BOTTOM, fill=X) 
root.mainloop()
从Tkinter导入*
将numpy作为np导入
进口cv2
将Tkinter作为tk导入
导入tkMessageBox
随机输入
导入网络浏览器
def请求_1(事件):
#messagebox手势
试验=0
审判期间