Example #1
0
def get_pos_only_prediction(model, trace, pred_hor):
    indices_input_trace = np.linspace(0,
                                      len(trace) - 1,
                                      M_WINDOW + 1,
                                      dtype=int)

    subsampled_trace = trace[indices_input_trace]

    encoder_pos_inputs = subsampled_trace[-M_WINDOW - 1:-1]
    decoder_pos_inputs = subsampled_trace[-1:]

    model_prediction = model.predict([
        np.array(
            transform_batches_cartesian_to_normalized_eulerian(
                [encoder_pos_inputs])),
        np.array(
            transform_batches_cartesian_to_normalized_eulerian(
                [decoder_pos_inputs]))
    ])[0][int(pred_hor / MODEL_SAMPLING_RATE)]
    model_prediction = transform_normalized_eulerian_to_cartesian(
        model_prediction)

    yaw_pred, pitch_pred = cartesian_to_eulerian(model_prediction[0],
                                                 model_prediction[1],
                                                 model_prediction[2])
    yaw_pred, pitch_pred = transform_the_radians_to_original(
        yaw_pred, pitch_pred)
    return create_head_map(np.array([yaw_pred, pitch_pred]), cartesian=False)
Example #2
0
def get_CVPR18_prediction(model, trace, saliency, pred_hor):
    indices_input_trace = np.linspace(0,
                                      len(trace) - 1,
                                      M_WINDOW + 1,
                                      dtype=int)
    indices_input_saliency = np.linspace(0,
                                         len(saliency) - 1,
                                         M_WINDOW + H_WINDOW,
                                         dtype=int)

    subsampled_trace = trace[indices_input_trace]

    subsampled_saliency = saliency[indices_input_saliency]

    encoder_pos_inputs = subsampled_trace[-M_WINDOW - 1:-1]
    decoder_pos_inputs = subsampled_trace[-1:]
    # encoder_sal_inputs = subsampled_saliency[:M_WINDOW]
    decoder_sal_inputs = subsampled_saliency[M_WINDOW:]

    model_prediction = model.predict([
        np.array([encoder_pos_inputs]),
        np.array([decoder_pos_inputs]),
        np.array([decoder_sal_inputs])
    ])[0][int(pred_hor / MODEL_SAMPLING_RATE)]

    yaw_pred, pitch_pred = cartesian_to_eulerian(model_prediction[0],
                                                 model_prediction[1],
                                                 model_prediction[2])
    yaw_pred, pitch_pred = transform_the_radians_to_original(
        yaw_pred, pitch_pred)
    return create_head_map(np.array([yaw_pred, pitch_pred]), cartesian=False)
Example #3
0
def recover_original_angles_from_xyz_trace(xyz_trace):
    angles_per_video = []
    for sample in xyz_trace:
        restored_yaw, restored_pitch = cartesian_to_eulerian(sample[1], sample[2], sample[3])
        restored_yaw, restored_pitch = transform_the_radians_to_original(restored_yaw, restored_pitch)
        angles_per_video.append(np.array([restored_yaw, restored_pitch]))
    return np.array(angles_per_video)
Example #4
0
def transform_batches_cartesian_to_normalized_eulerian(positions_in_batch):
    positions_in_batch = np.array(positions_in_batch)
    eulerian_batches = [[
        cartesian_to_eulerian(pos[0], pos[1], pos[2]) for pos in batch
    ] for batch in positions_in_batch]
    eulerian_batches = np.array(eulerian_batches) / np.array(
        [2 * np.pi, np.pi])
    return eulerian_batches
Example #5
0
def recover_original_angles_from_quaternions_trace(quaternions_trace):
    angles_per_video = []
    orig_vec = np.array([1, 0, 0])
    for sample in quaternions_trace:
        quat_rot = Quaternion(sample[1:])
        sample_new = quat_rot.rotate(orig_vec)
        restored_yaw, restored_pitch = cartesian_to_eulerian(sample_new[0], sample_new[1], sample_new[2])
        restored_yaw, restored_pitch = transform_the_radians_to_original(restored_yaw, restored_pitch)
        angles_per_video.append(np.array([restored_yaw, restored_pitch]))
    return np.array(angles_per_video)
Example #6
0
def transform_back_predicted_angles(sample):
    restored_yaw, restored_pitch = cartesian_to_eulerian(sample[0], sample[1], sample[2])
    restored_yaw, restored_pitch = transform_the_radians_to_original(restored_yaw, restored_pitch)
    return restored_yaw, restored_pitch