Now the faces are matched by calculating the average distance fom a point of the webcam-face to a point of a face of the dataset. This goes on for every point in the face and every face in the dataset. This list of distances then get sorted. The first result (with least distance) gets choosen as a match.
Problem
The sorting may need a lot of time. After we have the match with the least distance, we do not need the other faces in the list.
Solution
Replace the sort-function with replace or even just use a variable and set it if the new comparison has a smaller distance than the one that is in the function.
How it works now
Now the faces are matched by calculating the average distance fom a point of the webcam-face to a point of a face of the dataset. This goes on for every point in the face and every face in the dataset. This list of distances then get sorted. The first result (with least distance) gets choosen as a match.
Problem
The sorting may need a lot of time. After we have the match with the least distance, we do not need the other faces in the list.
Solution
Replace the
sort
-function withreplace
or even just use a variable and set it if the new comparison has a smaller distance than the one that is in the function.