Python线程模块AttributeError失败

时间:2017-04-21 07:13:46

标签: opencv3.0

import cv2
import numpy as np
import threading, winsound

face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')

def beep():
  for i in xrange(4):
   winsound.Beep(1500, 250)

cam = cv2.VideoCapture(0)
count = 0
iters = 0
while(True):
      ret, cur = cam.read()
      gray = cv2.cvtColor(cur, cv2.COLOR_BGR2GRAY)
      faces = face_cascade.detectMultiScale(gray,scaleFactor = 1.3, 
      minNeighbors=3, minSize=(20,20))
      for (x,y,w,h) in faces:
        #cv2.rectangle(cur,(x,y),(x+w,y+h),(255,0,0),2)
        roi_gray = gray[y:y+h,x:x+w]
        roi_color = cur[y:y+h,x:x+w]
        eyes = eye_cascade.detectMultiScale(roi_gray)
    if len(eyes) == 0:
      print ("Eyes closed")
    else:
      print ("Eyes open")
    count += len(eyes)
    iters += 1
    if iters == 4:
      iters = 0
      if count == 0:
        print ("Drowsiness Detected!!!")
        threading.start_new_threading(beep,())
      count = 0
    for (ex,ey,ew,eh) in eyes:
        cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh), (0,255,0),2)
  cv2.imshow('frame', cur)
  if cv2.waitKey(1) & 0xFF == ord('q'):
    cv2.destroyAllWindows()
    break

我收到以下错误和开放的准确性和眼睛的亲密度不是那么准确善意解决我的错误提前感谢:)

追踪(最近一次通话):   文件" C:\ Users \ AppData \ Local \ Programs \ Python \ Python36-32 \ original.py",第34行,in     threading.start_new_threading(蜂鸣声,()) AttributeError:module' threading'没有属性' start_new_threading'

0 个答案:

没有答案