Q:

OpenCV calculate covariance matrix with only one sample

I want to calculate the mean and the covariance matrix of samples. Is this possible even if the size of the sample is only 1? Because when I do:
calcCovarMatrix(descriptor, covar, mean, CV_COVAR_ROWS, CV_32F);

After execution the covar matrix is only 1x1 big and only contains 0 whereas descriptor is a row vector with 390 different float elements.

A:

Think of what the average and covariance mean in this case. If you only have a single sample, then:

the average is your only sample
there is no sample at a non-zero distance from the average, hence the covariance is zero.

Edit Note that if you wanted to calculate the average and variance of the 390 float values, you need to use CV_COVAR_COLUMNS instead of CV_COVAR_ROWS.

