def __merge_boxes(self, rects):
    'main function to detect text boxes from image\n\n        :param rects: list of \n        :type rects: numpy array\n        :param rectsUsed: image file in numpy array/opencv format\n        :type rectsUsed: numpy array\n\n        :return: output image with the list of text boxes\n        :rtype: file, list\n        '

    def grouper(iterable, interval=2):
        prev = None
        group = []
        for item in iterable:
            if ((not prev) or (abs((item[1] - prev[1])) <= interval)):
                group.append(item)
            else:
                (yield group)
                group = [item]
            prev = item
        if group:
            (yield group)
    rects_used = []
    heights = list()
    for bbox in rects:
        heights.append((bbox[3] - bbox[1]))
    heights = sorted(heights)
    median_height = (heights[(len(heights) // 2)] / 2)
    bboxes_list = sorted(rects, key=(lambda k: k[1]))
    combined_bboxes = grouper(bboxes_list, median_height)
    for group in combined_bboxes:
        x_min = min(group, key=(lambda k: k[0]))[0]
        x_max = max(group, key=(lambda k: k[2]))[2]
        y_min = min(group, key=(lambda k: k[1]))[1]
        y_max = max(group, key=(lambda k: k[3]))[3]
        rects_used.append([x_min, y_min, x_max, y_max])
    return rects_used
main function to detect text boxes from image

:param rects: list of 
:type rects: numpy array
:param rectsUsed: image file in numpy array/opencv format
:type rectsUsed: numpy array

:return: output image with the list of text boxes
:rtype: file, list
def __merge_boxes(self, rects):
    'main function to detect text boxes from image\n\n        :param rects: list of \n        :type rects: numpy array\n        :param rectsUsed: image file in numpy array/opencv format\n        :type rectsUsed: numpy array\n\n        :return: output image with the list of text boxes\n        :rtype: file, list\n        '

    def grouper(iterable, interval=2):
        prev = None
        group = []
        for item in iterable:
            if ((not prev) or (abs((item[1] - prev[1])) <= interval)):
                group.append(item)
            else:
                (yield group)
                group = [item]
            prev = item
        if group:
            (yield group)
    rects_used = []
    heights = list()
    for bbox in rects:
        heights.append((bbox[3] - bbox[1]))
    heights = sorted(heights)
    median_height = (heights[(len(heights) // 2)] / 2)
    bboxes_list = sorted(rects, key=(lambda k: k[1]))
    combined_bboxes = grouper(bboxes_list, median_height)
    for group in combined_bboxes:
        x_min = min(group, key=(lambda k: k[0]))[0]
        x_max = max(group, key=(lambda k: k[2]))[2]
        y_min = min(group, key=(lambda k: k[1]))[1]
        y_max = max(group, key=(lambda k: k[3]))[3]
        rects_used.append([x_min, y_min, x_max, y_max])
    return rects_used