unable to find KNearest and SVM functions in cv2?

asked 2015-02-13 05:29:43 -0600

Maryam gravatar image

I am using open cv 2.4 and python 2.7 and ubuntu 14.04 when i write a code as knn=cv2.KNearest()

error comes: knn=cv2.KNearest().find_nearest() AttributeError: 'module' object has no attribute 'KNearest'

I have tried everything. PLz help

edit retag flag offensive close merge delete

Comments

2

try a cv2.__version__ .

if it turns out, you're using opencv3.0, not 2.4 as you think, then the answer is:

the ml classes in opencv3.0 had to be temporarily (i hope) disabled, the wrapper scripts have some problems with the latest refactoring of the ml module (can't handle inner classes)

berak gravatar imageberak ( 2015-02-13 05:39:51 -0600 )edit

I have installed opencv 3.0 now but still error remains same.

Maryam gravatar imageMaryam ( 2015-02-13 07:19:22 -0600 )edit

oh sorry, it's the other way round : ifyou want to use any ml functionality from python, you will have to use 2.4.x (until this issue gets fixed in 3.0)

berak gravatar imageberak ( 2015-02-13 07:32:57 -0600 )edit

Yes! but in start i was using 2.4.x version but still encountered this problem. That's why thought of changing version. There is some issue related to installation of open CV that it cannot find these functions, others are available. Thanks for replying

Maryam gravatar imageMaryam ( 2015-02-13 07:41:39 -0600 )edit