2010/08/26
Face detection with Nokia N900, using ROS and OpenCV
by
Sébastien Lelong
—
posted at
2010-08-26 11:18
last modified
2010-08-26 11:18

This post is about a small recipe to perform face detection using Nokia N900 phone. It's based on ROS and OpenCV and shows how these components are mixed together and configure. See this OpenCV wiki page about face detection to understand how it works behind the scene.
First of all, ROS needs to be installed on N900. I've built several ROS packages, including latest offical release, code name "C turtle". I assume you know how to ssh to your N900 and gain root access.
Disclaimer
Careful while tinkering with your N900, you may "brick" it (if you don't know what I mean, close this page). And I wouldn't be responsible if this would occur, or if anything would turn into something bad. You've been warned.Setting up ros-n900 source
I've created a Google Code project dedicated to N900 ports and package developments. This project can be reached at http://code.google.com/p/ros-n900/. In download section, you'll find deb packages. You directly download them to your N900, or configure a new APT source pointing to this project:$ echo "deb http://ros-n900.googlecode.com/files /" >> /etc/apt/source.listNow install ROS with apt-get:
$ apt-get update
$ apt-get install ros-cturtle-baseThis will install ROS on /opt partition (usually 2GB ext3 space), leaving rootfs untouched. ROS uses ~500MB to install. You can also install it on a (fast) SD-card, formatted using ext3 filesystem (don't use FAT32). You'd then need to create a symlink /opt/ros-cturtle-base pointing to your SD-card.
Accessing N900 webcams under ROS
brown-ros-pkg project hosts gscam, a very nice ROS packages used to access camera with GStreamer. Since N900 webcams are recognized as V4L2 devices, it's easy to setup a gstreamer pipeline. First install dependencies. On N900:$ apt-get install gstreamer-toolsThis example shows how to send videos to PC host using UDP. Device /dev/video0 is back camera (big one, high resolution), /dev/video1 is the front one (small resolution).
# On N900, assuming 192.168.2.14 is PC's IP address (usually true if following usbnet howto tutorial)Here we are! A small window appears broadcasting N900 videos. You may even see your face. Install some more dependencies to build ROS package. On N900:
$ gst-launch v4l2src device=/dev/video1 ! videoscale ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! smokeenc ! udpsink host=192.168.2.14 port=1234
# On PC computer:
$ gst-launch-0.10 udpsrc port=1234 ! smokedec ! autovideosink
$ apt-get install libgstreamer0.10-devNow go to ROS stacks directory.
$ roscd
$ cd ../stacks
Install gscam package. Follow instructions here, download gscam archive in download section or install it from sources.
$ svn co -r 682 http://brown-ros-pkg.googlecode.com/svn/trunk/unstable/gscam gscam
Once installed, build it using rosmake:
$ roscd gscam
$ rosmake -i
(requires quite a lot of time, be patient...)
gscam requires environment variable GSCAM_CONFIG to be set. It stores gstreamer pipeline definition. I had lots of troubles running the correct pipeline, and finally got help from ros-users list. The trick is to convert YUV format (the only N900 cams seem to output) into RGB.
$ export GSCAM_CONFIG="v4l2src device=/dev/video0 ! videoscale ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! video/x-raw-rgb ! identity name=ros ! fakesink"
You can manually check it's working without ROS:
$ gst-launch-0.10 $GSCAM_CONFIGIf it pauses, that's ok. Now run it using gscam node. It requires to run within "bin" directory.
$ roscd gscamAt this time, gscam should say it's "processing..." (of course, a reachable roscore should run somewhere, for instance on PC host). Now back on PC, install n900-cam package.
$ cd bin
$ rosrun gscam
$ roscdNow run n900-cam testcam.py node. It'll retrieve images from image_topic subscription, add a circle and display the result in a window (from ROS tutorials).
$ cd ../stacks
$ svn co http://ros-n900.googlecode.com/svn/trunk/src/n900-cam
$ roscd n900-cam
$ rosmake -i
$ rosrun n900-cam testcam.pySo far so good. Let's face detect ourself ! This is closed to previous example, except now images are submitted to OpenCV for face detection. Code is coming from OpenCV samples and is glued here to work with a ROS node.
$ rosrun n900-cam facedetect.pyIf you can see yourself with a red square around your face, that's good news. If not, either you're not human, either something is wrong with running configuration...

- Category(s)
- Geek
- SirBot Project
2010/08/19
ROS on Nokia N900
by
Sébastien Lelong
—
posted at
2010-08-19 10:02
last modified
2010-08-19 10:02
I've recently bought a Nokia N900 smartphone. It's described as an Internet Tablet with phone capabilities. Interesting thing is 100% linux based, you can have full root access. On paper, this phone is awesome, in reality, it suffers from a lot of half-baked applications, poorly maintained software but, still, this opens to lots of tinkering...
On the other side, I've also discovered ROS. ROS stands for Robotic Operating System. It's robotic framework, offers distributed computing over nodes, pubsub architecture for inter-processes message exchanges. It can be programmed using C++, python and other less supported language. It's developped by Willow Garage, the guys who built robot PR2. If you've ever searched a flexible, powerful and fun robotic framework, or even wanted to develop your own (...), you definitely need to give ROS a try.
There are lots of advantages running a PC based robot. For instance you can easily plug a USB webcam and give vision to your robot. For minimal cost. Doing this with an embedded cam, like CMUCam, is certainly fun and interesting but in the end, performances can't be compared and you'll sure need some power computing to process incoming images. There are existing tiny PC, based on ITX motherboards for instance in order to do this. You can install Linux, put ROS on it and start to build your Linux powered robot. But, wait, I also have a very, very small form factor Linux PC, my N900... Why not using it as a robotic platform ?
It provides:
Doesn't it sound awesome as your main robotic platform ?
- 2 webcams (front, back)
- 3-axis accelerometer
- GPS
- high resolution touchscreen
- micro-USB connector, can be used as a USB host with some tinkering
- Wifi
- bluetooth
- Infra-red beam
- RGB LED
- 32GB memory, extendable to 64GB with microSD cards
- microphone
- speaker
- ambient light sensor
Doesn't it sound awesome as your main robotic platform ?
The idea is thus to install ROS on N900. Low-level tasks, such as actually activate motors, collecting sensor data, should remain on a microcontroller board, like Jaluino. All collected data and actions should go through N900, acting as a hub, performing some pre-processing tasks before delegating more power-consuming tasks to a PC around there, also running ROS.
It's been a while since I've already install ROS on N900. There were lots of trials and errors, highly time consuming, but it definitely worth it! I've created a dedicated Google Code project, named ros-n900. You'll find ROS packages specific to N900 target, and deb packages to easily install ROS on N900. You can also follow instructions on this wiki page I wrote on ros.org: http://www.ros.org/wiki/N900ROS.
Next, we'll see how to have fun with N900 webcams, ROS and OpenCV!
- Category(s)
- Geek
- SirBot Project
2009/01/18
Since last post...
by
Sébastien Lelong
—
posted at
2009-01-18 13:24
last modified
2009-01-18 13:24
- I've been working on jallib project, which aims to provide standard libraries to use with jalv2 compiler, with some other guys. Jallib is released under BSD and ZLIB licenses, and available on GoogleCode. A Google group is also available, this is where we discuss and debate about jalv2, jallib, etc...
- I've written some blog posts on jallib's blog
- I've migrated my SirBot's projects and javl2 libraries to jallib
- I've re-written an important of SirBot communication layer, now based on Twisted. This provides a extremely powerful base, without threads, easy to maintain
- I've played with Flex, Adobe's OpenSource RIA framework, and tried to prototype a Flash-based GUI for SirBot's monitoring widgets. Quite promising...
- Category(s)
- Geek
- SirBot Project
2008/08/01
PCB using toner transfer method: video and comparison
by
Sébastien Lelong
—
posted at
2008-08-01 19:41
last modified
2009-09-11 07:56
Having recently tested a lot this method, I've finally determine my "easy and cheap" way to build PCB using toner transfer method. I tried a lot of things, different papers. I've also tested the professional photoengraving method, this one can be considered for the most accurate (but certainly not the cheapest).
So, what's the recipe ? This is closed to the last one, but now way faster, since only ~ 10 minutes are needed. Main difference is you don't have to be careful while peel off the paper, toner really sticks firmly, there's no risk damaging the tracks.
This video shows the whole recipe:
Now, as a conclusion, here's a comparison of different PCB creation techniques:
[EDIT 2009-09-10] : here are some photos of the glossy paper I use, hoping it'll help choose the correct type.

So, what's the recipe ? This is closed to the last one, but now way faster, since only ~ 10 minutes are needed. Main difference is you don't have to be careful while peel off the paper, toner really sticks firmly, there's no risk damaging the tracks.
- I use glossy photo paper for laser printer (135g/m2)
- wash your PCB board with soap, then with window cleaner (or detergent with alcohol).
- sandpaper your board with ultra thin paper (600, one used for body car)
- wash again the board with soap, then with window cleaner. It must absolutely be dry.
- preheat the board,
- place the paper on the board. Be careful, it'll instantly stick to the board.
- iron the paper., first smoothly to help paper to sitck firmly, then with a lot of pressure (~1min)
- continue with the iron tip, and redraw all the circuit (black tracks will appear through the paper), for ~4/5min.
- Ironing time: ~4/5min
- then place the board on hot water, no soap. Wait for ~ 3/4 minutes, watching the paper beeing soaked.
- peel-off the paper. Most can easily be removed, only the last layer, where the toner sticks, will mostly remain on the board.
- peel-off again the paper with a toothbrush. Don't hesitate, it won't damage your PCB.
- once done, dry the board. Check if you've missed some paper.
- clean the board with window cleaner. While it won't remove toner, it'll help to remove paper residue and get an accurate board.
- you're done. You'll then need to etch the board. Once done, remove the toner using acetone (nail polish remover works well)
This video shows the whole recipe:
Now, as a conclusion, here's a comparison of different PCB creation techniques:
| Photoengraving | Toner transfer with transparency | Toner transfer with photo inkjet paper | Toner transfer with photo laser paper | |
| Ease | |
![]() |
![]() ![]() ![]() ![]() |
![]() ![]() ![]() |
| Repeatable | ![]() ![]() ![]() |
|
![]() ![]() |
![]() ![]() |
| Accuracy | ![]() ![]() ![]() |
|
![]() ![]() |
![]() ![]() |
| Fast |
|
![]() ![]() ![]() |
![]() ![]() |
![]() ![]() ![]() |
| Cheap | ![]() |
![]() ![]() ![]() |
![]() |
![]() ![]() ![]() ![]() |
| Total | ![]() |
![]() |
![]() ![]() |
![]() ![]() ![]() |
[EDIT 2009-09-10] : here are some photos of the glossy paper I use, hoping it'll help choose the correct type.

- Category(s)
- Geek
- SirBot Project
2008/06/16
New boards available from SirBot
by
Sébastien Lelong
—
posted at
2008-06-16 07:43
last modified
2008-06-16 07:43
Two new boards are available from SirBot Modules. Both are using a new bus cable connector, and were designed using Eagle.
- a new version of the mainboard: with an integrated i2c bus, better design
- a DC motor controller board: can be drive existing h-bridges, such as those found in RC toys. Extremely configurable and extensible, highly documented.
Many months (about six) have passed since the last Sirbot release, it's now time for a new one. Just need to finish the ChangeLog...
![]() |
![]() |
- Category(s)
- Geek
- SirBot Project
2008/04/29
I2C com. with two 16F88 (master/slave) using Jal v2
by
Sébastien Lelong
—
posted at
2008-04-29 21:31
last modified
2008-04-29 21:31
Weeks ago, while I was trying to interface my mainboard with a DC motor controller board, I had to dive into the i2c protocol. Serial com. couldn't make the deal, as I plan to connect several daughter boards, thus need to address them. Although RS485 was also possible, it implied a lot of changes, particularly on the PC side where I'd need an adaptor...
Anyway, just as blinking a LED, i2c is a must-have protocol. Several links helped me a lot, like this one explaining the whole theory, step-by-step, message-by-message. But the most helpful documentation still remains PIC 16F88 datasheet, and the Application Note AN734A which explains quite well how to implement an i2c slave as a state-machine. An interesting post is also explaining this very same App. note has a lot of bugs. I wouldn't say "a lot", still there's a little bug about clock stretching: CKP must be set to high when receiving a NACK. Anyway...
So, this time, this is about setting an i2c communication bus between two PIC 16F88, using Jal v2. The first thing to note is 16F88 implements SSP (Synchronous Serial Port), but not MSSP (Master Synchronous Serial Port). This means 16F88 can't be just configured to act as a i2c master, all of this must be done in software. Good news is jal v2 standard libraries come with an i2c module, which can handle all the i2c protocol subtleties, from a master point-of-view...
This jal v2 master implementation isn't based on interrupts: since it's the master which decides to take control of the bus, there's no need to react to external event... except when using Multi-Master i2c bus. To help this, 16F88 can be configured to generate interrupts on START/STOP bits (which defines when the bus is available or not). A Multi-Master i2c bus seems great but I didn't give a try, regarding all the debugging time it took me to set a "simple" 1-Master/1-Slave bus.
So, the master part is ok, now the slave part. This is where things are getting tough. Particularly without any oscilloscope or digital probe/analyzer. 16F88 can be configured as a hardware slave i2c. An IC address must be set, it must be the same as the one the master is using... This is what I've first thought, but it's not actually exactly true ! Actually, SSP must be configured so SSPADD contains a 8-bit address, that is, with the 8th bit setting read/write address type. Whereas in Jal, IC address is coded on 7-bits. This means, for instance:
Anyway, just as blinking a LED, i2c is a must-have protocol. Several links helped me a lot, like this one explaining the whole theory, step-by-step, message-by-message. But the most helpful documentation still remains PIC 16F88 datasheet, and the Application Note AN734A which explains quite well how to implement an i2c slave as a state-machine. An interesting post is also explaining this very same App. note has a lot of bugs. I wouldn't say "a lot", still there's a little bug about clock stretching: CKP must be set to high when receiving a NACK. Anyway...
So, this time, this is about setting an i2c communication bus between two PIC 16F88, using Jal v2. The first thing to note is 16F88 implements SSP (Synchronous Serial Port), but not MSSP (Master Synchronous Serial Port). This means 16F88 can't be just configured to act as a i2c master, all of this must be done in software. Good news is jal v2 standard libraries come with an i2c module, which can handle all the i2c protocol subtleties, from a master point-of-view...
This jal v2 master implementation isn't based on interrupts: since it's the master which decides to take control of the bus, there's no need to react to external event... except when using Multi-Master i2c bus. To help this, 16F88 can be configured to generate interrupts on START/STOP bits (which defines when the bus is available or not). A Multi-Master i2c bus seems great but I didn't give a try, regarding all the debugging time it took me to set a "simple" 1-Master/1-Slave bus.
So, the master part is ok, now the slave part. This is where things are getting tough. Particularly without any oscilloscope or digital probe/analyzer. 16F88 can be configured as a hardware slave i2c. An IC address must be set, it must be the same as the one the master is using... This is what I've first thought, but it's not actually exactly true ! Actually, SSP must be configured so SSPADD contains a 8-bit address, that is, with the 8th bit setting read/write address type. Whereas in Jal, IC address is coded on 7-bits. This means, for instance:
|
Jal slave i2c master
(declared slave address) |
Hardware i2c slave address |
| 0x2E = 0b00101110 | 0x5C = 0b1011100 |
That is, if the slave is declared to have 0x5C address, the master will have to talk to 0x2E as jalv2 is actually shifting 1-bit while building a write- or a read-address. As usual (and as everyone seems to report), i2c com. problems mainly come from address issues.
Setting a i2c bus is quite easy, from a hardware point of view. SDA and SCL pins must be connected on each side, on a bus using pull-up resistors to +5V. Different values can be used, they're determining the stability and the bus speed. I've successfully tried 2.2K and 3.3K, these are standard values.
Setting a i2c bus is quite easy, from a hardware point of view. SDA and SCL pins must be connected on each side, on a bus using pull-up resistors to +5V. Different values can be used, they're determining the stability and the bus speed. I've successfully tried 2.2K and 3.3K, these are standard values.

Finally, here's a two small Jal programs to test this i2c bus. The master 16F88, also connected via UART, gets a character from serial (from a PC), echoes it and send it to slave 16F88. This ones gets this char, process it (char = char + 1...). The master then gets the result and send it back to the PC. So, if you type "a", you'll get "a" as echo, then "b" as the slave's results.
| PIC 16F88 i2c Master | PIC 16F88 i2c Slave |
| simple_i2c_master.jal | simple_i2c_slave.jal |
- Category(s)
- Geek
- SirBot Project

