Here is a discussion about that very subject.http://stackoverflow.com/questions/5819 ... droid-java
I haven't come across a need for this yet but if I did, I might look at how these libraries work and then work to port the techniques to Java or using C and the NDK.
Generally, I think these routines work to find edges, the intersections of these edges, the angles formed by the intersections and finally, shapes from the sum of the angles and the number of sides. You may also be able to find this in use in languages other than Java and C like C++ and C#. These may lend themselves to porting. I believe I found something using Hough algorithm for C# once. Didn't know exactly what to do with it or what it was supposed to do. Used something simpler.