cantarinigiorgio/HHP-Net

How did you get the ground truth of euler angles?

sawoo9410 opened this issue · 3 comments

I want to learn your model, but I don't know where ground truth of euler angles is in 300W-LP dataset.

please reply to my question.

thank.

Hi @sawoo9410,

a .mat file with annotations is associated with each image of the 300W-LP dataset: you have to extract yaw, pitch and roll, expressed in radians, and convert them to degrees.

Here you can find a simple code snippet, let me know if it's clear to you!

import scipy.io as sio
import numpy as np


def get_ypr_from_mat(mat_path):
    """
    Get yaw pitch and roll from the .mat file (W300-LP dataset).

    Args:
        :mat_path (str): path of the filename containing the yaw, pitch and roll information express in radians (to be converted in degrees)

    Returns:
        :pyr (list): list containing yaw pitch and roll; [pitch, yaw, roll] express in radians
    """
    mat = sio.loadmat(mat_path)
    pose_params = mat['Pose_Para'][0]
    pyr = pose_params[:3]
    return pyr


if __name__ == '__main__':
    # get the pose in radians
    pose = get_ypr_from_mat('1.mat')

    # convert to degrees
    yaw = pose[1] * 180.0 / np.pi
    pitch = pose[0] * 180.0 / np.pi
    roll = pose[2] * 180.0 / np.pi

    labels = [yaw, pitch, roll]

Hi. @cantarinigiorgio
First, thank you for your kind answer.

I understood what you answered.

If you don't mind, can you tell me the ground truth code of the Biki dataset and the AFLW dataset?

I downloaded the data, but I've been wandering for over a week. :-<

please reply to my question.

thank you.

In the Biwi dataset, you can find a .txt file (frame_*_pose.txt) associated with each image: the first three lines represent a 3x3 matrix (the rotation matrix) and you can retrieve yaw, pitch and roll in the following way:

def get_ypr_from_txt(txt_path):
    """
    Get yaw pitch and roll from the .txt file (Biwi dataset)

    Args:
        :txt_path (str): path of the filename containing the rotation matrix

    Returns:
        :pyr (list): list containing yaw pitch and roll; [pitch, yaw, roll] express in radians
    """

    pose_annot = open(txt_path, 'r')
    r = []
    for line in pose_annot:
        line = line.strip().split(' ')
        l = []
        if line[0] != '':
            for nb in line:
                if nb == '':
                    continue
                l.append(float(nb))
            r.append(l)
    pose_annot.close()

    # rotation matrix
    r = np.array(r)
    r = r[:3, :]
    
    r = np.transpose(r)
    
    # get yaw pitch and roll and convert to degrees
    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
    return [pitch, yaw, roll]

In the AFLW2000 dataset, you have the same annotations as the 300W-LP dataset (you can use the function get_ypr_from_mat I wrote above).

Finally, in the AFLW the ground truth values are in a .sqlite file and you have to retrieve them using a query (the columns are facepose.yaw, facepose.pitch, facepose.roll): if you have access to the dataset you can find the aflw_example.py that contains a simple example.