Facial Recognition in 14 Lines Of ColdFusion
Posted By : todd sharp Posted At : January 21, 2010 2:05 PM Posted In: Java, ColdFusion
60
I was doing a bit of research on a potential project when I stumbled across faint, a Java facial recognition library and decided to give it a quick try.
The bad news is that the documentation is literally non-existent. So I did a bit of poking around the Jar and quickly found an 'OpenCVDetection' class. I dropped the faint Jar in my class path, restarted CF and about 5 minutes and 14 lines of code later I got the following result:
If you spend any time around me you've heard me babble on about why Java integration is one of my absolute favorite things about ColdFusion. This demo is exactly why I say that. Sure, the code behind this is massive and complex, but look at how easy I can leverage that hard work:
<cfset pathToOriginal = expandPath("test.jpg") />
<cfset thumbDimensions = createObject("java", "java.awt.Dimension").init(100,100) />
<cfset faces = detector.detectFaces(pathToOriginal, 1) />
<p>original img:</p>
<img src="test.jpg" /><br />
facial recognition:
<cfoutput>
<cfloop array="#faces#" index="f">
<p>face: #arrayFind(faces, f)#</p>
<cfset thumbnail = f.toThumbnail(thumbDimensions)>
<cfset img = imageNew(thumbnail)>
<cfimage action="writeToBrowser" source="#img#" />
</cfloop>
</cfoutput>
Stay tuned for more fun as I dig deeper into faint!


"Simple-Context-Filter - Recognition filter avoiding duplicate occurrences of a person on a single photo"
That would imply it can actually compare one facial instance to another and determine if the face belongs to the same person (a step beyond just determining what part of a picture constitutes a face). Have you tested that aspect yet, or is that next on your list? :)
for Java library's like this. How did you find this one?
I found I had to train it on lots of photos before it was confident enough to learn who's who. Very nice app and library though. It will get better with time no doubt.
Dumb question, but where do you put the .jar file for coldfusion to use it? Do I need to register it in the cf admin somewhere?
You should also be able to use javaloader (http://javaloader.riaforge.org).
I say that because the GUI app produces munged up bitmaps to show the workings of its analyses, but if it did use vectors and points then why doesn't it show them instead?
One of my projects has a need to look through a database of 1000's of images to find matches so it would need to be accurate without the need for training and importantly, way faster than Faint.
Search for a photo of twins and determine if it works or not:
http://www.bing.com/images/search?q=twins
http://en.wikipedia.org/wiki/Facial_recognition_sy...
I've Googled for a while and found descriptions of some amazing software but all of it is either commercial or for academic research.
Side tracking slightly, check out this (unavailable) software that takes a low res pixelated photo and turns it into a high res image. http://people.csail.mit.edu/celiu/FaceHallucinatio...
@Gary - Too bad Face Hallucination is not publicly available. The test results are surprisingly accurate.
An old colleague of mine was building "Target" recognition software for Uncle same in his spare time back then that was cutting edge stuff. I think its pretty darn cool that you can find a library like this just out there in the wild.
Interesting would be to build a photo album that automatically mapped the coordinates of the faces of pictures and allowed you to indicate who's who only once, scan all your pictures and apply facebook like hotspots...
the call but anything after that never appears. Any ideas?
http://www.bennadel.com/index.cfm?site-photo=246
BTW, you need a spam filter for your comments :)
@Rob - thanks man - we miss you in the CF world - what are you up to these days?
I added the path c:\inetpub\wwwroot\faint.jar in
coldfusion class path butb I recieve an error.
Please help