示例#1
0
def main():
    all_paths = get_all_files_under_directory(PARENT_DIR_PATH)
    delete_paths = get_all_files_under_directory(DELETE_PATH)
    all_keys = get_key(all_paths)
    delete_keys = get_key(delete_paths)
    index = 0
    for key in all_keys:
        if key not in delete_keys:
            print(key)
            shutil.copy(PARENT_DIR_PATH + key + '.jpg',
                        DES_PATH + str(index) + '_' + key + '.jpg')
            index = index + 1
示例#2
0
def get_name_set():
    paths = get_all_files_under_directory('J:/waier_nei_jika/has_line')
    names = set()
    for path in paths:
        _, name = os.path.split(path)
        names.add(name)
    return names
示例#3
0
def main():
    paths = get_all_files_under_directory(ORIGINAL_DIR_PATH)
    for p in paths:
        label = get_label(p)
        print(label)
        new_path = DES_PATH + label + '-' + str(uuid.uuid4()) + '.jpg'
        shutil.copy(p, new_path)
def classification_images():
    images_path = get_all_files_under_directory(ORIGINAL_PATH)
    images_size = len(images_path)
    for index in range(images_size):
        try:
            p = images_path[index]
            if index % 100 == 0:
                print(str(index) + '/' + str(images_size))
            dir_path, image_name = os.path.split(p)
            label = str(image_name.split('-')[0]).replace('#',
                                                          '').replace(' ', '')
            if label == '':
                dir_name = 'unrecognize'
            else:
                length = len(label)
                dir_name = str(length)
            new_path = os.path.join(DESTINATION_PATH, dir_name)
            new_path = os.path.join(new_path, label)
            create_dir(new_path)
            # if label[0] == '4':
            # label = label.replace('\\', '').replace('/', '')
            md5 = GetFileMd5(p)
            image_name = label + '-' + md5 + '.jpg'
            des_path = os.path.join(new_path, image_name)
            # if len(label) == 4:
            shutil.copy(p, des_path)
        except Exception as e:
            print(e)
def get_fonts_paths():
    """
    获取字体格式文件路径
    :return:
    """
    file_name = get_all_files_under_directory(FONTS_DIR_PATH)
    fonts_paths = []
    for i in range(CHOOSE_FONTS_SIZE):
        files = random.choice(file_name)
        fonts_paths.append(files)
    return fonts_paths
示例#6
0
def main():
    mask_model = MaskModel()
    dir_path = 'F:\dataset\detection_result/results/00f3d476-b62a-11e8-a9c6-11533fbcc673'
    paths = get_all_files_under_directory(dir_path)
    images = []
    for p in paths:
        if p.find('.png') > 0:
            images.append(cv2.imread(p))

    prece = mask_model.input_images_preprocess(images)
    mask_model.build()
def main():
    ver = 'E:\dataset\horizontal'
    paths = get_all_files_under_directory(ver)
    for index, path in enumerate(paths):
        if index % 100 == 0:
            print(index)
        _, img_name = os.path.split(path)
        label = img_name.split('-')[0]
        img = cv2.imread(path)
        if len(label) < 2:
            continue
        seg_horozontal(label, img)
示例#8
0
def main():
    ver = 'E:\dataset/vertical'
    paths = get_all_files_under_directory(ver)
    for index, path in enumerate(paths):
        if index % 100 == 0:
            print(index)
        _, name = os.path.split(path)
        label = name.split('-')[0]
        if len(label) == 1:
            continue
        img = cv2.imread(path)
        seg_vertical(label, img)
示例#9
0
def __main():
    img_paths = get_all_files_under_directory(SOURCE_DIR)
    for index, path in enumerate(img_paths):
        if '.jpg' not in path:
            continue
        if index % 10 == 0:
            print(index)
        _, name = os.path.split(path)
        dir_name = name.split('_')[0]
        md5_name = GetFileMd5(path)
        des_path = DES_DIR + md5_name + '.jpg'
        shutil.copy(path, des_path)
