1 | initial version |
the error means, that your hog feature had a different size, than those, you trained the svm on.
most likely, your test image had a different size, than the train images, too (larger image -> more features).
you have to keep the size of your train images around, and crop or resize() your test image to this, before extracting the hog features for the prediction:
Size trainSize = ...
resize(img, img, trainSize);
2 | No.2 Revision |
the error means, that your hog feature had a different size, than those, you trained the svm on.
most likely, your test image had a different size, than the train images, too (larger image -> more features).
you have to keep the size of your train images around, and crop or resize() your test image to this, before extracting the hog features for the prediction:
Size trainSize = ...
resize(img, img, trainSize);
apologies, i missed the elephant in the room: it has to be:
Ptr<ml::SVM> svm = ml::SVM::load("Features.xml");
(the load() method is static, and returns a new SVM. if you call it on an existing one, it does simply nothing, thus your svm is not trained yet)