I recently got the cute little pan-tilt hat and started messing around with the face tracking examples.
They work great, but I’d like the module to ‘roam’ per say when it cannot find a face - to this end, I’ve modified the ‘facetracker_lbp.py’ program with partial success.
I added this if statement just before the for loop:
lights(50 if len(faces) == 0 else 0, 50 if len(faces) > 0 else 0,0,50)
if len(faces) == 0:
for (x, y, w, h) in faces:
and defined ‘roam’ earlier on in the program (before the while True loop):
rand_x = random.randint(-20,20)
rand_y = random.randint(-20,20)
The roaming aspect works fine, but the sleep commands lock up the program every time it tries to refresh the frame in order to detect a face, resulting in a dreadfully slow frame rate and an unusable video output. Does anyone have any ideas on how to preserve the roaming function and the face tracking?
Thanks in advance!