Ask Your Question
1

custom trained SVM in hog.setSVMDetector (python)

asked 2015-05-24 10:20:53 -0600

joe minichino gravatar image

updated 2015-05-24 10:21:28 -0600

I successfully trained a svm with BOW in python (opencv 3). Now I would like to pass it to a hog with setSVMDetector. Is this possible or am I misunderstanding the use of the method? when i try to pass a trained svm to a hog detector like this:

svm = cv2.ml.SVM_create() # opencv 3.0-rc1 API
"""train svm..."""
hog = cv2.HOGDescriptor()
hog.setSVMDetector(svm)

i get TypeError: _svmdetector is not a numpy array, neither a scalar

I tried saving the svm to xml and then reload it and discovered the load() method in opencv 3 and discovered the load() method of SVM is gone.

edit retag flag offensive close merge delete

Comments

hog.setSVMDetector(something), expects a serialized float vector (made from a trained svm's support vectors, and rho) , definitely not the svm instance.

berak gravatar imageberak ( 2015-05-24 10:36:36 -0600 )edit

thanks @berak - is there a particular way to serialize the svm?

joe minichino gravatar imagejoe minichino ( 2015-05-24 10:38:30 -0600 )edit

you're mixing up ideas, that don't go together well.

BOW is a tecnique clustering float feature2d descriptors, like SIFT or SURF to a vocabulary (index) vector.

HOG is using different features, and is using it's svm in a much different way

tl;dr: i don't think, there's a pre-built way , to achieve , what you're trying)

berak gravatar imageberak ( 2015-05-24 10:45:12 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-05-24 10:50:07 -0600

joe minichino gravatar image

@berak thanks again, I was getting a bit adventurous there. As i said in the question i had a hunch I was misunderstanding the process.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-05-24 10:20:53 -0600

Seen: 2,233 times

Last updated: May 24 '15