def read_pts_file(self, pts_path):
"""Read a pts file that contains the coordinates of the landmarks.
"""
with open(pts_path) as f:
content = f.readlines()
content = content[3:-1] # exclude the 4 cases and the last case.
nbr = len(content)
X = np.zeros((nbr,1))
Y = np.zeros((nbr,1))
for i in xrange(nbr):
line = content[i].split(' ')
X[i] = np.float(line[0])
Y[i] = np.float(line[1].replace('\n', ''))
# remove 1 to start counting from 0 (python)
X = X - 1
Y = Y - 1
return X,Y
评论列表
文章目录