About

Ian Ozsvald picture

This is Ian Ozsvald's blog, I'm an entrepreneurial geek, an AI consultant, co-founder of the StrongSteam AI and data mining API, co-founder of the SocialTies App, author of the A.I.Cookbook, author of The Screencasting Handbook, a Pythonista, co-founder of ShowMeDo and FivePoundApps and also a Brightonian. Here's a little more about me.

View Ian Ozsvald's profile on LinkedIn Visit Ian Ozsvald's data science consulting business Protecting your bits. Open Rights Group

1 January 2011 - 16:02And on with 2011

Earlier this year I switched back to my long-running artificial intelligence and CUDA high performance computing consultancy work through Mor Consulting. Having sold ProCasts earlier in the year and moved entirely away from screencasting (leaving ShowMeDo in Kyran’s capable hands) I wanted to get back to the nitty gritty of low level algorithms and implementations.

My A.I.Cookbook project is coming along, albeit very slowly over the last few months. I’m looking forward to starting a few new projects in the Cookbook, the OCR project against the OpenPlaque images needs finishing first (I see more prizes ahead there…).

Emily and I have some joint A.I./mobile projects to publish this year and I’m always on the look-out for interesting parallel, high performance computing and artificial intelligence problems – if you have a problem in this area please do get in touch.

Lee Tucknott did the design for Mor Consulting and has provided a design for the A.I.Cookbook (which I’ve yet to get implemented), if you need a beautiful design do go see his work.

And now, to push on with Social Ties, our first A.I./mobile product for January which’ll help you find interesting people at events…


Ian applies Artificial Intelligence as an Artificial Intelligence Researcher for companies (Mor Consulting), co-founded the StrongSteam A.I. datamining toolkit, co-authored SocialTies, programs Python, writes The Screencasting Handbook and is also a sea-side dweller and consumer of fine coffees.

No Comments | Tags: Life

6 November 2010 - 16:04Building a Social Microprinter

Over the last couple of months I’ve been building up a social microprinter (inspired by Tom Taylor‘s implementation and Matt Webb‘s original idea). Here’s the current version – Arduino+WiShield+CBM231+off-site server (powered partly by BenOSteen’s Python driver):

There’s a second quick video and talk for the £5 App event I ran earlier in the week.

The goal is to build a social microprinter – a printer that’d live in a social environment (currently The Skiff co-working office in Brighton) which would help bring people a little bit closer. Currently it prints tweets (for ‘theskiff’) and shows events, later it’ll show recent Gowalla check-ins and maybe some local news headlines or the weather (but there’s got to be better stuff to show, right?…ideas on a postcard please).

My original intent was to build a device that could be stuck on the wall in a cafe, it would show tweets on a screen (probably under the cafe’s or Brighton’s hashtag) and let non-Internet folk post their own messages back. Doing this nicely would have needed a screen, machine, wall space etc – using a receipt printer seemed like an easy way to prototype the idea.

Jumping forward, here’s an early version – this is a CBM231 connected to my Ubuntu laptop via a USB->RS232 lead (note – this lead is good, the cheap ones on eBay can be bad – see below). Here I’m using BenOSteen’s Python driver to send tweets via serial to the printer.

This device has done the rounds, here it is on display at BuildBrighton’s talk to the British Computer Society:

Here it is in use at Likemind Brighton showing international #likemind tweets as other groups meet around the world on Friday morning (note – unicode converted to ‘?’ as I haven’t figured out if/how to get international characters out of the printer yet!):

It ran during the weekend of Barcamp Brighton and printed out barcampy stuff, I added some notes about local cafes and a job ad for one of the companies:

The goal all along was to build an independent controller (so removing the laptop from the equation). For this I coupled an Arduino with a WiShield 1.0. The WiShield libraries are easy enough to work with, after an hour’s experimentation I got WPA2 working (it takes 25 seconds to negotiate the connection on each attempt), we use WPA2 at home and in The Skiff.

Coupling the Arduino to the printer was easy enough, I have been trying (and so far failing) to get a Max233 chip acting as a voltage level converter so for now I’m using a pre-built RS232 Level Shifter. This converts the Arduino’s 0V/5V TTL to +12V/-12V RS232 levels (powered from the Aruino’s 5V out). To output text I’m using Roo Reynold’s Aduino sketch, this handily includes some control codes to cut the receipt after printing.

