facepunch: A facial recognition punch clock
facepunch tracks how many hours you spend sitting in front of your desk.
The concept is rather simple: the picamera takes a photo every 15 seconds, if my face is found, current time is recorded.
The logged time is then added up to calculate my exact working hours every week. The result is displayed on an OLED screen.
What you need
- Raspberry Pi Model B. It might work on Zero too but I don't have one to test with.
- Raspberry Pi Camera Module
- OPTIONAL 128x64 1.3 inch OLED display, search "1.3 oled" on ebay and alibaba for much cheaper ones. 0.96 inch OLED also works.
OLED is optional, skip related steps if you're not using one.
Get it working
Set up Raspberry pi
Wire up OLED display and camera
I placed the camera and OLED together on a perf board that plug into the header, of course you can put them somewhere else or design your own PCB.
Install required libraries
luma OLED library, install for python3.
Provide your photo
The program needs a picture of your face in order to learn what you look like. Get a picture of your well-lit face with a clean background, name it
me.jpg and place it in the software folder. The resolution should be around 400x400 otherwise the processing time is going to be long. An example is already provided so just replace it with your own.
Run the program
python3 detect.py to start face detection and logging.
python3 display_oled.py to display time statistics on the OLED.
Or if not using an OLED, run
python3 display_text.py to print the statistics to the terminal.
You might have to play with
camera.brightness at the beginning of
detect.py depending on how your camera is oriented and your lighting condition. You can open up
image.jpg to see the latest photo taken.
Default OLED reset pin is 17, change it to what you use in
All timestamps are in UTC. I'm in UK so this isn't a issue, but you can play with python datetime timezones if it bothers you.
It only keeps track of a single face since I made it for myself. However it's trivially easy to change it to recognize multiple faces.