Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in Tkinter callback Traceback most recent call last #32

Open
janny-sins opened this issue May 30, 2021 · 0 comments
Open

Exception in Tkinter callback Traceback most recent call last #32

janny-sins opened this issue May 30, 2021 · 0 comments

Comments

@janny-sins
Copy link

Here is the error I got.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Claire\AppData\Roaming\Python\Python36\site-packages\pandas\core\indexes\base.py", line 2898, in get_loc
return self._engine.get_loc(casted_key)
File "pandas_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\hashtable_class_helper.pxi", line 1675, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas_libs\hashtable_class_helper.pxi", line 1683, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Program Files\Python36\lib\tkinter_init_.py", line 1702, in call
return self.func(*args)
File "C:\Users\Claire\Desktop\New folder (6)\login-verification-master\run.py", line 161, in login_submit
TrackImages(a)
File "C:\Users\Claire\Desktop\New folder (6)\login-verification-master\run.py", line 135, in TrackImages
aa=df.loc[df['Id'] == Id]['Name'].values
File "C:\Users\Claire\AppData\Roaming\Python\Python36\site-packages\pandas\core\frame.py", line 2906, in getitem
indexer = self.columns.get_loc(key)
File "C:\Users\Claire\AppData\Roaming\Python\Python36\site-packages\pandas\core\indexes\base.py", line 2900, in get_loc
raise KeyError(key) from err
KeyError: 'Id'

This is the code that produces the error.
`def TrackImages(UserId):
recognizer = cv2.face.LBPHFaceRecognizer_create()#cv2.createLBPHFaceRecognizer()
recognizer.read("TrainingImageLabel\Trainner.yml")
harcascadePath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(harcascadePath);
df=pd.read_csv("Details\Details.csv")
cam = cv2.VideoCapture(0)
font = cv2.FONT_HERSHEY_SIMPLEX
run_count=0;run=True
while run:

    ret, im =cam.read()
    gray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
    faces=faceCascade.detectMultiScale(gray, 1.2,5)    
    for(x,y,w,h) in faces:
        cv2.rectangle(im,(x,y),(x+w,y+h),(225,0,0),2)
        Id, conf = recognizer.predict(gray[y:y+h,x:x+w])
        print(Id, conf)
        if(conf < 50):
            aa=df.loc[df['Id'] == Id]['Name'].values
            tt=str(Id)+"-"+aa
            if (str(Id)==UserId):
                df.get ('values')
                message.configure(text="Face Recognsed Successfully")
                run=False
        else:
            Id='Unknown'                
            tt=str(Id)            
        cv2.putText(im,str(tt),(x,y+h), font, 1,(255,255,255),2)        
    run_count += 1    
    cv2.imshow('im',im) 
    if (cv2.waitKey(1)==ord('q') or run_count==150):
        message.configure(text="Unable to Recognise Face")
        break

cam.release()
cv2.destroyAllWindows()

def login_submit():
a=txt.get()
b=txt2.get()
if (a in data):
if(data[a] == b):
TrackImages(a)
else:
message.configure(text="Id and Password does not Match")
else:
message.configure(text="Entered Id does not Exists")

login_clear()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant