First time here? Check out the FAQ!

Ask Your Question
0

Access EM means using Python?

asked Sep 10 '13

devmax gravatar image

trying to access the means after applying EM on a GMM: using code detailed here: http://docs.opencv.org/2.3/modules/ml/doc/expectation_maximization.html

but I get this error: AttributeError: 'cv2.EM' object has no attribute 'getMeans'

I am using opencv 2.4.5 (http://docs.opencv.org/2.4.5/modules/ml/doc/expectation_maximization.html) which only lists Algorithm::get() and Algorithm::set() functions for C++

How do I access the means and covariances using Python ?!

Preview: (hide)

1 answer

Sort by » oldest newest most voted
0

answered Sep 13 '13

Guanta gravatar image

There is an example under <your-opencv-folder>/opencv/samples/python2/gaussian_mix.py , it shows that you can access the mean and cov-matrices via getMat('means') and getMatVector('covs'), e.g.:

em = cv2.EM(...) // specify params inside
em.train(...) // train your em
// get mean and covariance matrices
means = em.getMat('means') 
covs = em.getMatVector('covs')
Preview: (hide)

Question Tools

Stats

Asked: Sep 10 '13

Seen: 741 times

Last updated: Sep 13 '13