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.
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!
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.
About this whole Python thing.
It turns out that the more power you get the deeper you have to go.
In my particular case I had to go deep enough that the Snow Leopard 32 bit / 64 bit started to really matter.
The problem arise when I tried to install opencv for Python. Opencv has ffmpeg as a dependency. And ffmpeg is 64 bit only on Snow Leoaprd. And I was running Python in 32 bit mode (VERSIONER_PYTHON_PREFER_32_BIT=yes) because mod_wsgi was compiled agains my XAMPP Apache which in turn was 32 bit. So I had to cut the roots of the problem and ditch XAMPP altogether.
Good thing MacPorts is around. Kudos to those guys who maintain the whole thing. In around 2-3 hrs I was able to have a fully working LAMP stack and all my local dev projects including vhosts worked without major hassles. I even have the XAMPP around and I can fire it up anytime I need.
Now I do realize that these are always on the todo list for any manual LAMP installation (even Windows) but it's just a heads up for those who didn't do this kind of job yet.
I recommend doing the MacPorts thing just for fun. You'll get a better idea of what's under the hood. And if you dont set anything to start at boot you don't risk breaking your current setup. When you see the added compile times you really understand that the whole LAMP thing is a huge effort and the fact that it seems so simple to use with great tools like XAMPP just adds up to it's coolness.
Now I have Apache2 in 64 bit mode and a brand new MySQL to go with it. Also PHP is at 5.3.6 and MacPorts has about all the PHP extensions you could need.
All I can say is that the same old lesson proved true again. In technology there's no solid ground. If you're not moving forward you're going backwards!
Funny how the snake tricked me into going trough all this pain just to end up with less. But the foundation is solid and I have no doubt that all will fall nicely in place. More posts to follow on the topic as I expect to get further with this new approach.
Update: the MacPorts mod_wsgi works just fine. It is much simpler to install than the XAMPP bag of tricks. I got "Hello World" again. Next is Django but I'll really put that off for a later time.
You tried Perl, you liked the power but dreaded the lingo?