Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

click to hide/show revision 2
No.2 Revision

updated 2016-03-26 01:49:01 -0600

berak gravatar image

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()

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)

response_list.append(i)

model = cv2.SVM() x = model.train(np.array(train_list), np.array(response_list)) model.save('trained.xml')

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

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

matrix

svm = cv2.SVM() svm.load('trained.xml')

svm.load('trained.xml')

svm.predict(img2)

svm.predict(img2)

Kindly help me resolve the above error.