Esempio n. 1
0
from os.path import join as pjoin
import glob
import pandas as pd
import cv2
import numpy as np

import CONFIG

C = CONFIG.Config()
element_map = {
    '0': 'button',
    '1': 'input',
    '2': 'select',
    '3': 'search',
    '4': 'list'
}
element_number = {'button': 0, 'input': 0, 'select': 0, 'search': 0, 'list': 0}


def view(img, label):

    # 'x_min, y_min, x_max, y_max, element'
    for l in label:
        l = l.split(',')
        print(l)
        x_min = int(l[0])
        y_min = int(l[1])
        x_max = int(l[2])
        y_max = int(l[3])
        element = element_map[l[4]]
        element_number[element] += 1
Esempio n. 2
0
import json
from glob import glob
from os.path import join as pjoin
import cv2
import numpy as np

import lib_ip.ip_segment as seg
import CONFIG

cfg = CONFIG.Config()


def draw_bounding_box(img,
                      corners,
                      classes,
                      resize_height=800,
                      color_map=cfg.COLOR,
                      line=2,
                      show=False,
                      write_path=None):
    def resize_by_height(org):
        w_h_ratio = org.shape[1] / org.shape[0]
        resize_w = resize_height * w_h_ratio
        re = cv2.resize(org, (int(resize_w), int(resize_height)))
        return re

    board = resize_by_height(img)
    for i in range(len(corners)):
        board = cv2.rectangle(board, corners[i][0], corners[i][1],
                              color_map[classes[i]], line)
        board = cv2.putText(board, classes[i],