Esempio n. 1
0
    }

    pylab.rcParams['figure.figsize'] = (8.0, 10.0)

    show_maskobb = False
    anno_file_name = ['small', 'dota-v1.5']

    img_dir = './data/{}/{}/images'.format(anno_file_name[0],
                                           anno_file_name[1])
    anno_dir = './data/{}/{}/labels'.format(anno_file_name[0],
                                            anno_file_name[1])

    for anno_name in os.listdir(anno_dir):
        file_name = os.path.splitext(os.path.basename(anno_name))[0]
        anno_file = os.path.join(anno_dir, anno_name)
        objects = wwtool.simpletxt_parse(anno_file)

        image_name = os.path.join(img_dir, file_name + '.png')

        im = cv2.imread(image_name)
        bboxes = []
        labels = []
        for obj in objects:
            bbox = obj['bbox']
            label = obj['label']
            bboxes.append(bbox)
            labels.append({label: coco_class[label]})

        wwtool.imshow_bboxes(im,
                             bboxes,
                             labels=labels,
Esempio n. 2
0
import os
import wwtool

label_fold = './data/stanford_campus/v1/trainval_test/labels'
image_fold = './data/stanford_campus/v1/trainval_test/images'

for label_name in sorted(os.listdir(label_fold)):
    print(label_name)
    label_file = os.path.join(label_fold, label_name)
    image_file = os.path.join(image_fold, label_name.split('.')[0] + '.png')
    objects = wwtool.simpletxt_parse(label_file)
    bbox, label = [single_object['bbox'] for single_object in objects
                   ], [single_object['label'] for single_object in objects]
    wwtool.imshow_bboxes(image_file, bbox)
Esempio n. 3
0
if __name__ == "__main__":
    image_format = '.png'

    origin_image_path = './data/visdrone/v1/trainval/images'
    origin_label_path = './data/visdrone/v1/trainval/labels'

    filtered_image_path = './data/visdrone/v1/trainval_filtered/images'
    filtered_label_path = './data/visdrone/v1/trainval_filtered/labels'

    wwtool.mkdir_or_exist(filtered_image_path)
    wwtool.mkdir_or_exist(filtered_label_path)

    filter_count = 1
    progress_bar = mmcv.ProgressBar(len(os.listdir(origin_label_path)))
    for label_name in os.listdir(origin_label_path):
        image_objects = wwtool.simpletxt_parse(
            os.path.join(origin_label_path, label_name))
        filtered_objects = []
        for image_object in image_objects:
            if convert_classes[origin_class[image_object['label']]] == None:
                filter_count += 1
                continue
            else:
                image_object['label'] = convert_classes[origin_class[
                    image_object['label']]]
                filtered_objects.append(image_object)

        if len(filtered_objects) > 0:
            img = cv2.imread(
                os.path.join(origin_image_path,
                             os.path.splitext(label_name)[0] + image_format))
            save_image_file = os.path.join(