How do I access Opencv-3.0.0's expectation maximization algorithm through Python

asked 2015-08-12 09:06:36 -0600

desri gravatar image


I am using Opencv-3.0.0 through Python 2.7.x on Ubuntu 14.04 LTS. I wanted to use the expectation maximization algorithm of Opencv. In Opencv-2.4.x the expectation maximization algorithm used to be accessed as cv2.EM. However, that doesn't exist anymore. I looked into, but did not find the EM class there.

Could anyone please help me out in that? The transition from Opencv-2.4.x to Opencv-3.0.0 is pretty arcane to me.

edit retag flag offensive close merge delete



really ?

import cv2
import numpy as np

data = np.ones((10,10), np.float32)

em =
covs = em.getCovs() # this was fixed only 2 weeks ago, so you might need an update

also try a :

>>> help(
berak gravatar imageberak ( 2015-08-12 09:18:24 -0600 )edit doesn't exist in my Python API. Does that mean I need to download an updated source and reinstall all over again? Please confirm.

desri gravatar imagedesri ( 2015-08-12 09:21:58 -0600 )edit

ohhh, most probably, - yes, and please, from github src.

(there was an early time, when none of the ml classes were actually wrapped into python. (in that case, a help( will only give you a list of constants) when did you download it ?)

berak gravatar imageberak ( 2015-08-12 09:26:00 -0600 )edit

Yes, that's what I have. I only get a list of constants. Should clone Opencv-3.0.0 beta or alpha version for this? Thanks for your help in advance.

desri gravatar imagedesri ( 2015-08-12 09:35:28 -0600 )edit

just git clone (or better git pull, if you already have a local git repo) from here . also, future updates will be pretty easy using git pull upstream master

berak gravatar imageberak ( 2015-08-12 09:52:00 -0600 )edit