user6092898
user6092898

Reputation:

Computing eigen values and eigen vectors using PCACompute2

Im using the following code to compute eigen vectors together with eigen values.

mean, eigenvectors, eigenvalues = cv2.PCACompute2(data_pts, mean)

but why am i getting the following error?

AttributeError: module 'cv2' has no attribute 'PCACompute2'

I have installed opencv-contrib-python though using pip but still the error persists. Is there any ways to find eigen values apart from PCACompute2?

Upvotes: 1

Views: 1483

Answers (2)

Robz
Robz

Reputation: 1

you need to install the contrib package

sudo -H pip install opencv-contrib-python
sudo -H pip install opencv-python

Upvotes: 0

Ruan
Ruan

Reputation: 902

Maybe numpy.linalg.eig is what you're looking for? Assuming you're sending your input as a square matrix.

import numpy as np
eigenvalues, eigenvectors = np.linalg.eig(M)

You may also want to take a look at an answer to this question: Do non-square matrices have eigenvalues? .

Upvotes: 1

Related Questions