Here is code that does what you asked for: http://libccv.org/doc/doc-swt/
Other projects that are relevant:
- https://www.google.com/search?q=text+detection+in+images
- python and c++ implementation by TiRG (screenshot sample) : http://funkybee.narod.ru/
- python and c++ implementation by TiRG (source code) : http://sourceforge.net/projects/tirg/