我的python人脸识别项目面临这种类型的错误。凸轮灯亮起,但不';t显示摄像机界面
我的python人脸识别项目面临这种类型的错误。摄像头指示灯亮起,但不显示摄像头界面 如果cv2.waitKey(100)&0xFF==ord('q'):cv2.error:OpenCV(4.2.0)C:\projects\OpenCV python\OpenCV\modules\highgui\src\window.cpp:717:error:(-2:Unspecified error)函数未实现。使用Windows、GTK+2.x或Cocoa支持重建库。如果您使用的是Ubuntu或Debian,请安装instal我的python人脸识别项目面临这种类型的错误。凸轮灯亮起,但不';t显示摄像机界面,python,c++,python-3.x,opencv,cv2,Python,C++,Python 3.x,Opencv,Cv2,我的python人脸识别项目面临这种类型的错误。摄像头指示灯亮起,但不显示摄像头界面 如果cv2.waitKey(100)&0xFF==ord('q'):cv2.error:OpenCV(4.2.0)C:\projects\OpenCV python\OpenCV\modules\highgui\src\window.cpp:717:error:(-2:Unspecified error)函数未实现。使用Windows、GTK+2.x或Cocoa支持重建库。如果您使用的是Ubuntu或Debia
def TakeImages():
Id =(txt.get())
name =(txt2.get())
if(is_number(Id) and name.isalpha()):
cam = cv2.VideoCapture(0)
harcascadePath = "C:/Users/Lenovo/AppData/Local/Programs/Python/Python36/Lib/site-packages/cv2/data/haarcascade_frontalface_default.xml"
detector = cv2.CascadeClassifier(harcascadePath)
sampleNum = 0
while(True):
ret,img = cam.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = detector.detectMultiScale(gray, 1.3,5)
for (x, y, w, h) in faces:
cv2.rectangle(img, (x, y), ( x + w, y + h), (255, 0, 0), 2)
sampleNum=sampleNum + 1
cv2.imwrite("C:\Users\Lenovo\AppData\Local\Programs\Python\Python36\TrainingImages\ "+name +"."+Id +'.'+ str(sampleNum) + ".jpg", gray[y:y + h, x:x + w])
cv2.imshow('frame', img)
if cv2.waitKey(100) & 0xFF == ord('q'):
break
elif sampleNum>60:
break
cam.release()
cv2.destroyAllWindows()
res = "Images Saved for ID: " + Id +" Name: "+ name
row = [Id, name]
with open('C:/Users/Lenovo/AppData/Local/Programs/Python/Python36/studentDetails\StudentDetails.csv', 'a+') as csvFile:
writer = csv.writer(csvFile)
writer.writerow(row)
csvFile.close()
message.configure(text = res)
else:
if(is_number(Id)):
res = "Enter Alphabetical Name"
message.configure(text = res)
if(name.isalpha()):
res = "Enter Numeric Id"
message.configure(text = res)
Error..
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36\lib\idlelib\run.py", line 137, in main
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36\lib\queue.py", line 172, in get
raise Empty
queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "C:\Users\Lenovo\Desktop\Face recognision syystem36.py", line 96, in TakeImages
if cv2.waitKey(100) & 0xFF == ord('q'):
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:717: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'