Face recognition has already captured the whole world. All major countries already use this useful feature. Why not make people's lives even more convenient and not embed face recognition in a left-luggage office?

For this we need
- downloaded neural network facenet
- a computer
- keras
- opencv
From the beginning we import dependencies
from keras.models import load_model import numpy as np from keras.utils import plot_model import math import glob import os import cv2 import serial
model_path = 'facenet_keras.h5' model = load_model(model_path) cascade_path = 'haarcascade_frontalface_alt2.xml'
A function that formats a picture and drives it through a neural network
def calc_embs(imgs, margin, batch_size): fram1e = cv2.resize(imgs,(160,160)) ofg2 = np.array(fram1e) aligned_images = prewhiten(ofg2) pd = [] x_train = np.array([aligned_images]) embs1 = model.predict_on_batch(x_train) embs1.reshape(1,-1) embs = l2_normalize(np.concatenate(embs1)) return embs
A function that, when a button is pressed for the first time, saves a person’s face that has passed through a neural network, and a second time already, having driven a new face through the network, compares it with the saved face
Well and maine. It all starts with arduino when the letter B is fed through the wart, which means that the button is pressed. Next, a command is sent to the arduino to open the box and the function for recognizing and saving the face is launched. Then, if the command to press the button again came from the arduino, we again start the recognition function and if the faces converge, then open the box.
ser = serial.Serial('COM3', 9600, write_timeout=1, timeout=0.1) print(ser.name)
The video is attached.
How to distinguish a person’s face from a photograph of a person’s face - I have not yet thought.
Link to github where the script lies