PCAComputeAsync function

Future<(Mat, Mat, Mat)> PCAComputeAsync(
  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

Future<(Mat mean, Mat eigenvalues, Mat eigenvectors)> PCAComputeAsync(
  InputArray data,
  InputOutputArray mean, {
  OutputArray? eigenvectors,
  OutputArray? eigenvalues,
  int maxComponents = 0,
}) async {
  eigenvalues ??= Mat.empty();
  eigenvectors ??= Mat.empty();
  return cvRunAsync0(
      (callback) => ccore.cv_PCACompute(
            data.ref,
            mean.ref,
            eigenvectors!.ref,
            eigenvalues!.ref,
            maxComponents,
            callback,
          ), (c) {
    return c.complete((mean, eigenvalues!, eigenvectors!));
  });
}