Back to O3de

Load data helpers

Gems/MotionMatching/JupyterNotebooks/LearnedMotionMatching.ipynb

latest1.9 KB
Original Source

Load data helpers

python
import numpy as np
import pandas as pd

def PrintGreen(text):
    print('\x1b[6;30;42m' + text + '\x1b[0m')
    
def PrintRed(text):
    print('\33[41m' + text + '\x1b[0m')

def LoadData(filename, rowsName, columnsName):
    newDataframe = pd.read_csv(filename, na_values = 'null')
    if newDataframe.shape[0] > 0 and newDataframe.shape[1] > 0:
        PrintGreen("Loading " + filename + " succeeded");
    else:
        PrintRed("Loading " + filename + " failed!");

    print(rowsName + " = " + str(newDataframe.shape[0]))
    print(columnsName + " = " + str(newDataframe.shape[1]))

    return newDataframe

# Ensure to show all columns
pd.set_option('display.max_columns', None)

Motion Database Poses

Evaluated skeletal poses at a given sample rate. Position and rotation in local space. Rotation is represented as the X and Y basis vectors of the transform.

python
dataPoses = LoadData('E:/MotionMatchingDatabase_Poses_60Hz.csv', "Frames", "PoseComponents")
dataPoses.head(15)

Motion Database Features

Feature matrix

python
dataFeatures = LoadData('E:/MotionMatchingDatabase_Features_60Hz.csv', "Frames", "FeatureComponents")

if (dataPoses.shape[0] == dataFeatures.shape[0]):
    PrintGreen("Frame numbers match.")
else:
    PrintRed("Frame numbers do not match!")

dataFeatures.head(15)

Recorded data (Poses, features and best matching frames)

python
recording_poses = LoadData('E:/RuntimeRecording_Poses.csv', "Frames", "PoseComponents")
recording_features = LoadData('E:/RuntimeRecording_Features.csv', "Frames", "FeatureComponents")
recording_bestMatchFrames = LoadData('E:/RuntimeRecording_BestMatchingFrames.csv', "Frames", "BestMatchingFrameComponents")

if (recording_poses.shape[0] == recording_features.shape[0] == recording_bestMatchFrames.shape[0]):
    PrintGreen("Frame numbers match.")
else:
    PrintRed("Frame numbers do not match!")