Tuesday, April 12, 2011

OpenCV in Python, in PHP, in Flash and everywhere else...

A good while ago we were doing a website for one of our social aware clients and the visitors could upload pictures of them and their good friends. But oh my, those pictures needed to be cropped to thumbnails and we couldn't upset the clients by asking them not to upload images in portrait format.
Obviously.
So I looked at my Cake and wondered how could I crop and keep their faces. Ok, that sounds like I have something against our clients and I was about to go Lecter-ish on them which is simply not true. What I mean to say is that I wanted to crop the uploaded images while maintaining the areas containing the graphical representations of their faces in the output.
Now there is a name for that and the name is "Computer Vision". And there is an Open Source project for that and it's name is OpenCV.
And there is a very cool dude who goes buy the name of Robert Eisele who created the PHP Facedetect Extension so all PHP devs can find faces in images. Indeed the extension worked very nice for that project and all the faces were there. I must say that I was amazed by the accuracy. It's mind bogging what computers can do if you tell them how to do it!
But it doesn't come for OpenCV2  and that's what I got on MacPorts.

Good thing I have Python running. Because although OpenCV is C it has a full Python interface!
So now you understand my recent interest in snake taming ;-)

But the coolest thing of the whole stack is, you guessed, Flash!
More precisely the the way that Eugene Zatepyakin, Flash wiz extraordinaire used the Alchemy Project to achieve Viola-Jones object detection in the Flash Player. And that really works. But do check all the other uber cool tricks Eugene has up his sleeve. All are quite impressive and def worth your time.
Alchemy seems to work ok on my OSX 10.6. I managed to do the install steps and compile the basic sample so now the sky would be the limit :-)




0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home