Ejemplo n.º 1
0
    def add(self, frame_index, pnt_x, width, pnt_y, height):
        """ Add a :class:`~lib.align.DetectedFace` object to the current frame with the
        given dimensions.

        Parameters
        ----------
        frame_index: int
            The frame that the face is being set for
        pnt_x: int
            The left point of the bounding box
        width: int
            The width of the bounding box
        pnt_y: int
            The top point of the bounding box
        height: int
            The height of the bounding box
        """
        face = DetectedFace()
        faces = self._faces_at_frame_index(frame_index)
        faces.append(face)
        face_index = len(faces) - 1

        self.bounding_box(frame_index, face_index, pnt_x, width, pnt_y, height, aligner="cv2-dnn")
        face.load_aligned(None)
        self._tk_face_count_changed.set(True)
Ejemplo n.º 2
0
 def extract_one_face(self, alignment, image):
     """ Extract one face from image """
     logger.trace("Extracting one face: (frame: '%s', alignment: %s)",
                  self.current_frame, alignment)
     face = DetectedFace()
     face.from_alignment(alignment, image=image)
     face.load_aligned(image, size=self.size, centering="head")
     face.thumbnail = generate_thumbnail(face.aligned.face, size=80, quality=60)
     return face
Ejemplo n.º 3
0
 def load(self):
     """ Load the faces from the alignments file, convert to
     :class:`~lib.align.DetectedFace`. objects and add to :attr:`_frame_faces`. """
     for key in sorted(self._alignments.data):
         this_frame_faces = []
         for item in self._alignments.data[key]["faces"]:
             face = DetectedFace()
             face.from_alignment(item, with_thumb=True)
             face.load_aligned(None)
             _ = face.aligned.average_distance  # cache the distances
             this_frame_faces.append(face)
         self._frame_faces.append(this_frame_faces)