Emgu 3 and its fun quirks

Just spent a day finding out why Emgu seems to give me one hell of a time computing simple pca for a bunch of 2d points.

For some reason we are not sure and yet replicated across two dev machines, if you pass wrong matrix size as output parameters to functions like CVinvoke.calcCoVariance or CVinvoke.eigen it will crash the program but in very insidious ways with no error given except the output matrices just contain data of all 0s. And left you wondering what the hell went wrong….

Also calccovariance’s mandatory flag are apparently require “or” somehow in our layout such as “Emgu.CV.CvEnum.CovarMethod.Normal | Emgu.CV.CvEnum.CovarMethod.Cols” worked for us. Then afterwards the covariance matrix needs to normalize by array length size afterward…. In order to get the same results as numpy

Lastly, this one is on me: eigen value and vectors are arranged based on descending order in emgucv/opencv.

Almost have my pca working as intended to identify principle two dimensional clusters distributions…