Principal Component Analysis (PCA) with openCV

thought i would share some code snippet that i more or less copied from here:

i used it to give me the orientation of an array of points. in my case the array was the contour of a blob.

my blob rotated around it’s centre. but PCA was only good at 180 degree range.