Example #1
0
def main():
    pixel = read_image('txt.jpg') / 255
    bbox = BboxGeneratorV2(pixel, is_corrected=True).gen_bboxes()
    for box in bbox:
        img = read_image('txt.jpg')
        area = get_text_area_from_bbox(img, box)
        write_image('area.jpg', area)
Example #2
0
def main():
    for i in range(10):
        start_time = time.time()
        text_area = read_image('imgs/txt.jpg')
        gap_area = read_image('imgs/gap.jpg')
        bbox_generator = ContainerBboxGenerate(text_area / 255, gap_area / 255)
        bbox_generator.gen_bbox()
        print(time.time() - start_time)
Example #3
0
def main():
    img = read_image('1.jpg')
    shape = img.shape
    # img = cv2.resize(img, (int(shape[1] / 2), int(shape[0] / 2)))
    color_extractor = ColorExtractor(img)
    res = color_extractor.extract_color()
    write_image('2.jpg', res * 255)
Example #4
0
def main():
    img = read_image('2.jpg') / 255
    img[np.where(img > 0.6)] = 1
    img[np.where(img <= 0.6)] = 0
    connected_domains = get_connected_domains_list(img)
    for index, domain in enumerate(connected_domains):
        write_image('cont' + str(index) + '.jpg', domain * 255)
Example #5
0
def main():
    original_pixel = cv2.imread('pxl.jpg')[:, :, 0] / 255
    bbox_gen = ObliqueBBOXGenerator(original_pixel)
    oblique_bbox = bbox_gen.get_oblique_bbox()
    img = read_image('imgs/1.jpg')
    areas = bbox_gen.get_transparent_text_area(img, oblique_bbox)
    for area in areas:
        write_image('ar.jpg', area)
Example #6
0
def __load_char_mapping():
    """

    """
    char_mapping = {}
    char_paths = get_all_files_under_directory(CHAR_DIR)
    for p in char_paths:
        _, name = os.path.split(p)
        label = name.split('_')[0]
        img = read_image(p)
        if label not in char_mapping:
            char_mapping[label] = []
        char_mapping[label] = img
    return char_mapping
def save_image(image_str, i, file_name):
    if enlarge_radio == 1:
        image_path = TRAINING_DATA_DIR + file_name.replace('.json',
                                                           '') + '.jpg'
    else:
        image_path = TRAINING_DATA_DIR + file_name.replace('.json', '') + \
                     str(enlarge_radio).replace('.', '_') + '.jpg'
    fh = open(image_path, "wb")
    fh.write(base64.b64decode(image_str))
    fh.close()
    img = read_image(image_path)
    shape = img.shape
    img = cv2.resize(
        img, (int(shape[1] * enlarge_radio), int(shape[0] * enlarge_radio)))
    write_image(image_path, img)
Example #8
0
def main():
    # img = to_gray(img)
    # mean_value = img.mean()
    # print(mean_value)

    # paths = get_all_files_under_directory('E:/qianfen_area')
    # for path in paths:
    #     img = read_image(path)
    #     img = enlighten_image_np(111, img)
    #     _, name = os.path.split(path)
    #     write_image('E:/new_area/' + name, img)
    """"""
    img = read_image('1.jpg')

    img = lpls_enlighten(img)
    write_image('2.jpg', img)
def main():
    txt_and_image_paths = 'D:/label_result_2020_3_10/label_result/箱门中文字识别/txt'
    des_line_dir = 'D:/label_result_2020_3_10/label_result/箱门中文字识别/line/'
    paths = get_all_file_from_dir(txt_and_image_paths)
    try:
        for i, p in enumerate(paths):
            if '.jpg' not in p:
                continue
            img_name = os.path.split(p)[1].replace('.jpg', '')
            img = read_image(p)
            txt_path = p.replace('.jpg', '.txt')
            points, is_error = get_points(txt_path)
            if is_error:
                print(p)
            draw_image = get_detect_result(points, img)
            write_image(des_line_dir + img_name + '.jpg', draw_image)
    except Exception as e:
        print(e)
Example #10
0
def main():
    mask = read_image('text.jpg') / 255
    gap = read_image('gap.jpg') / 255
    new_mask = mask * gap * 255
    write_image('new_mask.jpg', new_mask)
Example #11
0
def main():
    pixel = read_image('imgs/pixl.jpg') / 255
    bbox = BboxGeneratorV5(pixel, is_corrected=True).gen_bboxes()
    print(bbox)
Example #12
0
def main():
    pixel = read_image('imgs/1.jpg') / 255
    pass
Example #13
0
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name:     get_all_file_path
   Description :
   Author :       'li'
   date:          2020/1/18
-------------------------------------------------
   Change Activity:
                   2020/1/18:
-------------------------------------------------
"""
import os

from llib.cv_utility.image_opt_utility import read_image, write_image
from utility.file_path_utility import get_all_files_under_directory

img_dir = 'J:/BaiduNetdiskDownload/0506'
des_path = 'J:/BaiduNetdiskDownload/plate_recognize/img/'
paths = get_all_files_under_directory(img_dir)
for path in paths:
    _, name = os.path.split(path)
    image = read_image(path)
    write_image(des_path + name, image)
Example #14
0
def main():
    points = [[642, 592], [724, 658], [724, 692], [652, 628]]
    img = read_image('imgs/1.jpg')
    res = draw_points(points, img)
    write_image('imgs/ll.jpg', res)