Next I wanted live data. At first I simply put a short plain text file on a web site, used the WiShield to fetch it and Roo’s code to print it. Now I’m using a hacked version of Ben’s code to write tweets (including bold and underline control codes) to a text file which is stored online (microprinter.ianozsvald.com), this ready-to-print file is grabbed over the WiShield, printed and then cut. The online file is updated every 2 minutes.

The final tweak was to add a button to the printer. Using the Arduino’s demo button sketch I hooked up a big thumb-sized button. The Arduino’s main loop is looking for a combination of ‘at least 5 seconds have passed since the last print’ and ‘button pressed’, then it’ll kick off the web request for new data. Once this request returns it prints out the text.

I look for the pattern “————–” (14 dashes) to start and end the message, before this we get HTTP headers (from the WiShield) that I didn’t want to print.

Here’s the finished hardware:

This is a WiShield 1.0. The button (shown just out of shot top-left) is connected 3.3V->button, button->Pin 6 AND Ground (via a 15k resistor). For the printer I’m using Pin 8 for tx (blue lead on the RS232 level converter) and Ground, the level converter is powered by the 5V out.

Here’s the connector:

The connector is overly-connected in this image. I think all you actually need is Pin 2 from the RS232 Level Converter to Pin 3 on the 25 pin connector along with Pin 5 (GND) to Pin 7 (GND on 25 pin connector). With yellow wires I’ve shorted Pins 4&5 and 8&20 but I think this is overkill (they’re used for bus control but they’re probably ignored in this configuration).  Here’s a full pinout.

During all the hacking our faithful cat Mia has attempted to assist whenever she could. Here she’s taken ownership of the bag used to transport the early versions:

Along the way I also acquired an Epson TM T88 II receipt printer, it is ‘just another serial printer’ but takes different control codes (and it looks like it might have a smaller character set than the CBM 231). As yet I’ve only tried printing plain ASCII, I’d like to investigate further and build a library that supports this printer too.

Note on buying leads from eBay! be aware that if you buy cheap leads from eBay (e.g. £2 silver/blue leads) then you might end up with a pack of 5 (because if you buy 5 and one breaks, you’ve got 4 more that work, right?), you might have 5 dead-on-arrival leads. You could then report the problem and the nice people could then ship you a replacement set, but then you might discover that you’ve got another 5 DOA leads. You have been warned.

If you’re buying your first microprinter do try to buy a working serial lead with it (it’ll probably be a 9 pin to 25 pin converter lead) – if you get the wrong lead (null modem vs straight serial – I forget which you need!) then you won’t get anything (the bane of my first few week’s of testing). Buy a printer+lead that’s known to work and you won’t go wrong.

Spend the £8 per lead and buy from Amazon if you don’t want to waste hours wondering why your printer is just printing out reams of ‘?’ rubbish:

If you want to build your own then the first best source of info is the microprinter wiki. Roo Reynolds has Arduino drivers (which I hacked a bit for my implementation) that don’t depend on external data sources.

You’ll find my Python server source and Arduino sketch (which assumes you’ve got a WiShield 1.0) here: social_microprinter. Note that the code is horribly hacky, it was written over many short sessions when I could steal an hour or two from other projects.

It could do with being straightened out and commented and a few nice new features would include Gowalla check-in notifications, event RSS reading and weather printing.

Many thanks to my fellow hackers at BuildBrighton for help debugging my early serial problems and to Barney for the lend of his RS232 Shifter (I’ll soon get this Max233 working, promise!).

Here’s the finished, installed unit on the work bench at BuildBrighton in The Skiff (just by the social kitchen space). Once it is a bit more robust it’ll move to the front of the building:


Ian applies Artificial Intelligence as an Artificial Intelligence Researcher for companies (Mor Consulting), co-founded the StrongSteam A.I. datamining toolkit, co-authored SocialTies, programs Python, writes The Screencasting Handbook and is also a sea-side dweller and consumer of fine coffees.

