Skip to content

Commit

Permalink
fix: mysterious NameError
Browse files Browse the repository at this point in the history
    mouse.move(a,b)
NameError: name 'a' is not defined
  • Loading branch information
nickumia committed Oct 9, 2022
1 parent 288bab2 commit fcc49c9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions eye_Controlled_Mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def track_pupil():

while True:
global a,b
a,b = 0,0
ret, img = cam.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # convering to gray to recognize colour change effectively
faces = face_Cascade_File.detectMultiScale(gray, 1.3, 5) # geometry
Expand All @@ -34,8 +33,11 @@ def track_pupil():
cv2.rectangle(roi_colour, (ex, ey), (ex + ew, ey + eh), (0, 255, 0), 2)
# print(len(eyes))
print(ex+(ex+ew)/2)
a =int(float(ex)/8)
b=int(float(ey)/8)
try:
a = int(float(ex)/8)
b = int(float(ey)/8)
except NameError:
a,b = 0,0
if int(len(eyes)) == 0:
quit()
cv2.imshow('img', img)
Expand Down

0 comments on commit fcc49c9

Please sign in to comment.