Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 2088

Same Code works with LinearSVM but not RBF

$
0
0
When I use **trainAuto** method of SVM, I get the value 2 for `getKernelType()` but when I use the `RBF` in my code, it trains my file and outputs the XML file. svm = cv2.ml.SVM_create() svm.setType(cv2.ml.SVM_C_SVC) svm.setKernel(cv2.ml.SVM_RBF) svm.setGamma(0.0025) svm.setC(0.5) svm.train(samples, cv2.ml.ROW_SAMPLE, labels) svm.save('svm_data.xml') Above code works for me. But when I moved to prediction part with below code hog = cv2.HOGDescriptor((100,200), (16,16), (8,8), (8,8), 9) svm = cv2.ml.SVM_load('svm_data.xml') sv = svm.getSupportVectors() rho, alpha, svidx = svm.getDecisionFunction(0) svm_new = np.append(sv, -rho) hog.setSVMDetector(svm_new) It shows be below error error: (-215:Assertion failed) checkDetectorSize() in function 'cv::HOGDescriptor::setSVMDetector' But **when I change RBF with LINEAR** it works for me in prediction part. When I check print (hog.checkDetectorSize()) print (hog.getDescriptorSize()) It returns `True` for DetectorSize and `26676` for DescriptorSize

Viewing all articles
Browse latest Browse all 2088

Trending Articles