user4960127
user4960127

Reputation:

AttributeError: 'module' object has no attribute 'SVM_LINEAR'

I have installed open cv 3.0 then i installed libsvm.Then i addded that to my pycharm packages.But still when typing this code

svm_params = dict( kernel_type = cv2.SVM_LINEAR,
                svm_type = cv2.SVM_C_SVC,
                C=2.67, gamma=5.383 )

it shows this error

svm_params = dict( kernel_type = cv2.SVM_LINEAR,
AttributeError: 'module' object has no attribute 'SVM_LINEAR'

i tried import libsvm but it didn't work.please help. Is opencv 3.0 is ok should i go back to 2.4?

Upvotes: 6

Views: 6503

Answers (1)

Neel
Neel

Reputation: 21243

You are accessing SVM_LINEAR with cv2, but SVM_LINEAR is attribute of ml.

You have to access SVM_LINEAR as cv2.ml.SVM_LINEAR

Upvotes: 12

Related Questions