Summary
This painting was exhibited in Berlin during Pictoplasma 2014 Festival.
Eyes are following visitors (if many, change randomly).
It’s powered by a Raspberry Pi, C++ Code and Open CV (using Face Recognition)
Software written by Pierre Raufast (France)
Animatronics, Design and Built by 3753% Tordal (Norway)
More infos : tordal.no, raufast.org, thinkrpi.wordpress.com
Pictures
Technical Stuff – Face Recognition
Software is based on Raspberry Pi and strongly inspired from my previous “OpenCV and Pi camera” posts.
For face recognition, software is very easy : it only detects faces, without recognizing people. It’s fast.
face_cascade.detectMultiScale(imageMat, faces, 1.1,3,CV_HAAR_SCALE_IMAGE,Size(80,80));
g_nVisitors = faces.size(); // number of visitors found
Once faces are detected, instructions are sent to servos to move eyes. Actually, it looks like a physical version of XEyes, for old good X11 geeks 😉
The code implements a lot of funny behaviors :
- if unique visitor, follow him
- if many visitors, randomly change
- if a new visitor appears, focus on him
- if nobody, search visitors with funny eyes moves
- sometimes, take a nap, close eyelids.
- …
The tricky part was how to remember which visitor is where, frame after frame. And, when the face is lost while few seconds, be able to remember this visitor was already here (it’s not a new one, no need to focus on him/her).
Technical Stuff – Servo Control
Eyes are controlled by 2 servos (horizontal and vertical moves). Eyelid is controlled by a third servo. Thanks to ServoBlaster, control servos with Raspberry Pi is really very easy. To move servo using shell (for testing), just type : (0 = 1st servo, % = between 0-100)
echo 0=50% >/dev/servoblaster
echo 0=10% >/dev/servoblaster
and in C++ (fflush is important !)
FILE * servoDev;
servoDev=fopen(“/dev/servoblaster”,”w”);
fprintf(servoDev, “%d=%d%%\n”,ServoId,ServoPosition); //will be in a function
fflush(servoDev); // will be in a function
fclose(servoDev);
I used :
- Servo 0 (Horizontal Move) = GPIO 4 = Pin 7
- Servo 1 (Vertical Move) = GPIO 17 = Pin 11
- Servo 2 (Eyelid Move) = GPIO 18 = Pin 12
- GND pin is connected to gnd servo power
Acknowledgements
Thank you Bard (from 3753% Tordal) to give me opportunity to work on such funny project ! and to show our work during Pictoplasma Festival in Berlin ! (Next : Mexico…)
Thank you Richard for your wonderful and easy-to-work-with ServoBlaster Daemon.
And Thank you Nat for your patience during all these sundays, spent in front of my Raspberry… 🙂
Pingback: Animatronics and a #RaspberryPi come together to make art | Raspberry PiPod
Pingback: Grappig: Kunstwerk met Raspberry Pi dat je aan blijft kijken
Hi,
Amazing post ! Does it possible to share both hardware and software sources ?
Thanks !
I am also interested in seeing both the hardware and software sources, and maybe a tutorial! I would love to build one of these to greet visitors at my office!
Cool project. Perfect for a science fest. I enjoyed reading and going through the magic mirror post. Is it possible to share the c++ code for this project also?
It would be great Pierre if you could shed some more details on this project as I intend to design a tweaked version of this project as my final year project for my bachelors course. I have already started work on it but have met some stumbling blocks, I am using the codes made available from your previous works. You have done a wonderful job! Keep up the good work! A little bit insight on this project might just help me bump my GPA for the course!
I’d second the requests for a little more info into the specifics – it’s such a fun project it’d be great to explore and learn more!
Pingback: My Raspberry at Mexico ! | Think RPI
How to use openCV C++ code with GPIO pins of Raspberry???