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

Make resolution and servo pos scale #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions face_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')

cap = cv2.VideoCapture(0)
width=480 #adjust these to change dimentions; larger width & height gives better resolution, but slower processing speed
height=360
cap.set(3,width)
cap.set(4,height)

# Defining and initializing globals
global panServoAngle
Expand All @@ -38,25 +42,25 @@
def servoPosition (x, y):
global panServoAngle
global tiltServoAngle
if (x < 250):
if (x < width*.45):
panServoAngle += 10
if panServoAngle > 140:
panServoAngle = 140
os.system("python angleServoCtrl.py " + str(panPin) + " " + str(panServoAngle))

if (x > 300):
if (x > width*.55):
panServoAngle -= 10
if panServoAngle < 40:
panServoAngle = 40
os.system("python angleServoCtrl.py " + str(panPin) + " " + str(panServoAngle))

if (y < 160):
if (y < height*.45):
tiltServoAngle += 10
if tiltServoAngle > 140:
tiltServoAngle = 140
os.system("python angleServoCtrl.py " + str(tiltPin) + " " + str(tiltServoAngle))

if (y > 210):
if (y > height*.55):
tiltServoAngle -= 10
if tiltServoAngle < 40:
tiltServoAngle = 40
Expand Down