PCACompute function

(Mat, Mat, Mat) PCACompute(
  1. InputArray data,
  2. InputOutputArray mean, {
  3. OutputArray? eigenvectors,
  4. OutputArray? eigenvalues,
  5. int maxComponents = 0,
})

PCACompute performs PCA.

The computed eigenvalues are sorted from the largest to the smallest and the corresponding eigenvectors are stored as eigenvectors rows.

Note: Calling with maxComponents == 0 (opencv default) will cause all components to be retained.

For further details, please see: https://docs.opencv.org/4.x/d2/de8/group__core__array.html#ga27a565b31d820b05dcbcd47112176b6e

Implementation

(Mat mean, Mat eigenvalues, Mat eigenvectors) PCACompute(
  InputArray data,
  InputOutputArray mean, {
  OutputArray? eigenvectors,
  OutputArray? eigenvalues,
  int maxComponents = 0,
}) {
  eigenvalues ??= Mat.empty();
  eigenvectors ??= Mat.empty();
  cffi.Mat_PCACompute(data.ref, mean.ref, eigenvectors.ref, eigenvalues.ref, maxComponents);
  return (mean, eigenvalues, eigenvectors);
}