Creating a dataset from an image using Python for face recognition

I am trying to code a face recognition program in Python (I am going to use the k-nn algorithm for classification).

First of all, I converted the images to grayscale, and then created a long column vector (using the Opencv imagedata function) with image pixels (128x128 = 16384 functions)

So, I have a dataset, such as the following (the last column is the class label, and I showed only the first 7 datasets instead of 16384).

176, 176, 175, 175, 177, 173, 178, 1 
162, 161, 167, 162, 167, 166, 166, 2

But when I apply k-nn to this dataset, I get inconvenient results. Is it necessary to apply additional processes to this data set, and not just convert the image into a pixel representation?

Thank.

+3
source share
4 answers

If you want it to work well, yes, you need to do the conversion of objects.

PCA or LDA work well. The PCA will take a collection of input vectors (in this case, your vectorized images) and find Eigenfaces that span multiple inputs. Then, during testing, you project your input vector (i.e., Image) onto this set of Eigenfaces and use the resulting coordinate vector as your vector function. For more information, see [ Turk and Pentland, 1991 .

PCA PIE database .

+1

, , , .

, . , .

+1

, , . . , , , . opencv getAffineTransform. , . (, ), ( ). , (PCA) (LDA). , , , , LBP, HOG SIFT. , , KNN, ( ) , SVM.

+1
source

How do you print this? Have you tried using the reshape function? It converts 2D images to 1D images with / without multiple channels.

In addition, image pixels are not features . You can have many different objects behind your face - curtains, books, other faces, etc. Things like the border of the face, the distance between the eyes, etc., are more invasive of such things.

0
source

All Articles