2 Comments | Tags: Life, Programming, projectbrightonblogs, Python

17 September 2010 - 10:52Demoing pyCUDA at the London Financial Python User Group

On Wednesday night I jumped on a train up to London to visit the London Financial Python User Group to give a short demo of pyCUDA. I’m using CUDA heavily for my physics consultancy and I figured the finance guys would be interested in 10-1000* speed-ups for their calculations.

The raw figures and the Mandelbrot demo that I gave are already covered in my earlier blog post: 22,937* faster Python math using pyCUDA.

To introduce pyCUDA I used P. Narayanan’s GPUs: For Graphics and Beyond PDF presentation (the first 13 pages), his explanation and diagrams are very clear.

To put CUDA in context against regular CPUs I used the recent Peak MHz graph and the main power/speed/transistor count graph in The Free Lunch is Over: A Fundamental Turn to Concurrency in Software. The main point here is that we’ve topped out at 2-3GHz CPUs and now we have to parallelise our code. Doing so on CPUs means we get 4, 8, 16 (and soon 24 then 32) cores to play with…but with CUDA if the problem is mathematics based we have 480 cores to use!

If you’re interested in the general use of CUDA and GPUs then check out the excellent gpgpu.org.

You may wonder about real-world performance with CUDA. Without naming names I can say that I’m now delivering a 115* speed-up on a particularly gnarly problem (I mentioned during the talk that I’d reached 80* – I’ve managed to improve that in the last 2 days). On an earlier problem when I knew far less about CUDA I delivered a 100* speed-up for the same company.

It was grand to meet a lot of new faces at the group, a few people I’ve met before at PyCons (hi Ben! Giles!). Making a contact with Didrik of Enthought was rather grand too. I hope to visit again.


Ian applies Artificial Intelligence as an Artificial Intelligence Researcher for companies (Mor Consulting), co-founded the StrongSteam A.I. datamining toolkit, co-authored SocialTies, programs Python, writes The Screencasting Handbook and is also a sea-side dweller and consumer of fine coffees.

3 Comments | Tags: Life, Python

7 September 2010 - 22:11Selling ProCasts through Flippa.com

A couple of weeks ago I sold ProCasts.co.uk, the screencasting business I built over the last two years. Some of you know that I moved away from the business back at Christmas and left it idle (a rather silly thing to do), here are some notes on how I sold it and how you could sell your business. This is my first business sale, some valuable lessons were learned.

I listed the business on flippa.com a month back, flippa specialises in matching buyers and sellers of domain names and small businesses. Since ProCasts was, after 8 months of inactivity, essentially a website that generated leads with a client list – I figured a listing on flippa would find some interested parties. I didn’t sell The Screencasting Handbook, I’m still happily developing the Handbook’s sales.

The new owners are Tintisha Technologies, a Leicester based video production company who wanted to expand their screencasting brand. Rich of Tintisha discovered the ProCasts sale through flippa by (happy!) accident, made a couple of bids at the end of the auction and came out on top. We completed the handover last week.

The reason for selling ProCasts was simple – I’d moved away from screencasting back at Christmas as I’d decided to return to my historic trade of artificial intelligence research and data science. I knew that a few of ProCasts’ competitors might be interested in the site and that a listing on flippa with money sent through escrow.com would make for a clean, safe sale.

I listed the site as an “Established lead generating screencasting site” with a two week auction. Flippa works differently to eBay – it uses an open auction (though private sales are possible) with a rolling end-time (if a bid is placed within 4 hours of the end of the auction the end time is advanced by another 4 hours).

Take a look at the listing to see the details that I included, I added:

  • Full business and site description
  • Details of past clients and warm leads
  • Bank statements to prove income
  • Verified Google Analytics traffic data
  • A Transfer Agreement listing all assets/processes for the sale

I made a point of responding to all questions (lots came via the private email channel) and updating the listing with new information. Fortuitously a couple of older leads came back with requests for work during the auction so these ‘very warm leads’ got a mention in the comments too.

At the end of the day the site sold for $4,002 (£2,500), minus the sale fee (£100) and escrow.com’s fees I took away £2,400. Not bad for a site that was otherwise of no value to me but obviously not an ‘interesting exit’.

