def splitdata(self, rate): """ :param rate: resize rate before cut """ imagelist = GetFileFromThisRootDir(self.imagepath) imagenames = [util.custombasename(x) for x in imagelist if (util.custombasename(x) != 'Thumbs')] for name in imagenames: self.SplitSingle(name, rate, self.ext)
def generate_file_list(img_dir, output_txt, file_ext='.txt'): #读取原图路径 # img_dir=os.path.split(img_dir)[0] imgs_path = GetFileFromThisRootDir(img_dir, file_ext) f = open(output_txt, "w", encoding='utf-8') for num, img_path in enumerate(imgs_path, 0): obj = '{}\n'.format(os.path.splitext(os.path.split(img_path)[1])[0]) f.write(obj) f.close() print('Generate {} down!'.format(output_txt))
def splitdata(self, rate): """ :param rate: resize rate before cut """ imagelist = GetFileFromThisRootDir(self.imagepath) imagenames = [util.custombasename(x) for x in imagelist if (util.custombasename(x) != 'Thumbs')] image_num = 1 for name in imagenames: print('############################') print(r'process image:' + name + ' <<< >>> the %d image '%(image_num) + 'of total image num %d' %(int(len(imagenames)))) self.SplitSingle(name, rate, self.ext) image_num += 1
def splitdata(self, rate): """ :param rate: resize rate before cut """ imagelist = GetFileFromThisRootDir(self.imagepath) imagenames = [util.custombasename(x) for x in imagelist if (util.custombasename(x) != 'Thumbs')] worker = partial(self.SplitSingle, rate=rate, extent=self.ext) # # for name in imagenames: # self.SplitSingle(name, rate, self.ext) self.pool.map(worker, imagenames)
def splitdata(self, rate): """ :param rate: resize rate before cut """ imagelist = GetFileFromThisRootDir(self.imagepath) imagenames = [util.custombasename(x) for x in imagelist if (util.custombasename(x) != 'Thumbs')] if self.num_process == 1: for name in imagenames: self.SplitSingle(name, rate, self.ext) else: # worker = partial(self.SplitSingle, rate=rate, extent=self.ext) worker = partial(split_single_warp, split_base=self, rate=rate, extent=self.ext) self.pool.map(worker, imagenames)
def DOTAtxt2GT_to_eval(GT_xml_path, txt_dir_h, file_ext='.txt'): if not os.path.exists(txt_dir_h): os.mkdir(txt_dir_h) file_paths = GetFileFromThisRootDir(GT_xml_path, file_ext) for count, txt_path in enumerate(file_paths): bboxes, labels, bboxes_ignore, labels_ignore = parse_ann_info(txt_path) # eval txt # Task1 # write_handle_h = open( os.path.join( txt_dir_h, 'Task1_gt_{}.txt'.format( os.path.splitext(os.path.split(txt_path)[1])[0])), 'w') #Task1_gt_ for i, rbox in enumerate(bboxes): # rbox[4]=0 # rbox_cv=rotate_rect2cv(rbox) # rect_box = cv2.boxPoints(rbox_cv) rect_box = rbox2poly_single(rbox) command = '%.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f %s 0\n' % ( rect_box[0], rect_box[1], rect_box[2], rect_box[3], rect_box[4], rect_box[5], rect_box[6], rect_box[7], labels[i]) write_handle_h.write(command) write_handle_h.close()