Category Archives: Raspberry Pi

Raspberry Pi, Raspbian, OpenCV @ BMMF – Getting It There

Just thought I would post the journey it took to get the Raspberry Pi Computer Vision project to the Brighton Mini Maker Farie 2012.

It started about 5/4 weeks before the Maker Faire, in a pub. Where the small group of members of the Brighton Pi sat round a table and thought what can we do for the Maker Faire. I had spoken about using some sort of computer vision on my autonomous RC car project sometime ago but didn’t do anything more with it. So the others decided that I would use my Raspberry Pi to demo some computer vision, face detection, object and edge detection. “Ok” I said, “I should be able to put something together”

My Pi was still in the anti-static bag, with no other items to enable it’s use in this project. So quickly ordered a box from pibow and quick look on Amazon and the Elinux.org SD card section. Picked the Integral 16GB SDHC Class 10 Ultima pro 20 Mb/s. Also ordered a Flexible keyboard from HK only a £5 and powered USB Hub (which I needed to modify). I had a Logitech C250 webcam, also an USB mouse.

While I was waiting for the delivery of the other items, also have some items coming from Hong Kong (fingers crossed they arrive in time). I used my Ubuntu (Linux) computer to enable me to start working on the code and see if this at all is possible to do this. Plugged the webcam into the computer, showed it was connected, loaded a program called Cheese (a webcam photo booth) to test the webcam. All working fine.
Cheese is available as a Debian package using the apt-get command in a terminal. As it was also going to run on a Raspberry and I knew a little Python, so that would be the language used to talk to Open CV. Open CV is written in C++ and available from http://opencv.org/

OpenCV is released under a BSD license and hence it’s free for both academic and commercial use.
It has C++, C, Python and Java interfaces and supports Windows, Linux, Android and Mac OS.

The image used for this project was the Raspbian available from http://www.raspberrypi.org/downloads which was a gamble as there was no support for the webcam I was using by default. The Arch Linux image did have the support required but due to my 250mA flexible keyboard I was unable to boot into that OS. It’s too late to get another keyboard. Anyway I liked the keyboard as it was easy to transport so I stuck with the Raspbian image, just need to recompile the Linux Kernel with the required UVC driver. Found some details here (Linux UVC driver & tools)  http://www.ideasonboard.org/uvc/#download  I had started tweeting about my project and the kernel gods answered by adding USB webcam support to the Raspbian kernel, which I somehow picked up by doing a lot of reboots and apt-get update, apt-get upgrade, Ri-update commands. Also following a USB cable mod (cut the red wire) to stop the powered hub powering the Raspi the webcam was detected by my raspberry. Whoo hoo major hurdle overcome. The code was being worked on my Ubuntu box, which showed Grey-scale, Face Detection, Edge Detection, Gaussian Blur. These were running in loop which ran about 4.5 FPS. Now the Ubuntu box is 2GHZ CPU with 512Mb Ram so it going to be a lot slower on the Pi which runs at 700Mhz with 256Mb ram.

Moved the code over to the raspberry and also installed Genny (lightweight text editor) able to help with python indentation. First I installed OpenCV from the site above but found  that the python bindings didn’t work so I use the package python-opencv available by using the command sudo apt-get install python-opencv  This enabled my python scripts to import cv gaining access to the Image processing commands within OpenCV.

Another major problem I overcame was that raspberry pi couldn’t cope with taking the feed directly from the cam though the USB at 640×480 so I used a program called fswebcam which enable me to take frames from the cam, perform some basic image manipulation, save to a Jpeg file and reduce in size. This file was then placed upon a USB stick to save wear and tear on a SD card, because I was polling the cam every 10 secs with a 1sec delay upon capture saving the image. The python script was then loading/reading the image from the USB and processing the same image with a loop, which ran at about 0.5 fps. The webcam program was running at 7 fps. This caused a small delay in the update of the 4 images shown but did a good job  with edge and face detection. As you can see in the pic below, Pi’s Cpu was running at 90-100% and using about 25% of the ram available.

Maybe with a directly connected camera . So by passing the USB bottleneck and access to the GPU chip it could have been quicker. Also it wouldn’t be common practice to run each image function Face and edge detection using Haar Cascade and Canny within a loop but it did show that the Raspberry Pi could be used in image processing applications.   

Some late night debugging was done the Thursday night before the Maker Faire at the Build Brighton Hack-Space Set-up was done Friday night with a bit more debugging.     

