How to normalise the HoG feature vector, to be able to use it for SVM? [closed]
This is where i reached so far, need some help to be able to move to the svm part:
Can you please help?
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/video/tracking.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/objdetect/objdetect.hpp>
using namespace cv;
using namespace std;
int main() {
HOGDescriptor hog; // Use standard parameters here
hog.winSize = cv::Size(40, 40); // Default training images size as used in paper
cv::Size trainingPadding = cv::Size(0, 0);
// specific parameters
hog.cellSize = cv::Size(5, 5);
hog.blockSize = cv::Size(10, 10);
hog.blockStride = cv::Size(5, 5);
hog.nbins = 8;
cv::Size winStride = cv::Size(5, 5);
// default parameters
/*hog.cellSize = cv::Size(8, 8);
hog.blockSize = cv::Size(16, 16);
hog.blockStride = cv::Size(8, 8);
hog.nbins = 9;
cv::Size winStride = cv::Size(8, 8);*/
vector<float> featureVector;
Mat imageDataRaw = imread("C:/Users/nuzha/Desktop/Canny.jpg", 0);// read an image
Mat imageData;
resize(imageDataRaw, imageData, hog.winSize);
// Check for mismatching dimensions
if (imageData.cols != hog.winSize.width || imageData.rows != hog.winSize.height) {
featureVector.clear();
printf("Error: Image '%s' dimensions (%u x %u) do not match HOG window size (%u x %u)!\n", "C:/Users/nuzha/Desktop/Canny.jpg", imageData.cols, imageData.rows, hog.winSize.width, hog.winSize.height);
return -1;
}
vector<Point> locations;
hog.compute(imageData, featureVector, winStride, trainingPadding, locations);
return 0;
}