Created
June 11, 2019 09:45
-
-
Save bezero/5e02381a7db601ed1b3a97e6a9d0100e to your computer and use it in GitHub Desktop.
PCA using opencv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
points = np.array([[0, 20], [980, 1020], [1020, 980], [20, 0]], dtype=np.float) | |
mean, eigenvectors = cv2.PCACompute(data=points, mean=None, maxComponents=1) | |
print(points) | |
print(eigenvectors) | |
theta = np.arctan((eigenvectors[0, 1])/(eigenvectors[0, 0])) | |
print('theta: ', theta) | |
print('theta deg: ', theta*180/np.pi) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment