Ask Your Question
2

opencv3 Expectation Maximization Python getCovs

asked 2015-07-23 10:01:31 -0500

l3an gravatar image

How do I use the em.getCovs() function in python with opencv3?

def dictionary(descriptors, N):
    em = cv2.ml.EM_create()
    em.setClustersNumber(N)
    em.trainEM(descriptors)
    means = em.getMeans()
    covs = em.getCovs()
    weights = em.getWeights()
    return np.float32(means), np.float32(covs), np.float32(weights)

I keep getting a AttributeError: 'cv2.ml_EM' object has no attribute 'getCovs'

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-07-23 10:28:50 -0500

berak gravatar image

updated 2015-07-23 10:42:59 -0500

that is opencv3, correct ?

if so, - easy answer - getCovs() does not have a CV_WRAP tag, while predict2() has 2 of them... now, guess, what happened ;)

ofc, the honour to fix it is yours, now. just tell me, if you don't feel like doing so, in that case i'll go and make pr.

edit flag offensive delete link more

Comments

haha i see. please do make the pr if u don't mind

l3an gravatar imagel3an ( 2015-07-23 11:21:30 -0500 )edit

yes it is opencv3. Once fixed, will I need to rebuild opencv from scratch?

l3an gravatar imagel3an ( 2015-07-23 11:23:22 -0500 )edit

ok, i'll do it.

still, unless that's merged into trunk, you'll have to applythe same fix locally, and rebuild (starting with a cmake run)

berak gravatar imageberak ( 2015-07-23 11:27:46 -0500 )edit

thanks for reporting a bug, there we go

berak gravatar imageberak ( 2015-07-23 11:45:13 -0500 )edit

got it. thanks 4 your help.

l3an gravatar imagel3an ( 2015-07-23 11:46:30 -0500 )edit

(sidenote:) see, that was a pretty easy one.

again, there's probably only a handful devs at opencv.org, and like 7 mil users. we definitely need more folks engage in the middle..again, some sort of a plea : if you find something, - get bold !

berak gravatar imageberak ( 2015-07-23 12:25:49 -0500 )edit

plea acknowledged and accepted. I will definitely start contributing...

l3an gravatar imagel3an ( 2015-07-23 12:47:46 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-07-23 10:01:31 -0500

Seen: 559 times

Last updated: Jul 23 '15