问题
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