Here are some of the takehome lessons:

  • If you’re selling a business, a pure consultancy (with no consultants) isn’t super interesting to buyers, only to existing market players
  • Building a consultancy in a super-small niche (when I started I had 4 US competitors and 0 in the UK) means few buyers when you decide to exit (in fairness – I didn’t build the business to sell it, I know better for next time)
  • Design your business with an exit in mind – recurring or passive income has real value to a buyer, make sure you can be removed from the business without damaging it
  • A two week auction was fine but four weeks would have made more sense
  • Soliciting private bids from competitors should have been done sooner rather than later
  • Adding a product or recurring income stream to the business would have added a lot of value (I decided to keep The Screencasting Handbook as an experimental platform)
  • BusinessesForSale is an alternative site, I didn’t know about it when I started, their companies tend to have higher value (flippa isn’t really for consultancy businesses, just simple web businesses)

What next?

Some of you know that I’ve been working in the field of artificial intelligence research for industry over the last 10 years (as both senior programmer, product designer and pure r&d bod) in my Mor Consulting. This role is evolving and I’m turning into a “Data Scientist” (the new shiny term for A.I. researchers!).

I’m also building some new IP by way of web services using A.I. technologies, these are designed with an exit in mind (I’m learning!). If you’re curious about using A.I. in industry see my new A.I.Cookbook.

I’m also continuing to develop The Screencasting Handbook, it is a useful experimental platform and I still very much enjoy teaching the art of screencasting.

If you have any questions, ask away.


Ian applies Artificial Intelligence as an Artificial Intelligence Researcher for companies (Mor Consulting), co-founded the StrongSteam A.I. datamining toolkit, co-authored SocialTies, programs Python, writes The Screencasting Handbook and is also a sea-side dweller and consumer of fine coffees.

No Comments | Tags: ArtificialIntelligence, Entrepreneur, Life, ProCasts, Screencasting, The Screencasting Handbook

5 September 2010 - 13:03Saving power around the house with an EnviR

We took delivery of an EnviR from CurrentCost a week back, we’ve been measuring power usage around the house since then. The unit itself is super easy to install – the LCD panel sits on a window sill and the measurement unit clips to the electric meter (it has a 30m range).

Here’s what we measured (kW is kilo Watts, W is Watts, I’m not writing ‘per hour’ for each entry):

  • Kettle boiling – 2.9kW/hr (for about 5 minutes)
  • Electric oven – 2kW/hr at 220 degrees C (used 30-60 minutes per day)
  • 800W Microwave running – 1kW
  • Washing machine – 300W
  • Electric clothes drier – 282W (used for 2 hours every few days)
  • Dehumidifier – 200W (used 1 hour each day)
  • Widescreen LCD TV – 90W-140W
  • Kitchen downlighters (5) – 112W
  • Fridge and freezer running – 94W (turns on and off throughout the day)
  • Media PC on and playing a video – 100W
  • Media PC on but idle – 40W
  • Macbook charger – 40W
  • Amplifier on media PC – 20W (idle most of the day)
  • Power saving lights – 9W-24W each
  • Microwave on standby – 4W
  • Dishwasher running – ??
  • Toaster running – ??
  • DECT phone, broadband router, standby power for media PC – 3W
  • The following readings are guestimates – 1W seems to be the lowest reading the EnviR can make
  • Coffee grinder on standby – 1W
  • Toaster on standby – 1W
  • Widescreen LCD TV – 1W
  • Electric oven and extractor fan on standby – 1W

Has it changed our behaviour? We’ve started turning off the media PC when not in use (saving 40W/hr overnight). We also turn off the microwave and coffee grinder (saving 5W/hr 23 hours a day) – it is trivial but the grinder gets warm, turning them on just to use them is easy.

We’ve also stopped turning off the TV at night (it uses at most 1W/hr on standby) and turning off the toaster (again 1W/hr at most). I had wondered if the TV consumed a lot of standby power, the toaster has a set of LEDs – both use a trivial amount of power so I’ll ignore them for now.

I had no idea that the kitchen lights were so expensive – we won’t leave them on when not in use any more. I was really surprised by the oven – 2kW/hr  swamps the usage of everything else! We really ought to use the outside line for some wet clothes too (but we don’t have back access to the tiny garden so getting there is a bit of a faff…).

