Intelligent text recognition for document photography and scanning