  
          print("Done!")
  
  
  class Alignments():
      """ Holds processes pertaining to the alignments file """
      def __init__(self, arguments, is_extract):
          self.is_extract = is_extract
          self.args = arguments
          self.serializer = self.get_serializer()
          self.location = self.get_location()
 
</s> remove         self.is_extract = is_extract
 </s> add  </s> remove         self.serializer = self.get_serializer()
        self.location = self.get_location()
        self.have_alignments_file = os.path.exists(self.location)
        self.data = self.load()

    def frames_count(self):
        """ Return current frames count """
        return len(self.data)

    def faces_count(self):
        """ Return current faces count """
        return sum(len(faces) for faces in self.data.values())
 </s> add         self.is_extract = is_extract
        folder, filename = self.set_folder_filename()
        serializer = self.set_serializer()
        super().__init__(folder,
                         filename=filename,
                         serializer=serializer,
                         verbose=self.args.verbose)

    def set_folder_filename(self):
        """ Return the folder for the alignments file"""
        if self.args.alignments_path:
            folder, filename = os.path.split(str(self.args.alignments_path))
        else:
            folder = str(self.args.input_dir)
            filename = "alignments"
        return folder, filename </s> remove     def save(self):
        """ Write the serialized alignments file """
        try:
            print("Writing alignments to: {}".format(self.location))
            with open(self.location, self.serializer.woptions) as align:
                align.write(self.serializer.marshal(self.data))
        except Exception as err:
            print("{} not written!".format(self.location))
            print(str(err))

    def frame_exists(self, frame):
        """ return path of images that have faces """
        return frame in self.data.keys()

    def get_alignments_for_frame(self, frame):
        """ Return the alignments for the selected frame """
        return self.data.get(frame, list())

    def get_legacy_frames(self):
        """ Return a list of frames with legacy rotations """
        keys = list()
        for key, val in self.data.items():
            if any(alignment.get("r", None) for alignment in val):
                keys.append(key)
        return keys

    def rotate_existing_landmarks(self, frame, dimensions):
        """ Backwards compatability fix. Rotates the landmarks to
            their correct position and deletes r """
        for face in self.get_alignments_for_frame(frame):
            angle = face.get("r", 0)
            if not angle:
                return
            rotation_matrix = self.get_original_rotation_matrix(dimensions,
                                                                angle)
            rotate_landmarks(face, rotation_matrix)
            del face["r"]

    @staticmethod
    def get_original_rotation_matrix(dimensions, angle):
        """ Calculate original rotation matrix and invert """
        height, width = dimensions
        center = (width/2, height/2)
        rotation_matrix = cv2.getRotationMatrix2D(center, -1.0*angle, 1.)

        abs_cos = abs(rotation_matrix[0, 0])
        abs_sin = abs(rotation_matrix[0, 1])
        rotated_width = int(height*abs_sin + width*abs_cos)
        rotated_height = int(height*abs_cos + width*abs_sin)
        rotation_matrix[0, 2] += rotated_width/2 - center[0]
        rotation_matrix[1, 2] += rotated_height/2 - center[1]

        return rotation_matrix

 </s> add  </s> remove class Rotate():
    """ Rotating landmarks and bounding boxes on legacy alignments
 </s> add class Legacy():
    """ Update legacy alignments:

        - Add frame dimensions
        - Rotate landmarks and bounding boxes on legacy alignments </s> remove     def __init__(self, verbose=False, align_eyes=False, size=256):
 </s> add     def __init__(self, verbose=False, align_eyes=False, size=256, padding=48):
class Alignments(AlignmentsBase):
    """ Override main alignments class for extract """
  
          print("Done!")
  
  
class Alignments(AlignmentsBase):
    """ Override main alignments class for extract """
class Alignments(AlignmentsBase):
    """ Override main alignments class for extract """
      def __init__(self, arguments, is_extract):
          self.is_extract = is_extract
          self.args = arguments
          self.serializer = self.get_serializer()
          self.location = self.get_location()
keep keep keep keep replace replace keep keep keep keep keep
 Fix convert-adjust (#531)

* Add dimensions to alignments + refactor

* Add frame_dims + funcs to DetectFaces. Add alignments lib

* Convert Adjust working

* Refactor and tidy up 
scripts/fsmedia.py