提取visdrone2019數(shù)據(jù)集數(shù)據(jù)_第1頁
提取visdrone2019數(shù)據(jù)集數(shù)據(jù)_第2頁
提取visdrone2019數(shù)據(jù)集數(shù)據(jù)_第3頁
提取visdrone2019數(shù)據(jù)集數(shù)據(jù)_第4頁
提取visdrone2019數(shù)據(jù)集數(shù)據(jù)_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、visdrone2019數(shù)據(jù)集數(shù)據(jù)這通過只提取類跟蹤數(shù)據(jù)集,因此對其更改,如果需要提取多類的直接打開即可,同時呢這個轉換為多累跟蹤數(shù)據(jù)集,其中數(shù)據(jù)的格式為:,其中的類別為:ignored regions(0), pedestrian(1),people(2), bicycle(3), car(4), van(5), truck(6), tricycle(7), awning-tricycle(8), bus(9),motor(10),others(11)# import shutil# -110 類是我們需要檢測和跟蹤的標# van# truck# tricycle# awning-tricy

2、cle (8), - 7# bus# motor# -# others(11)# We need 10 classes to detect and trackingvan: 4,:param img: opencv(numpy array): HWC:param boxes: a list of boxes: left(box0), top(box1), width(box2), height(box3)box = list(map(lambda x: int(x + 0.5), box) # 四舍五imgbox1: box1 + box3, box0: box0 + box2 = 0, 0,

3、 0return imgdef gen_dot_train_file(data_root, rel_path, out_root, f_name=detrac.train):param rel_path:param out_root:param f_name:return:if not (os.path.isdir(data_root) and os.path.isdir(out_root):out_f_path = out_root + / + f_namecnt = 0with open(out_f_path, w) as f:root = data_root + rel_pathseqs

4、 = x for x in os.listdir(root)seqs.sort()# seqs = sorted(seqs, key=lambda x: int(x.split(_)-1)for seq in tqdm(seqs):img_dir = root + / + seq # + /img1img_list = x for x in os.listdir(img_dir)img_list.sort()for img in img_list:if img.endswith(.jpg):f.write(item + n)cnt += 1print(Total :d images for t

5、raining.format(cnt)def gen_track_dataset(src_root, dst_root, viz_root=None):dst_img_root = dst_root + /imagesdst_txt_root = dst_root + /labels_with_idsif not os.path.isdir(dst_img_root):os.makedirs(dst_img_root)# id, 0# track_start_id = 0track_start_id_dict = defaultdict(int) # start id0開始for cls_id

6、 in id2cls.keys():# 遍歷每個視頻序列for seq in tqdm(seq_names):print(Processing :.format(seq)seq_img_dir = src_root + /sequences/ + seqseq_txt_f_path = src_root + /annotations/ + seq + .txt# ()dst_seq_img_dir = dst_img_root + / + seqif not os.path.isdir(dst_seq_img_dir):os.makedirs(dst_seq_img_dir)dst_seq_t

7、xt_dir = dst_txt_root + / + seqif not os.path.isdir(dst_seq_txt_dir):os.makedirs(dst_seq_txt_dir)# seqtrack_id# seq_max_tar_id = 0seq_max_tra_id_dictk = 0# 視頻序列seq_frame_names = os.listdir(seq_img_dir)seq_frame_names.sort()label_n_lines = len(label_lines)for line_i, line in enumerate(label_lines):li

8、ne = int(x) for x in line.strip().split(,)seq_label_arrayline_i = lineseq_label_arrayline_i = line# 這需要注意的是,數(shù)據(jù)集的格式為:# ,# 數(shù)據(jù)集的類別為:# ignored regions(0), pedestrian(1),people(2), bicycle(3), car(4), van(5), truck(6), tricycle(7), awning-tricycle(8), bus(9), motor(10),others(11)# 0boxbox,因此分兩部分處理,把忽略的和真

9、正的類別進區(qū)分處理# , seq_objs_label_dict = defaultdict(list)# seqdictclasstarget idseq_cls_target_ids_dict = defaultdict(list)tmp_ids_dict = defaultdict(set)cls_id = label7 - 1target_id = label1#for cls_id in tmp_ids_dict.keys():track_ids = tmp_ids_dictcls_id# track_ids = set(track_ids)track_ids = list(trac

10、k_ids)track_ids.sort()seq_cls_target_ids_dictcls_id = track_ids# track_ids = tmp_ids_dict9# track_ids = list(track_ids)# track_ids.sort()for k, v in seq_cls_target_ids_dict.items():seq_max_tra_id_dictk = len(v)# print( max track id: :d, start id: :d#.format(id2cls9, seq_max_tra_id_dict0, track_start