The Economist has a nice Watts Up article looking at how people underestimate the expense of some items (I certainly did!) and overestimate the savings they get from turning off things like lightbulbs.

Now the meter sits on a window ledge facing the sofa – we can monitor the house’s power usage and over time we’ll learn to play the game of keeping the numbers as low as seems reasonable. Feedback is a powerful thing!


Ian applies Artificial Intelligence as an Artificial Intelligence Researcher for companies (Mor Consulting), co-founded the StrongSteam A.I. datamining toolkit, co-authored SocialTies, programs Python, writes The Screencasting Handbook and is also a sea-side dweller and consumer of fine coffees.

2 Comments | Tags: Life

14 July 2010 - 12:5222,937* faster Python math using pyCUDA

I’ve just uploaded a new Mandelbrot.py demo for pyCUDA, it adds a new calculation routine that straddles the numpy (C based math) and the pure-CUDA implementations. In total there are 4 variants to choose from. The speed differences are huge!

Update – this Reddit thread has more details including real-world timings for two client problems (showing 10-3,677* speed-ups over a C task).

Update – I’ve written a High Performance Python tutorial (July 2011, 55 pages) which covers pyCUDA and other technologies, you might find it useful.

This post builds upon my earlier pyCUDA on Windows and Mac for super-fast Python math using CUDA.

You’ll need CUDA 3.1 and pyCUDA installed with a compatible NVIDIA graphics card. This version of the Mandelbrot code forces single precision math – this means it’ll work on all CUDA cards (even the older ones – full list). It runs on my MacBook (Leopard) and Windows, the Windows machines use a 9800 GT and GTX 480. Here’s what it generates:

The big-beast graphics card for my physics client is a GTX 480 – this is NVIDIA’s top of the line consumer card (costing £420GBP in the UK a few weeks back). It is huge – it covers two slots, uses one PCIe 2.0×16 slot and has a requirement for 300-400W of power (I’m using a 750W PSU to be safe on a Gigabyte GA H55M S2H motherboard):

The mandelbrot.py demo has four options (e.g. ‘python mandelbrot.py gpu’):

  • ‘gpu’ is a pure CUDA solution on the GPU
  • ‘gpuarray’ uses a numpy-like CUDA wrapper in Python on the GPU
  • ‘numpy’ is a pure Numpy (C-based) solution on the CPU
  • ‘python’ is a pure Python solution on the CPU with numpy arrays

The default problem is a 1000*1000 Mandelbrot plot with 1000 max iterations. I’m running this on a 2.9GHz dual core Windows XP SP3 with Python 2.6 (only 1 thread is used for all CPU tests). The timings:

  • ‘gpu’ – 0.07 seconds
  • ‘gpuarray’ – 3.45 seconds – 49* slower than GPU version
  • ‘numpy’ – 43.4 seconds – 620* slower than GPU version
  • ‘python’ – 1605.6 seconds – 22,937* slower than GPU version
  • ‘python’ with psyco.full() – 1428.3 seconds – 20,404* slower than GPU version

By default mandelbrot.py forces single precision for all the math. Interestingly on my box if I let numpy default to numpy.complex128 (two double precision floating point numbers rather than numpy.complex64 with two single precision floats) then the Python result is faster:

  • ‘numpy’ – 34.0 seconds (double precision)
  • ‘python’ – 627 seconds (double precision) – 2.5* faster than the single precision version

The ’22,937*’ figure is a little unfair in light of the 627 second result (which is 8,957* slower) but I wanted to use only single precision math for consistency and compatibility across all CUDA cards (the older cards can only do single precision math).

On my older dual core 2.66GHz machine with a 9800 GT I get:

  • ‘gpu’ – 1.5 seconds
  • ‘gpuarray’ – 7.1 seconds – 4.7* slower than GPU version
  • ‘numpy’ – 51 seconds – 34* slower than GPU version
  • ‘python’ – 1994.3 seconds – 1,329* slower than GPU version

