First, let's understand how the PCA class works in OpenCV. We can conclude from the documentation that the PCA class is used to compute a special basis for a set of vectors,which consists of eigenvectors of the covariance matrix computed from the input set of vectors. This class can also transform vectors to and from the new coordinate space, using project and backproject methods. This new coordinate system can be quite accurately approximated by taking just the first few of its components. This means we
can represent the original vector from a high-dimensional space with a much shorter vector consisting of the projected vector's coordinates in the subspace.