First try to apply a PCA directly, I think it's sufficient already. Then note, that mathematically a k-means method yields the same centroids as a PCA projection, see:
- Ding C., He X. "K-means Clustering via Principal Component Analysis" in Proceedings of the 21 st International Conference on Machine Learning, Banff, Canada 2004. [PDF Online Available here]
So there's no need to perform a k-means clustering on the projected samples. What I would try instead is to see, what clusters a Linear Discriminant Analysis yields. A Linear Discriminant Analysis is available as cv::LDA
in the contrib module of OpenCV:
Then I would play around with OpenCV's awesome machine learning library and see how a Multi Layer Perceptron performs or how a SVM performs on the image data (with different kernels).
Regarding Local Binary Patterns, there's a much simpler (and tested!) implementation in the face recognition code I provide. The OpenCV implementation in cv::FaceRecognizer is the same. I am linking to the original project (libfacerec), because everything is in one file there:
If you need some ideas on how to work with OpenCV machine learning, you can have a look into my Guide to Machine Learning with OpenCV:
There are also tutorials on using a SVM in the official OpenCV documentation: