1 | initial version |
you have to train the SVM on hog features, not images
so, processing the train data should look like:
HOGDescriptor hog = new HOGDescriptor(new Size(160, 96), new Size(8,8), new Size(4,4), new Size(4,4), 9);
for (each image) {
Mat img = Imgcodecs.imread(file.getPath());
Mat newImg = new Mat();
Imgproc.cvtColor(img, newImg, Imgproc.COLOR_BGR2GRAY);
Imgproc.resize(newImg, newImg, new Size(160 , 96));
Mat descriptors = new Mat();
hog.compute(newImg, descriptors);
// now train your svm with the descriptors, not the images !
}