1 | initial version |
if you wanted to reduce the size(length) of your hog features, you have to do a projection with the eigenvectors from the PCA, not use the eigenvectors themselves.
// assuming, you have 1000 hog vectors, each with a length of 200:
Mat hogvecs(1000, 200, CV_32F);
// do the PCA, and retain only 50 eigenvecs:
PCA pca(hogvecs, Mat(), PCA::DATA_AS_ROW, 50);
// equivalent to: (hogvecs-mean) * eigenvecs
//
Mat reduced = pca.project(hogvecs);
cout << reduced.size() << endl;
// [50x1000]
so, it still has 1000 features, and we shortened the length of the features from 200 to 50.
2 | No.2 Revision |
if you wanted to reduce the size(length) of your hog features, you have to do a projection with the eigenvectors from the PCA, not use the eigenvectors themselves.
// assuming, you have 1000 hog vectors, each with a length of 200:
Mat hogvecs(1000, 200, CV_32F);
// do the PCA, and retain only 50 eigenvecs:
PCA pca(hogvecs, Mat(), PCA::DATA_AS_ROW, 50);
// equivalent to: (hogvecs-mean) * eigenvecs
eigenvecs.t()
//
Mat reduced = pca.project(hogvecs);
cout << reduced.size() << endl;
// [50x1000]
so, it still has 1000 features, and we shortened the length of the features from 200 to 50.