I am using C++ with OpenCV 3.0.
I have a training data matrix with features that I have extracted of some images (trainData). The size of this matrix is 2750x1104 because I have 2750 images (positive and negative) with 1104 features each. I have other matrix of 2750x1 with the labels (trainLabels).
- trainData: 2750 images x 1104 features.
- trainLabels: 2750 images x 1 label per column
With this information I want to train a SVM and I would like to evaluate the performance of using PCA (Principal Component Analysis), LDA (Linear Discriminative Analysis) and a combination of both. I have applied PCA without problems but when I use LDA I obtain a matrix of 2750x1 (projected) that the SVM cannot use as input.
I have used this link, but they do not employ SVM.
This is the code:
LDA lda(trainData, trainLabels, num_components);
Mat eigenvectors = lda.eigenvectors();
Mat projected = lda.project(trainData);
I have selected num_components as 1 because I have two classes (person & no person).
And these are my results:
- eigenvectors: 1104 rows x 1 column
- projected: 2750 rows x 1 column
As far I understand eigenvectors should be 1104x1104 and projected 2750x1104 so the SVM can be trained with the matrix projected.
I don't know if I am really wrong in the code, maybe I do not understand correctly how LDA works. If so, could you give me some tips? In fact, could I train a SVM with LDA?
Thanks in advance.