Ask Your Question
0

Access EM means using Python?

asked 2013-09-10 14:41:47 -0600

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 ?!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-09-13 09:00:25 -0600

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')
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-09-10 14:41:47 -0600

Seen: 721 times

Last updated: Sep 13 '13