PCA With ALGLIB

PoseDesigner uses ALGLIB‘s principal component analysis routine to extract a basis matrix from Kinect skeletal data. The ALGLIB conventions can be a little confusing – the example below provides some clarification.

// 6 samples of 3D data (x, y, z)
double values[18] = {1.0, 2.0, 3.0,
                     1.0, 2.0, 3.0,
                     1.0, 2.0, 3.0,
                     1.0, 2.0, 3.0,
                     1.0, 2.0, 3.0,
                     1.0, 2.0, 3.0};

// add this data to ALGLIB's format
alglib::real_2d_array ptInput;
ptInput.setcontent(6, 3, values);

// this guy gets passed in and is filled in with an integer status code
alglib::ae_int_t info;

// scalar values that describe variances along each eigenvector
alglib::real_1d_array eigValues;

// unit eigenvectors which are the orthogonal basis that we want
alglib::real_2d_array eigVectors;

// perform the analysis
pcabuildbasis(ptInput, 6, 3, info, eigValues, eigVectors);

// now the vectors can be accessed as follows:
double basis0_x = eigVectors[0][0];
double basis0_y = eigVectors[1][0];
double basis0_z = eigVectors[2][0];

double basis1_x = eigVectors[0][1];
double basis1_y = eigVectors[1][1];
double basis1_z = eigVectors[2][1];

double basis2_x = eigVectors[0][2];
double basis2_y = eigVectors[1][2];
double basis2_z = eigVectors[2][2];

Principle Component Analysis Kinect

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.