SVM TRAINING FOR LICENSE PLATE DETECTION
I am currently working on License Plate recognition using custom HoG and SVM. I have the features of my image data set extracted and saved in an xml file. Here is the code:
train_list = []
response_list = []
hog = cv2.HOGDescriptor()
for i in range(2,7):
img = cv2.imread(str(i) + "_.png")
h = hog.compute(img)
train_list.append(h)
response_list.append(i)
model = cv2.SVM()
x = model.train(np.array(train_list), np.array(response_list))
model.save('trained.xml')
However, when I use SVM predict to classify if a certain image is positive or negative, I get the following error:
Input sample must have 32fC1 type in function cvPreparePredictData
Here is my code for using svm predict method:
img = cv2.imread('2.jpg',cv2.IMREAD_COLOR)
img2 = img.ravel() #conversion to a 1D matrix
svm = cv2.SVM()
svm.load('trained.xml')
svm.predict(img2)
Kindly help me resolve the above error.