Skip to content

Commit

Permalink
Perform a double-check: if the centerpoint of the detect face is with…
Browse files Browse the repository at this point in the history
…in a tracker rectangle AND the centerpoint of the tracker rectangle is within the bounds of the detected face, only then we consider it a match
  • Loading branch information
Guido Diepen committed Feb 27, 2017
1 parent f789460 commit 2f20ab2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions track multiple faces/demo - track multiple faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,20 @@ def detectAndTrackMultipleFaces():
t_w = int(tracked_position.width())
t_h = int(tracked_position.height())


#calculate the centerpoint
t_x_bar = t_x + 0.5 * t_w
t_y_bar = t_y + 0.5 * t_h

#check if the centerpoint of the face is within the
#rectangleof a tracker region. If it is, we have
#a match
if ( ( t_x <= x_bar <= (t_x + t_w) ) and
( t_y <= y_bar <= (t_y + t_h))):
#rectangleof a tracker region. Also, the centerpoint
#of the tracker region must be within the region
#detected as a face. If both of these conditions hold
#we have a match
if ( ( t_x <= x_bar <= (t_x + t_w)) and
( t_y <= y_bar <= (t_y + t_h)) and
( x <= t_x_bar <= (x + w )) and
( y <= t_y_bar <= (y + h ))):
matchedFid = fid


Expand Down

0 comments on commit 2f20ab2

Please sign in to comment.