opencv3 EM.getCovs(covs)
what type should covs
be in getCovs(covs)
?
From the 3.0-beta c++, "Returns vector std::vector<Mat>& covs
of covariation matrices. Number of matrices is the number of gaussian mixtures, each matrix is a square floating-point matrix NxN, where N is the space dimensionality."
from this old opencv2 bug, I understand that "vector<mat> corresponds to a list of numpy arrays, not 3D numpy array (since matrices in vector can in general have different size.) "
from cv2 import ml
import numpy as np
def dictionary(descriptors, number_clusters=N):
covs = [np.zeros(( N, N), np.float64)]
em = ml.EM_create()
em.setClustersNumber(N)
em.trainEM(descriptors)
means = em.getMeans()
covs = em.getCovs(covs)
weights = em.getWeights()
return np.float32(means), np.float32(covs), np.float32(weights)[0]
printing out covs
just prints out the original [np.zeros(( N, N), np.float64)]
. Any body know how to get the covs?
Note that attempting to run this code will not work without fixing this bug and rebuilding.