Create function to calculate a basis of PCA eigenvectors
Search for nearest neighbor among learned images
Finally got it working.