from file_utils import time_start, timer_end

is_ctpn = True
is_uied = True
is_merge = True

PATH_IMG_INPUT = 'data\\input\\web\\6.png'
PATH_LABEL_COMPO = 'data\\output\\compo.json'
PATH_LABEL_TEXT = 'data\\output\\ocr.txt'
PATH_CTPN_DRAWN = 'data\\output\\ctpn.png'
PATH_UIED_DRAWN = 'data\\output\\uied.png'
PATH_UIED_BIN = 'data\\output\\gradient.png'
PATH_MERGE = 'data\\output\\merged.png'
PATH_COMPONENT = 'data\\output\\components'
img_section = (3000, 1500)  # selected img section, height and width

start = time_start()

if is_ctpn:
    import ocr
    ocr.ctpn(PATH_IMG_INPUT, PATH_LABEL_TEXT, PATH_CTPN_DRAWN, img_section)
if is_uied:
    import ui
    ui.uied(PATH_IMG_INPUT, PATH_LABEL_COMPO, PATH_UIED_DRAWN, PATH_UIED_BIN, img_section)
if is_merge:
    import merge
    merge.incorporate(PATH_IMG_INPUT, PATH_LABEL_COMPO, PATH_LABEL_TEXT, PATH_MERGE, img_section, is_clip=True, clip_path=PATH_COMPONENT)

timer_end(start)
Exemple #2
0
        continue
    input_path_img = line.split()[0]
    print(input_path_img)

    # *** start processing ***
    start = time.clock()

    # set output paths
    # for image detection
    label_compo = pjoin(C.ROOT_LABEL_UIED, str(index) + '.json')
    img_uied_drawn = pjoin(C.ROOT_IMG_DRAWN_UIED, str(index) + '.png')
    img_uied_grad = pjoin(C.ROOT_IMG_GRADIENT_UIED, str(index) + '.png')
    # for text recognition (ctpn)
    label_text = pjoin(C.ROOT_LABEL_CTPN, str(index) + '.txt')
    img_ctpn_drawn = pjoin(C.ROOT_IMG_DRAWN_CTPN, str(index) + '.png')
    # for incorporated results
    img_merge = pjoin(C.ROOT_IMG_MERGE, str(index) + '.png')
    label_merge = pjoin(C.ROOT_OUTPUT, 'label.txt')

    if is_ctpn:
        ocr.ctpn(input_path_img, label_text, img_ctpn_drawn, img_section)
    if is_uied:
        ui.uied(input_path_img, label_compo, img_uied_drawn, img_uied_grad,
                img_section)
    if is_merge:
        merge.incorporate(input_path_img, label_compo, label_text, img_merge,
                          label_merge, img_section, is_clip)

    print('%d Time Taken:%.3f s\n' % (index, time.clock() - start))
    index += 1