If we compare the 0.07 seconds for the GTX 480 against the 1.5 seconds for the 9800 GT (albeit on different machines but the runtime is just measuring the GPU work) then the GTX 480 is 21* faster than the 9800 GT. That’s not a bad speed-up for a couple of years difference in architectures.

If you take a look at the source code you’ll see that the ‘gpu’ option uses a lump of C-like CUDA code, behind the scenes all pyCUDA code is converted into this C-like code and then down to PTX via their compiler. This is the way to go if you understand the memory model and you want to write very fast code.

The gpuarray option uses a numpy-like interface to pyCUDA which, behind the scenes, is converted into CUDA code. Because it is compiled from Python code the resulting CUDA code isn’t as efficient – the compiler can’t make the same assumptions about memory usage as I can make when hand-crafting CUDA code (at least – that’s my best understanding at present!).

The numpy version uses C-based math running on the CPU – generally it is regarded as being ‘pretty darned fast’. The python version uses numpy arrays with straight Python arithmetic, this makes it awfully slow. Psyco 2.0.0 makes it a bit faster.

Feedback and extensions are welcomed via the wiki!

If you want to get started then make sure you have a compatible CUDA card, get pyCUDA (installation instructions), compile pyCUDA (takes 30 minutes from scratch if you’re on a well-known system), try the examples and run mandelbrot.py. The mailing list is helpful.

It’d be nice to see some comparisons with PyPy, ShedSkin and other Python implementations. You’ll find links in my older ShedSkin post. It’ll also be interesting to tie this in to some of the A.I. projects in the A.I. Cookbook, I’ll have to ponder some of the problems that might be tackled.

Books:

The following two books will be useful if you’re new to CUDA. The first is very friendly, I’m still finding it very useful.


Ian applies Artificial Intelligence as an Artificial Intelligence Researcher for companies (Mor Consulting), co-founded the StrongSteam A.I. datamining toolkit, co-authored SocialTies, programs Python, writes The Screencasting Handbook and is also a sea-side dweller and consumer of fine coffees.

4 Comments | Tags: ArtificialIntelligence, Life, Python

11 July 2010 - 14:17Presenting A.I. at FlashBrighton (using Python!)

A couple of weeks back I presented an Artificial Intelligence evening at FlashBrighton with John Montgomery and Emily Toop. The night covered optical character recognition, face detection, robots and some futurology. A video link should follow.

Optical Character Recognition to Read Plaques

Recently I’ve been playing with OCR to read photos with text, a particular example I care about is extracting the text from English Heritage Plaques for the OpenPlaques project:

I gave an overview of the tesseract open source OCR tool (originally created by HP). Some of the notes I explained came from this tesseract OSCON paper. Some notes:

  • tesseract ranked highly in international competitions for scanned-image text extraction
  • it works better if you remove non-text regions (e.g. you isolate just the blue plaque in the above image) and threshold the image to a grey scale
  • it runs very quickly – it’ll extract text in a fraction of a second so it will run on a mobile phone (iPhone ports exist)

To get people thinking about the task from the computer’s point of view I had everyone read out the text from this blurry photo. Treating the image as a computer would see it shows that you need several passes to learn which country is involved and to guess at some of the terms:

You can guess that the domain is music/theatre (which helps you to specialise the dictionary you’re using), based in the US (so you know that 1.25 is $1.25USD) and even though the time is hard to read it is bound to be 7.30PM (rather than 7.32 or 7.37) because events normally start on the hour or half hour. General knowledge about the domain greatly increases the chance that OCR can extract the correct text.

I talked about the forthcoming competition to write a Plaque-transcriber system, that project is close to starting and you can see demo Python source code in the AI Cookbook.

Optical Character Recognition Web Service and Translator iPhone Demo

To help make OCR a bit easier to use I’ve setup a simple website: http://ocr.aicookbook.com/. You call a URL with an image that’s on the web (I use flickr for my examples) and it returns a JSON string with the translated text. The website is a few lines of Python code created using the fabulous bottle.py.

The JSON also contains a French translation and mp3 links for text to speech, this shows how easy it is to make a visual-assist device for the hard of sight.

Emily built an iPhone demo based on this web service – you can a photograph of some text, it uploads the text to flickr, retrieves the JSON and then plays the mp3s and shows you the translated text.

