The firmware written for this project can be found in our GitHub repository. Below is a list of the files found in the repository and their functions:
haarcascade_frontalface_alt.xml - a popular predefined haar cascade file that contains the data for the frontal view of a face in order to set the OpenCV cascade classifier.
laptopcam.py - the main python code that is run on a Windows 10 laptop with a web camera to do facial recognition with the above file as well as the DeepFace Library to send the live emotions of a user to the Arduino that controls the music box servos.
music_box.ino - the main Arduino code that receives serial data from the laptop and controls the music box servos with several hard coded songs.
music_motor.ino - a simple file that runs on the second Arduino to spin the motor that rotates the music box gears.
The first two sprints of this project had entirely different sets of code as the programming side of this project was originally using only using IR sensors and driving two motors. However this shifted into attempts to use a Raspberry pi with OpenCV to do color masking however setting up dependencies and communicating between the pi and Arduino proved to be a challenge when we had not even begun to work on writing songs into them. During the second sprint there was some consideration for using MIDI files but after several iterations of trying to dissect it in python or slicing up the MIDI with Mido to send in serial, it was proving too complicated to be achieved in the short time period, especially on an Arduino that was already going to be running 15 servos. Thus we scoped down to the current project as outlined above.
This project uses a Windows 10 computer with a webcam and an Arduino Uno that is plugged into the laptop with a USB-USBA cable. The Arduino is connected to a PCA9685 (library here) Adafruit PWM servo driver as fifteen servos are used to play notes on a music box. Note: Serial monitor cannot be open at the same time as running the python code.Currently the code and its dependencies work on Windows 10, the following things will need to be installed:
created with
WYSIWYG HTML Editor .