我打算用opencv2机器学习库创建svm来处理一些图像。我已经在这个网站上做了一些挖掘,我发现我需要将图像转换为矢量并从这些矢量中创建一个矩阵。但是我没有找到如何做到这一点的信息。请帮忙。请注意,我不是在使用python
答案 0 :(得分:0)
# pseudocode
svm = cv2.SVM() # getting the params right is a science of its own..
traindata, trainlabels = [],[]
for i in (my trainig data ):
traindata.extend(feature) # again, 1 flattened array of numbers
trainlabels.append(label) # 1 class id for the feature above
# now train it:
svm.train(np.array(traindata), np.array(trainlabels))
# after that, we can go and predict labels from new test input,
# it will return the predicted label(same one you fed to the training before...)
p = svm.predict(test_feature)
还look here,请!