@@ -146,12 +146,24 @@ def render(self, image):
146
146
previous_spawn_time = current_time
147
147
spawn_delay = random .normalvariate (4 , 1 )
148
148
149
+ face_bounding_box = None
149
150
150
151
if face_results .detections :
151
152
detection = next (iter (face_results .detections ))
152
153
153
154
mp_drawing .draw_detection (image , detection )
154
155
156
+ bbox = detection .location_data .relative_bounding_box
157
+ fbbx = int (bbox .xmin * w )
158
+ fbby = int (bbox .ymin * h )
159
+ fbbw = int (bbox .width * w )
160
+ fbbh = int (bbox .height * h )
161
+ face_center = np .array ((fbbx + fbbw / 2 , fbby + fbbh / 2 ))
162
+ face_bounding_box = (fbbx , fbby , fbbw , fbbh )
163
+
164
+ for rect in rect_list :
165
+ rect .chase (face_center , delta_time )
166
+
155
167
if hand_results .multi_hand_landmarks :
156
168
for hand_landmarks in hand_results .multi_hand_landmarks :
157
169
mp_drawing .draw_landmarks (image , hand_landmarks , mp_hands .HAND_CONNECTIONS )
@@ -172,7 +184,8 @@ def render(self, image):
172
184
if len (hits ) > 0 :
173
185
hit_indices .append (i )
174
186
175
- rect .chase (index_mcp , delta_time )
187
+ if not face_results .detections :
188
+ rect .chase (index_mcp , delta_time )
176
189
177
190
if is_hit :
178
191
continue
0 commit comments