Thanks to the members of Build Brighton, Brighton Pi, Brighton Mini Maker Faire also a blog post by Fajita and various other blog posts which enabled this project to presented at Brighton Mini Maker Faire 2012
Result below:

Please comment below or contact me if you spot any errors Continue reading

Posted in bmmf, Brighton Pi, Computer Vision, News, Pyhton, Raspberry Pi, Raspbian | Comments Off

Brighton’s First Raspberry Pi Jam

On Tuesday 26th June I attended the first Brighton Pi Jam at Build Brighton.

The Brighton Pi Google Group and this meet up was planned by Peter Hobson after a meeting was held in a small pub in Brighton in which Peter put across the idea of Brighton having a user’s group of Raspberry Pi user’s and non users to help promote it’s use, share ideas, equipment, etc. Also try to answer that  frequently asked question “What is this?” and “What can I do with it?”.

A good turn out of people arrived at the Hack Space, after passing the test of finding the entrance to the space, (not set by us) just something which was caused by things beyond our control.

There was 3 people on the speaker’s list to introduce us to the wonders of the Raspberry Pi.
First up was

Neil C Ford – Show Notes http://www.neilcford.co.uk/2012/06/brightonpi-raspberry-jam-the-show-notes/

He came up to the front and gave a very passion filled talk about his work with the Rewired State, his Raspberry Pi, a Raspberry Jam, Young Rewired State. Explained about Hack Days, as he had been involved in The Field Studies Council hack day in Devon, enjoying every minute of his 2 day trip on the Devon coast in beautiful sunshine using the Pi as a portable web server. You can get further details by clicking the link above. You can also follow him on Twitter @neilcford . This talk helped get the group together and discuss what to do with the Pi during the short break for refueling with tea, coffee, etc

Next Up was
Chris EvansManager and Owner of CJE Micro’s and Fourth Dimension. 
CJE Micro’s http://www.cjemicros.co.uk/index.shtml

First off he stated that he also bought a model B back in the days of the BBC Micro . A computer which was placed in my primary school the year I left for secondary school which had Commodore Pet computers. Ahh the joys of typing in 3+ pages of code from a text book with no errors.

Chris also showed off a pre-alpha version of  RISC OS running on the Raspberry Pi. I was not aware of this being developed for the Pi, which sparked more discussion during the breaks as the OS has a low footprint so could  be run/installed on smaller SD cards rather than larger ones required by the official Pi build of Debian. 

He also came to show off and promote some of the hardware that the store had developed for the Raspberry Pi device. One major device which was showed and a world first was the development of a Real Time Clock module which plugs into the Pi and stays within the contours of the Raspberry Pi. Linux and RISC OS is partly implemented with full implementation due soon. A fully made up PCB of this is available from the store above, also you have the option of a temperature sensor which will give you piece of mind when you Pi is running, though is not going to run that hot anyway to worry about it being melted.

Showed the various cases that are available from the shop and for the Raspberry Pi, even showing that you could place a Pi within a ATX or Mini ITX case to make smooth looking device. Also supplies cable to make a Raspberry Pi look neater and control the cables coming from the device. Further work that the company is carrying out is how to power a cluster (known as a Bramble) of Pi from one power source.

Next Up was
Peter Hobson – Founder of the Brighton Pi Group on Twitter @BrightonPi

Peter was going to show some examples of using the Scratch programing language, this is also the foundation’s main choice which will be placed on the education release of the Pi. Aimed at getting young people involved and interested in coding, learning what is possible when using a computer but it was deiced to let the attendees have a chance to talk about their projects and plans for their Pi, also to test or tryout any of the hardware which Chris had brought along.

A good evening was had by all and the Raspberry Pi is going to be huge and has great potential, lets carry this into the next month’s meeting. 

If you are interested in joining the Brighton Pi Group please visit the group’s google group all updates and information about the group will be posted to this group. You need to be approved before your able to post. (don’t worry about this, it keeps out the Spam Bots (machines) from posting to group.)

Brighton Hack Space are up for letting us use the space on an monthly basis. So we need ideas for speakers, discussion about what to do at each of those monthly meetings.
Any further ideas, errors, updates just drop a comment below or post in the google group and I will update this blog. Continue reading

Posted in Brighton, Build Brighton, CJE Micro's, Hack Space, News, Raspberry Pi, Raspberry Pi Jam, Worthing | Comments Off