def search_face(self, face_object): for i,face in enumerate(self.faces): dx = max(face.w, face_object.w) dy = max(face.h, face_object.h) d = max(dx,dy)/2 if calc_d(face.get_center(), face_object.get_center()) < d: return face,i return None,-1
def search_face(self, face_object): for i, face in enumerate(self.faces): dx = max(face.w, face_object.w) dy = max(face.h, face_object.h) d = max(dx, dy) / 2 if calc_d(face.get_center(), face_object.get_center()) < d: return face, i return None, -1
def is_face_exists(self,face1): x,y,w,h = face1.ravel() face1_center = (x+w/2, y+h/2) max_distance = h for face2 in self.faces: face2_center = face2.get_center() max_distance = max(max_distance,h) distance = calc_d(face1_center,face2_center) if distance < max_distance: return True return False
def is_face_exists(self, face1): x, y, w, h = face1.ravel() face1_center = (x + w / 2, y + h / 2) max_distance = h for face2 in self.faces: face2_center = face2.get_center() max_distance = max(max_distance, h) distance = calc_d(face1_center, face2_center) if distance < max_distance: return True return False
def update_centers(self, list_name, object): list = self.centers[list_name] if len(list) < 3 or object == self.none: list.appendleft(object) return l = np.array(list) x = l[:,0] y = l[:,1] is_none = x == -1 x = np.delete(x,np.where(is_none == True)) y = np.delete(y,np.where(is_none == True)) if len(x) < 3: list.appendleft(object) return x_med = int(np.median(x)) y_med = int(np.median(y)) d = calc_d((x_med,y_med),object) if d < 80: list.appendleft(object)