Following in from part one, here is the second part of the series Jamie Craggs authored about our ongoing captive coral reproduction project in the amazing Ultra Marine Magazine.
I decided to have a go at doing something fun with my Kickstarter Rapiro this evening and got some inspiration from Tony DiCola on the AdaFruit blog (http://learn.adafruit.com/raspberry-pi-face-recognition-treasure-box?view=all).
So here are the steps I took and the script I put together for my Rapiro Facial Recognition 3am hack.
1. Install open CV
sudo apt-get update
sudo apt-get install build-essential cmake pkg-config python-dev libgtk2.0-dev libgtk2.0 zlib1g-dev libpng-dev libjpeg-dev libtiff-dev libjasper-dev libavcodec-dev swig
tar zxvf opencv-2.4.7.tar.gz
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_gpu=OFF -DBUILD_opencv_ocl=OFF
note: the make command takes about 5 hours!
sudo make install
2. Install Python Dependancies
sudo apt-get install python-pip
sudo pip install picamera
sudo pip install rpio
sudo apt-get install python-serial
3. Download Tony’s base project here from GitHub note that I deleted all the negative training images or it takes an age to run the final script.
4. Take Pictures of you – type c (and press enter) to capture about 10-12 images in different orientations and expressions.
sudo python capture-positives.py
5. Build the training file
6. Add my rapiro.py file to the folder
7. Try the script out
sudo python rapiro.py
8. If it works add it to a bash script on startup (Make sure you are in the pi folder)
sudo nano rapiroscript
type these lines:
sudo python rapiro.py (save and exit: Ctrl+X, Y, Enter)
sudo nano .bashrc Scroll down to the bottom and add the line: ./rapiroscript (save and exit: Ctrl+X, Y, Enter)
9. Finally auto login
sudo nano /etc/inittab
1:2345:respawn:/sbin/getty 115200 tty1
comment out like so:
#1:2345:respawn:/sbin/getty 115200 tty1
then add below this line:
1:2345:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1
10. You can add commands or play around with some different ones in the rapiri.py script
- #M1 – robot will move forward
- #M2 – robot will move backward
- #M3 – robot will turn right
- #M4 – robot will turn left
- #M5 – robot will raise his hand and wave the left hand. LED will become green and flashing
- #M6 – robot will lower his left hand. LED will become Yellow
- #M7 – robot will move both arm and contract his hands. LED will become Blue
- #M8 – robot will wave goodbye with his left arm. LED will become RED.
- #M9 – robot will raise its right arm and move its waist. LED will become BLUE
- #M0 – robot will go to initial position
- #PS00A000T010#PS00A180T010 – full head movement from side to side
- #PS01A000T010#PS01A180T010 – Waist
- #PS02A000T010#PS01A180T010 – r Shoulder
- #PS03A000T010#PS03A180T010 – r Arm
- #PS04A000T010#PS04A180T010 – r HAND
- #PS05A000T010#PS05A180T010 – l Shoulder
- #PS06A000T010#PS06A180T010 – l Arm
- #PS07A000T010#PS07A180T010 – l hand
- #PS08A000T010#PS08A180T010 – r Foot yaw
- #PS09A000T010#PS09A180T010 – r Foot pitch
- #PS10A000T010#PS10A180T010 – l Foot yaw
- #PS11A000T010#PS11A180T010 – l Foot pitch
or more here http://forum.rapiro.com/thread/21/
This is very useful for testing
sudo apt-get install minicom
echo "#M6" | sudo minicom -b 57600 -o -D /dev/ttyAMA0
And for viewing the PiCam on a Mac
nc -l 5001 | mplayer -fps 31 -cache 1024 - run this on your mac after installing brew then running
raspivid -t 999999 -o - | nc 192.168.1.9 5001 run this command on your Pi with your Macs IP
With Barnaby You can work flat out and hook up and get your ROV running on the bench at Reading Hackspace! Just some potting left to do 🙂
We’re getting a fetish for underwater toys and we’re getting good at it – I have a funny feeling this is just the beginning of something big!!