The other day my friends and I were playing Spyfall, a party game similar to Mafia, and I was thinking about how a lie detector could help us. I decided that I didn't want to make a conventional lie detector, but one based on facial recognition.

Bluff Finder records your expressions and emotions whenever you press t or b. When you press t it records your expressions as a truth, but b records it as a bluff. The program records your expressions based on a set of scores. You get a score for how happy you are, angry, sad, afraid, surprised, neutral, and disgusted. Once you record enough data it will scan your face to see if the current scores are closer to the average truth or bluff scores.

I used Visual Studio Code and Python programming language. I used cv2 and deepface for camera access and facial recognition. I used matplotlib libraries to edit the footage I receive and play it back. I coded a program that would analyze your emotions using deepface and record the scores for each emotion. I took the average of all the data so far and stored it in two arrays. One for truth and one for disgust. If at least 5 sets of data were taken for each, lie and truth, the program would analyze your current face and record the emotions seen. If the emotion scores were closer to bluff then you were lying, otherwise, you were telling the truth.

Originally, I tried to use eye movements and eyebrow movements. However, at different angles, you would get different values. This caused the program to be undecided on whether you were telling the truth or not. Eye movements also didn't help with determining the truth so I decided to remove that section of the code and use purely expressions. Also, I use the average value of the scores to determine if you are lying. At first, I tried to use regressions to estimate if you were lying or not but that was not as accurate and required more data points.

I am very glad that my code works and this is a type of project I haven't attempted during a hackathon. Through hours of testing and fine-tuning, I managed to find code that works. I am proud of accomplishing such a feat!

Surprisingly enough, I learned that the simplest solution is the best. Not only is my code much more compact than before, but it also works faster, off of less data, and is more accurate. The frame of the output is now also faster since I am not checking for eye movements.

I would like to make this even more detailed. Currently, my program does not work unless the entire face is shown and it is not tilted too much or moving too much. Also, a good liar could keep their face as neutral as possible and it has a good chance of passing. I would like to address these issues.

Built With

Share this project:

Updates