OCR on videos

The final OCR demo shows a proof of concept that extracts keywords from ShowMeDo‘s screencast videos. The screencasts show programming in action – it is easy to extract frames, perform OCR and build up strong lists of keywords. These keywords can then be added back to the ShowMeDo video page to give Google more indexable content.

There’s a write-up of the early system here.

OCR futurology

Text is all around us and mobile phones are everywhere. It strikes me that sooner or later we’ll be pointing our mobile phone at a poster like this and we’ll get extra information in return:

From the photo we can extract names of places, we also know the phone’s location so a WikiPedia geo-lookup will return relevant pages. Probably we can also extract dates and costs from posters and these can go into our calendar. I used tesseract on this image and extracted enough information to link to several WikiPedia pages with history and a map.

Face Detection for Privacy Invasion

John and I built a system for correlating gowalla check-ins with faces seen in images from the SkiffCam – the webcam that’s hosted in the Skiff co-working space. The goal was to show that we lose quite a lot of privacy without realising it – the SkiffCam has 29,000 images (1Gb of data) dating back over several years.

Using openCV’s face detection system I extracted thousands of faces. John retrieved all the gowalla check-ins based at the Skiff and built a web service that lets us correlate the faces with check-ins. We showed faces for many well-known Brightoners including Seb, Niqui, Paulo, Jon & Anna and Nat.

Given a persons face we could then train a face recogniser to see other occurrences of that person at the Skiff even if they’re not checking in with gowalla. We can also mine their twitter accounts for other identifying data like blogs and build a profile of where they go, who they know and what they talk about. This feels pretty invasive – all with open source tools and public data.

Emotion detection

Building on the face detector I next demonstrated the FaceL face labeling project from Colorado State Uni, built on pyVision. The tool works out of the box on a Mac – it can learn several faces or poses during a live demo. Most face recognisers only label the name of the person – the difference with FaceL is that it can recognise basic emotional states such as ‘happy’, ‘neutral’ and ‘sad’. This makes it really easy to work towards an emotion-detecting user interface.

During my demo I showed FaceL correctly recognising ‘happy’ and ‘sad’ on my face, then ‘left’ and ‘right’ head poses’, then ‘up’ and ‘down’ poses. I suspect with the up/down poses that it is really easy to build a nod-detecting interface!

Headroid2 – a Face Tracking Robot

Finally I demo’d Headroid2 – my face tracking robot (using the same openCV module as above) that uses an Arduino, a servo board, pySerial and a few lines of code to give the robot the ability to track faces, smile and frown:

Here’s a video of the earlier version (without the smiling face feedback):

For full details including build instructions see building a face tracking robot.

EuroPython

I’ll bring Headroid3 (this adds face-seeking behaviour) to EuroPython in a few weeks, hopefully I can find a few other A.I. folk and we can run some demos.

Reading material:

If you’re curious about A.I. then the following books will interest you:


Ian applies Artificial Intelligence as an Artificial Intelligence Researcher for companies (Mor Consulting), co-founded the StrongSteam A.I. datamining toolkit, co-authored SocialTies, programs Python, writes The Screencasting Handbook and is also a sea-side dweller and consumer of fine coffees.

No Comments | Tags: ArtificialIntelligence, Life, Python

9 July 2010 - 22:35Abandoned petrol pump

Here’s a random moment – on Blackman Street just down from Brighton Station is this abandoned petrol pump. I’m curious to know what kind of business it supported – anyone know?

This is the cheapside area of Brighton (meaning ‘market area‘ in olde English) known now as the New England Quarter – a few streets from the new sustainable housing developments, green corridor and New England House.


Ian applies Artificial Intelligence as an Artificial Intelligence Researcher for companies (Mor Consulting), co-founded the StrongSteam A.I. datamining toolkit, co-authored SocialTies, programs Python, writes The Screencasting Handbook and is also a sea-side dweller and consumer of fine coffees.

No Comments | Tags: Life

17 May 2010 - 21:06Extracting keyword text from screencasts with OCR

Last week I played with the Optical Character Recognition system tesseract applied to video data. The goal – extract keywords from the video frames so Google has useful text to index.

