import csv


def read_groundtruth(filename):
    """
    Reads a file with 7 annotations for a ground truth scan.
    :param filename: Filename of the text file to load.
    :return: A list of 7 annotations in the order (1) right eye outer corner, (2) right eye inner corner, (3) left eye inner corner, (4) left eye outer corner,
             (5) nose bottom, (6) right mouth corner, (7) left mouth corner.
    """
    groundtruth_points = []
    with open(filename, newline='') as csvfile:
        reader = csv.reader(csvfile, delimiter=' ')
        for row in reader:
            if row:  # there might be an empty line at the end of the file
                groundtruth_points.append([float(row[1]), float(row[2]), float(row[3])])
    if len(groundtruth_points) != 7:
        raise Exception("Error: Expected 7 landmarks in the given ground truth file " + filename + ".")
    return groundtruth_points