OpenCV  3.4.4
Open Source Computer Vision
samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp

Check the corresponding tutorial for more details