Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

the syntax has changed a bit from 2.4. to 3:

svm = cv2.ml.SVM_create() self.model.setKernel(cv2.ml.SVM_LINEAR) svm.train(np.array(traindata), cv2.ml.ROW_SAMPLE, np.array(trainlabels))

the syntax has changed a bit from 2.4. to 3:

# it's all in a cv2.ml submodule now
help(cv2.ml)

svm = cv2.ml.SVM_create()
self.model.setKernel(cv2.ml.SVM_LINEAR)
cv2.ml.SVM_create() #you need a 'create' function for all ml classes
svm.setKernel(cv2.ml.SVM_LINEAR) #getters & setters for all params
svm.setType(cv2.ml.SVM_C_SVC) 

svm.train(np.array(traindata), cv2.ml.ROW_SAMPLE, np.array(trainlabels))

np.array(trainlabels))