Running face recognition

The last topic I would like to cover in the chapter is trying to match different images of the same person, to see whether we can build a face recognition model based on FREAK.

I have taken two images of a young woman and cropped the area around her face, assuming this would be the output from a camera. This is the image:

Let's proceed to the Julia code and run the images there, using this code:

using Images, ImageFeatures, ImageDraw, ImageView

img1 = Gray.(load("sample-images/beautiful-1274051_640_100_1.jpg"))
img2 = Gray.(load("sample-images/beautiful-1274056_640_100_2.jpg"))

Next, we find the keypoints and match them together with the help of FREAK by using this code:

keypoints_1 = Keypoints(fastcorners(img1, 12, 0.25));
keypoints_2 = Keypoints(fastcorners(img2, 12, 0.25));

freak_params = FREAK()
desc_1, ret_keypoints_1 = create_descriptor(img1, keypoints_1, freak_params);
desc_2, ret_keypoints_2 = create_descriptor(img2, keypoints_2, freak_params);
matches = match_keypoints(ret_keypoints_1, ret_keypoints_2, desc_1, desc_2, 0.2)

The moment the keypoints are matched, we can plot the results using theĀ ImageDraw package by using this code:

grid = Gray.(hcat(img1, img2))
offset = CartesianIndex(0, size(img1, 2))
map(m -> draw!(grid, LineSegment(m[1], m[2] + offset)), matches)
imshow(grid)

The results are disappointing. The algorithm could not handle the different images of the same person, and I would not try running the face-recognition system using the preceding methods because of the low quality. There is no doubt we can spend more time on image adjustment, but the main question is this: is it worth it? Take a look at these images: