This is for improving get_contour_by_neighboring_shapes() in [url removed, login to view] as explained:
contour_adaptive = cnts #FIXME: This is a bad default.
# A better way would be to have no default, and if no neighboring
# contours are found, try the following method:
# - Find all text in the image as explained here:
# [url removed, login to view]
# - Create a convex hull of all text.
# - Find the first contour that encloses the hull.
# - If none is found, use the 4 point minimal enclosing rectangle.
Most of it is pretty straight forward, I think, because it uses the same techniques that you already implemented.