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

十年热恋 提交于 2019-12-22 07:47:09

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/36109874/attributeerror-module-object-has-no-attribute-svm-linear

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!