A few months ago, I modelled and printed one of my colleague's head for fun. I thought It would be funny to push the joke and build a mechanism for this head which can detect people and keep staring at them as they move around the room.
I struggled to make the mechanism small enough to fit my 3D print so instead of locking the project in a cupboard forever and forget about it, I decided to make an easy to assemble model with a easy to use software for everyone to enjoy and build upon.
How does it work?
The camera moves using two servos driven by an Arduino Uno. The camera is plugged to a computer where a software tries to find faces in the images received from the camera.
If a face is found, the software will send a message to the Arduino to make the camera move in order to get the detected face in the centre of the image.
If no face is found, the software will send a message to the Arduino to make it move to a random position.
I tried to make the software quite flexible with option such as:
- modifiable servo ranges
- possibility to invert the servos rotation
- manual control
Hopefully this will make it easy to reuse it for other purposes.
I also added 3 LEDs that show the state of the detection, red for no detection, yellow when a face is detected but not in the center of the image, and green when a face is detected and in the center of the image.
The LEDs are not very interesting on their own but it should be easy to modify the device to perform a useful action instead of just turning ON and OFF a few lights.
The communication between the Arduino and the software is done through serial communication (via USB).
The face detection software was written in Python. I left all the Python files on GitHub in case you want to have a look at the code (warning : it's probably not great, I am learning on my own) or reuse them for your own project.
If Python isn't your thing you can also download the executable version on my website.
If you want to build your own, check the following videos. I tried to make them as easy as possible to follow, I hope I did a good job at that.
Everything you need
Software and setup