11、_id_dict0)for k in id2cls.keys():# 讀取每幀for fr_id in seq_objs_label_dict.keys():# -fr_labels = seq_objs_label_dictfr_idprint(Err: empty image.)continueviz_path = viz_dir + / + fr_name# img數(shù)據(jù)作為可視化輸出img_viz = copy.deepcopy(img)# - label(txt)# label_str(or)fr_label_strs = for label in fr_labels:# cls_id

12、 and cls_nameobj_type = label7assert 0 obj_type 11cls_id = obj_type - 1 # 0開始# cls_name = id2clscls_idtarget_id = label1score = label6truncation = label8 # no truncation = 0 (truncation ratio 0%), and partial truncation = 1 (truncation ratio 1% 50%)occlusion = label9# - label(label/): 在歸化之前if not (v

13、iz_root is None): # 如果可視化錄不為空# targetbboxcv2.rectangle(img_viz,pt_1,pt_2,cls_str = id2clscls_idveh_type_str_size = cv2.getTextSize(cls_str,cv2.FONT_HERSHEY_PLAIN,1.3,1)0(pt_10,cv2.FONT_HERSHEY_PLAIN,1.3,225, 255, 255,1)tr_id_str_size = cv2.getTextSize(tr_id_str,cv2.FONT_HERSHEY_PLAIN,1.3,1)0cv2.putT

14、ext(img_viz,tr_id_str,(pt_10,pt_11 + veh_type_str_size1 + tr_id_str_size1 + 8),cv2.FONT_HERSHEY_PLAIN,1.3,225, 255, 255,1)# bbox中點坐標bbox_center_x = bbox_left + bbox_width * 0.5bbox_center_y = bbox_top + bbox_height * 0.5# bbox(0.0, 1.0)bbox_center_x /= Wbbox_center_y /= Hbbox_width /= Wbbox_height /

15、= H# label, label成完成才輸出# class_id, track_id, bbox_center_x, box_center_y, bbox_width, bbox_height# label_str = :d :d :.6f :.6f :.6f :.6fn.format(cls_id,track_id,bbox_center_x,bbox_center_y,bbox_width,bbox_height)label_str = :d :d :.6f :.6f :.6f :.6fn.format(0,track_id,bbox_center_x,bbox_center_y,bbo

16、x_width,bbox_height)fr_label_strs.append(label_str)# seq, track_start_idfor cls_id in id2cls.keys():print(Total :d frames.format(frame_cnt)viz_root=E:/MOTdata/VisDrone2020/viz_result_val)轉換完成以后,進成.train件:88 . 88(| -_- |)0 = /0_/-_. | |/ ./ | : |/ / _| -:- |- | | - / | |佛祖保佑Version: 1.0FilePath: srcg

17、en_data_path copy.pyLastEditTime: 2021-05-28 15:23:35import globprint(image22:, file=f)f.close()def gen_dot_train_file(data_root, rel_path, out_root, f_name=VisDrone2019.train):To generate the dot train file:param data_root:param rel_path:param out_root:param f_name:return:if not (os.path.isdir(data

18、_root) and os.path.isdir(out_root):out_f_path = out_root + / + f_namecnt = 0with open(out_f_path, w) as f:root = data_root +/+ rel_pathseqs = x for x in os.listdir(root)seqs.sort()# seqs = sorted(seqs, key=lambda x: int(x.split(_)-1)for seq in tqdm(seqs):img_dir = root + / + seq # + /img1img_list = x for x in os.listdir(img_dir)img_list.sort()print(Total :d images for training.format(cnt)def clean_train_set(im

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論