0
votes

I am getting the above error. I Already installed opencv-contrib module but still not working out

def dictionary(descriptors, N):
em = cv2.EM(N)
em.train(descriptors)

Traceback (most recent call last):

File "", line 1, in runfile('C:/Users/Ankuran Das/Desktop/Pyhton/Case/fishvec.py', wdir='C:/Users/Ankuran Das/Desktop/Pyhton/Case')

File "D:\Anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile execfile(filename, namespace)

File "D:\Anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/Ankuran Das/Desktop/Pyhton/Case/fishvec.py", line 141, in gmm = generate_gmm(working_folder,args.number)

File "C:/Users/Ankuran Das/Desktop/Pyhton/Case/fishvec.py", line 87, in generate_gmm means, covs, weights = dictionary(words, N)

File "C:/Users/Ankuran Das/Desktop/Pyhton/Case/fishvec.py", line 16, in dictionary em = cv2.EM.train(N)

AttributeError: module 'cv2.cv2' has no attribute 'EM'

1
Can you show us how you import cv2?Pani
Also just in case, try: pip install --force-reinstall opencv-contrib-pythonPani
I have imported cv2 as - import math, cv2Jugasmita Kashyap
Could you edit your question to show the import and the full error traceback pleasePirateNinjas
yeah ...done ..can you please check now.Jugasmita Kashyap

1 Answers

0
votes

Try the following lines of codes:

em = cv2.ml.EM_create()
em.setClustersNumber(N)
em.trainEM(descriptors)