示例#10
0
def load_mapping(image_dir_path):
    """
    load  name and path map
    :param image_dir_path:
    :return:
    """
    imgs_path = get_all_files_under_directory(image_dir_path)
    mapping = {}
    for p in imgs_path:
        _, name = os.path.split(p)
        name = name.split('.')[0]
        mapping[name] = p
    return mapping
示例#11
0
def get_black_images():
    images_path = get_all_files_under_directory(ORIGINAL_PATH)
    for p in images_path:
        try:
            img = cv2.imread(p)
            mean = np.mean(np.mean(img, axis=0), axis=0)
            if mean[0] < 40 and mean[1] < 40 and mean[2] < 40:
                _, file_name = os.path.split(p)
                print(file_name)
                # os.remove(p)
                shutil.move(p, BLACK_PATH + file_name)
        except Exception as e:
            print(e)
            print(p)
示例#12
0
def main():
    img_dir = 'C:/Users/lr/Desktop/txt_inage'
    img_paths = get_all_files_under_directory(img_dir)
    txt_mapping = get_txt_mapping()
    des_dir = 'C:/Users/lr/Desktop/genb/'
    for path in img_paths:
        _, name = os.path.split(path)
        name = name.split('_____')[0]
        if name not in txt_mapping:
            print(name)
            continue

        new_name = get_uuid_str()
        des_path = des_dir + new_name + '.jpg'
        shutil.copy(path, des_path)
        with open('result1.txt', mode='a', encoding='utf8') as file:
            line = new_name + ' ' + txt_mapping[name] + '\n'
            file.write(line)
示例#13
0
def main():
    source_dir = 'J:/car_door/original_image'
    door_side_dir = 'J:/car_door/to_class/door_side/'
    other_side_dir = 'J:/car_door/to_class/other_side/'
    paths = get_all_files_under_directory(source_dir)
    random.shuffle(paths)
    for index, path in enumerate(paths):
        _, name = os.path.split(path)
        # if index < 4810:
        #     continue
        if index % 10 == 0:
            print(index)
        if 'Pos' in name:
            continue
        print(path)
        if 'Front' in name:
            des_path = door_side_dir + name
            shutil.copy(path, des_path)
        elif 'Rear' in name:
            des_path = other_side_dir + name
            shutil.copy(path, des_path)
示例#14
0
   Description :
   Author :       'li'
   date:          2020/1/8
-------------------------------------------------
   Change Activity:
                   2020/1/8:
-------------------------------------------------
"""
import os
import shutil

from utility.file_path_utility import get_all_files_under_directory

names = set()
with open('name.txt', mode='r', encoding='utf8') as file:
    lines = file.readlines()
    for line in lines:
        line = line.strip()
        if len(line) > 1:
            names.add(line)

image_dir = 'J:/dangerous_mark/tocheck/dele/no/'
des_dir = 'C:/Users/lr/Desktop/tolael/'
image_paths = get_all_files_under_directory(image_dir)
for path in image_paths:
    _, name = os.path.split(path)
    name = name.replace('.jpg', '')
    if name not in names:
        print(name)
        shutil.copy(path, des_dir + name + '.jpg')
示例#15
0

def get_images_average_value(images_path):
    """
    get images average values
    :param images_path:
    :return:
    """
    images_size = len(images_path)
    print('images size:' + str(images_size))
    total_value = np.zeros((3,), dtype=np.float)
    add_time = 0
    for index in range(images_size):
        if index % 100 == 0:
            print(str(index) + '/' + str(images_size))
        p = images_path[index]
        img = cv.imread(p)
        if img is not None:
            aver = get_one_image_average_value(img)
            total_value = np.add(total_value, aver)
            add_time = add_time + 1
    average_value = total_value / add_time
    return average_value


if __name__ == '__main__':
    dir_path = 'F:\BaiduNetdiskDownload/uuid_image'
    paths = get_all_files_under_directory(dir_path)
    average_value = get_images_average_value(paths)
    print(average_value)
示例#16
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)