I chose to work with ShowMeDo‘s screencasts as many show programming in action – there’s great keyword information in these videos that can be exposed for Google to crawl. This builds on my recent OCR for plaques project.

I’ll blog in the future about the full system, this is a quick how-to if you want to try the system yourself.

First – get a video. I downloaded video 10370000.flv from Introducing numpy arrays (part 1 of 11).

Next – extract a frame. Using ffmpeg I extracted a frame at 240 seconds as a JPG:

ffmpeg -i 10370000.flv -y -f image2 -ss 240 -sameq -t 0.001  10370000_240.jpg

Tesseract needs TIF input files (not JPGs) so I used GIMP to convert to TIF.

Finally I applied tesseract to extract text:

tesseract 10370000_30.tif 10370000_30 -l eng

This yields:

than rstupr .
See Also
linspate : Evenly spaced numbers with  careful handling of endpoints.
grid: Arrays of evenly spared numbers  in Nrdxmensmns
grid: Grid—shaped arrays of evenly spaced numbers in  Nwiunensxnns
Examples
>>> np.arange(3)
¤rr¤y([¤. 1.  2])
>>> np4arange(3.B)
array([ B., 1., 2.])
>>>  np.arange(3,7)
array([3, A, S, 6])
>>> np.arange(3,7,?)
·=rr··¤y<[3.  5])
III
Ill

Obviously there’s some garbage in the above but there are also a lot of useful keywords!

To clean up the extraction I’ll be experimenting with:

  • Using the original AVI video rather than the FLV (which contains compression artefacts which reduce the visual quality), the FLV is also watermarked with ShowMeDo’s logo which hurts some images
  • Cleaning the image – perhaps applying some thresholding or highlighting to make the text stand out, possibly the green text is causing a problem in this image
  • Training tesseract to read the terminal fonts commonly found in ShowMeDo videos

I tried four images for this test, in all cases useful text was extracted. I suspect that by rejecting short words (less than four characters) and using words that appear at least twice in the video then I’ll have a clean set of useful keywords.

Update – the blog for the A.I. Cookbook is now active, more A.I. and robot updates will occur there.


Ian applies Artificial Intelligence as an Artificial Intelligence Researcher for companies (Mor Consulting), co-founded the StrongSteam A.I. datamining toolkit, co-authored SocialTies, programs Python, writes The Screencasting Handbook and is also a sea-side dweller and consumer of fine coffees.

1 Comment | Tags: ArtificialIntelligence, Life, Programming, Screencasting, ShowMeDo

31 March 2010 - 21:3722nd £5 App Write-up for WildLife, Plaques, Robots, Go and Golf Gadgets

Last night we ran our 22nd £5 App event, videos for each speaker are listed below. The lovely Thayer Prime of Data.Gov.Uk provided us with 3 copies of Programming the Semantic Web to give away, this was particularly well timed given the semantic nature of our two main talks. Thanks Thayer!

WildLife Near You by Simon Willison and Natalie Downe (wildlifenearyou.com)

£5 App #22 WildLifeNearYou by Simon Willison and Natalie Downe from IanProCastsCoUk on Vimeo.

OpenPlaques by Simon Harriyott and Jez Nicholson (openplaques.org)

£5 App #22 OpenPlaques.org from IanProCastsCoUk on Vimeo.

BotBuilder’s Robots by Steve Carpenter (botbuilder.co.uk)

£5 App #22 Robots from BotBuilder (Steve Carpenter) from Ian Ozsvald on Vimeo.

Google Go by Jamie Campbell (golang.org)

£5 App #22 Google’s Go by Jamie from Ian Ozsvald on Vimeo.

SureScore Golf Pro by Chris Holden (scoresure.co.uk)

£5 App #22 Chris on ScoreSure Golf Pro from Ian Ozsvald on Vimeo.


Ian applies Artificial Intelligence as an Artificial Intelligence Researcher for companies (Mor Consulting), co-founded the StrongSteam A.I. datamining toolkit, co-authored SocialTies, programs Python, writes The Screencasting Handbook and is also a sea-side dweller and consumer of fine coffees.

No Comments | Tags: Life, £5 App Meet