5

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?

2
  • 1
    You might be use different version, please check opencv 3.0 code, this variable might be not exist in that. You have to use cv2.ml.SVM_LINEAR Commented Mar 20, 2016 at 3:26
  • @Lafada Thank you very much it worked.opencv 3.0 lot of changes.very confusing.Most examples in internet are opencv 2.4.x. Commented Mar 20, 2016 at 3:53

1 Answer 1

12

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.