Ejemplo n.º 1
0
def show_lines(image, lines_elem):
    image_to_show = image.copy()
    for element in lines_elem:
        p_1 = (element['x'], element['y'])
        p_2 = (element['x'] + element['w'], element['y'] + element['h'])
        cv2.rectangle(image_to_show, p_1, p_2, (0, 0, 255), -1)
        utils.show_image(image_to_show)
Ejemplo n.º 2
0
def show_text_elem_in_roi(image, text_elem_in_roi):
    image_to_show = image.copy()
    for element in text_elem_in_roi:
        p_1 = (element['x'], element['y'])
        p_2 = (element['x'] + element['w'], element['y'] + element['h'])
        cv2.rectangle(image_to_show, p_1, p_2, (0, 0, 255), 5)
    utils.show_image(image_to_show)
Ejemplo n.º 3
0
def show_two_bbox(image, element1, element2):
    image_to_show = image.copy()
    p_1 = (element1['x'], element1['y'])
    p_2 = (element1['x'] + element1['w'], element1['y'] + element1['h'])
    p_3 = (element2['x'], element2['y'])
    p_4 = (element2['x'] + element2['w'], element2['y'] + element2['h'])
    cv2.rectangle(image_to_show, p_1, p_2, (0, 0, 255), 3)
    cv2.rectangle(image_to_show, p_3, p_4, (0, 0, 255), 3)
    utils.show_image(image_to_show)
Ejemplo n.º 4
0
def display_centroids(image, centroids, rad=6, color=(0, 0, 255), width=-1):
    """Display centroids as circles for each connected component.

    Args:
        image (np.array): background image to draw centroids on.
        centroids (np.array): coordinates of centroids.
        rad (int): radius of centroid. Defaults to 6.
        color (tuple, optional): color (B, G, R) of centroids. Defaults to (0, 0, 255): red.
        width (int, optional): width of centroids. Defaults to -1 (fill the circle).

    Returns:
        None

    """
    image_to_show = image.copy()
    for coord in centroids:
        cv2.circle(image_to_show, (int(coord[0]), int(coord[1])), rad, color, width)
    utils.show_image(image_to_show)
Ejemplo n.º 5
0
def display_bboxes(image, stats, color=(0, 0, 255), width=3):
    """Display bboxes for each connected component.

        Args:
            image (np.array): background image to draw bboxes on.
            stats (list): CC stats converted to list.
            color (tuple, optional): color (B, G, R) of bbox. Defaults to (0, 0, 255): red.
            width (int, optional): width of centroids. Defaults to 3.

        Returns:
            None

    """
    image_to_show = image.copy() # TODO: combine display_bboxes() and save_bboxes
    for stat in stats:
        p_1 = (stat[0], stat[1])
        p_2 = (stat[0] + stat[2], stat[1] + stat[3])
        cv2.rectangle(image_to_show, p_1, p_2, color, width)
    utils.show_image(image_to_show)
Ejemplo n.º 6
0
def show_bbox(image, element):
    image_to_show = image.copy()
    p_1 = (element['x'], element['y'])
    p_2 = (element['x'] + element['w'], element['y'] + element['h'])
    cv2.rectangle(image_to_show, p_1, p_2, (0, 0, 255), 3)
    utils.show_image(image_to_show)