Proposed Lamp name: LamPi
We are aiming at having work flow as presented on above diagram, we believe it can be achieved using following pseudo implementation:
1.Mutex lock on servos X,Y coordinates.
2.Camera thread captures a frame, finds face on it and writes to servos X,Y coords.
3.Release mutex lock.
1. Acquire mutex lock on servos X,Y coordinates and move distance/direction.
2. Calculate distance and servo movement direction.
3. Move servos.
4. release move distance/direction locks.
5. Call play() method in Audio thread.
6. Monitor for when servo reaches its desired position.
7. Call stop() method in Audio thread.
8. Release locks.
1. Acquire mutex lock on move distance/direction.
2. Use distance and direction to choose appropriate sound/modulation.
3. Release locks on Stop.
|Basic Class diagram|
- Servos to be controlled via PWM signals from Raspberry PI
- Current levels maybe be an issue if servo requires too much current from Raspberry Pi
- RPIO may be a better solution to driving the GPIO pins
- Might be more convenient to calculate a position for the servo 0 -255. Don’t think Raspberry Pi supports this. Maybe need to implement code to determine necessary PWM signals to reach and maintain a position.
Python libraries worth investigating:
OpenCv 2.4.9 http://docs.opencv.org/2.4.9/
In this sprint we set out with following goals:
Tasks to be complete
- Raspberry Pie running open CV with on board camera
- Controlling servos
- Simple vision system interactions to control a pan and tilt servo mechanism.
- Sounds effects to play over the movements.
Raspberry Pi running OpenCv with on board camera:
- Script to demo its working.
- Threaded class to write to x,y coordinates of the detected face.
- Simple control script to demo how it works to the team.
- Threaded class that takes x,y coordinates as target and moves servos into this position.
- Extend threaded class so it can trigger audio thread to play and stop.
- Script to play wav file
- Threaded class with play() and stop() method
- Extend threaded class so it can modulate sound depending on servo movement distance.
Timeline and task assignment
Raspberry Pi running OpenCv with on board camera
This step could be done in two ways:
- build from sources (8hr)
- use older version of prebuilt opencv (30m)
We chose option 2 due to significant time saving, to get OpenCV running with Python using Pi camera module we had to run following commands:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo rpi-update
$ sudo apt-get install libopencv-dev
$ sudo apt-get install python-opencv
$ sudo apt-get install python-dev
last step was to enable camera in the raspi config.
Running simple example script for face detection worked pretty well considering that protective film was still on the camera lens. Below is our placeholder image until we can take full team photo using Rpi with face detection.
Our Rpi runs Python 2.7.1 and OpenCV 2.4.9