我正在使用dlib来检测多个视频帧中的面部界标坐标。如何以一种易于将其转换回其原始坐标的方式标准化这些坐标,而无需保存任何额外的数据?
这是python和numpy的示例:
def process_keypoints(keypoints):
# Need to save center variable to correctly go from normalized keypoints to original keypoints
center = np.mean(keypoints, axis=0)
keypoints_norm = keypoints - center
return keypoints_norm
如果您不想保存额外的数据,但是以后可以进行一些额外的计算,那就可以了
#replace the first point with the center
keypoints_norm[0] = center
return key_points_norm
#reconstruct
center = keypoints_norm[0]
keyporints_norm[0]=-np.sum(keypoints_norm[1:])