欧拉角说明和计算,https://www.cnblogs.com/21207-iHome/p/6894128.html
https://blog.csdn.net/loongkingwhat/article/details/82765388
numpy.digitize(data,bins)函数用法 https://blog.csdn.net/weixin_38358654/article/details/78997769
读取BIWI数据 pose.txt ,说明
欧拉角计算公式 给的是旋转矩阵txt文件,(四元数对应的旋转矩阵,三行三列),对应欧拉角的公式
roll = -np.arctan2(R[1][0], R[0][0]) * 180 / np.pi
yaw = -np.arctan2(-R[2][0], np.sqrt(R[2][1] ** 2 + R[2][2] ** 2)) * 180 / np.pi
pitch = np.arctan2(R[2][1], R[2][2]) * 180 / np.pi
# Loosely crop face
k = 0.35
x_min -= 0.6 * k * abs(x_max - x_min)
y_min -= k * abs(y_max - y_min)
x_max += 0.6 * k * abs(x_max - x_min)
y_max += 0.6 * k * abs(y_max - y_min)
img = img.crop((int(x_min), int(y_min), int(x_max), int(y_max)))
#一张图片对应欧拉角的三个值,roll,yaw,pitch
#print roll,yaw,pitch #-3.400551904862772 0.5440903943579737 -8.078185087842218
# Bin values 分类值 -99到+102度,分类需要对应的标签
# bins 是 np.digitize(data,bins)第二个参数(升序或者降序),第一个数据在bins 哪个区间范围内,
bins = np.array(range(-99, 102, 1)) #198个角度分类,对欧拉角的三个角度,按照角度区间进行分类
binned_pose = torch.LongTensor(np.digitize([yaw, pitch, roll], bins) - 1) #[yaw, pitch, roll],to labels[99 90 95]