Пример #1
0
def merge_draw(merge_path, see, save_name, isShow=True, isSplit=True):
    '''
    merge_path: the path which is the same as the 'save_dir_merge' in function 'eval_map'
    see: the path of images
    save_name: the name of save-folder which you want.
               if save_name = None , it will not save images at the disk
    isShow: show image or not
    isSplit: split the result or not
    '''
    import dota_utils as util
    from DOTA import DOTA
    if isSplit:
        util.Task2groundtruth_poly(merge_path, r'see/labelTxt')
    example = DOTA(r'see')
    imgids = example.getImgIds(catNms=[])
    for imgid in tqdm(imgids):
        anns = example.loadAnns(imgId=imgid)
        imgs = example.loadImgs(imgids=imgid)[0]
        for ann in anns:
            cate = ann['name']
            c = color[cate]
            poly = (np.array([ann['poly']], dtype=np.int32))
            img = cv2.drawContours(imgs, poly, -1, c, 2)
        if save_name != None:
            cv2.imwrite('see/{}/'.format(save_name) + imgid + '.jpg', img)
        if isShow:
            cv2.imshow('{}'.format(imgid), img)
            cv2.waitKey()
def ResultMerge(outputs,
                integrated_outputs,
                merged_outputs,
                dota_outputs = None): 


    if not os.listdir(outputs):
        raise RuntimeError('No detection results founded in {} ! '.format(outputs))    

    util.detections2Task1(outputs, integrated_outputs)
    mergebypoly(integrated_outputs, merged_outputs)
    if dota_outputs is not None:
        if os.path.exists(dota_outputs):
            shutil.rmtree(dota_outputs)
        os.makedirs(dota_outputs)           
        util.Task2groundtruth_poly(merged_outputs, dota_outputs)
Пример #3
0
import numpy as np
import matplotlib.pyplot as plt
import os
from DOTA import DOTA
import dota_utils as util
import pylab
pylab.rcParams['figure.figsize'] = (20.0, 20.0)

from ResultMerge import mergebypoly

# In[12]:

util.groundtruth2Task1(r'examplesplit/labelTxt', r'Task1')
mergebypoly(r'Task1', r'Task1_merge')
util.Task2groundtruth_poly(r'Task1_merge', r'restoredexample/labelTxt')