Program that calculates the extraction polygon of present text lines given an existing baseline in the page file as per the article that can be found here Distance Map Article
Although the sofware might run in higher versions of this libraries it has not been tested on them. Furthermore, it is known that higher versions of OpenCV break backwards compatability with certain calls used in this software.
To compile this software simply download this repository, change directory to it and execute:
make all
extract_lines --help
./extract_lines -i 156730303.jpg -p 156730303.xml -o output.xml -w 4 -x -1