#!/usr/bin/env python import os import sys import analyze_lost if __name__ == '__main__': if len(sys.argv) != 3: print 'Usage: ./convert_pred.py <org_pred_file> <dest_pred_file>' exit(1) org_pred_fn = sys.argv[1] dest_pred_fn = sys.argv[2] records = analyze_lost.FileToList(org_pred_fn) update_reocrds = list() for record in records: x = float(record[2]) y = float(record[3]) w = float(record[4]) h = float(record[5]) center_x = x + w / 2 center_y = y + h / 2 x = center_x - w / 2 / 1.5 y = center_y - h / 2 / 1.5 w = w / 1.5 h = h / 1.5 record[2] = str(x) record[3] = str(y) record[4] = str(w) record[5] = str(h)
new_w = frame_image.shape[1] - new_x if y + new_h > frame_image.shape[0]: new_h = frame_image.shape[0] - new_y return frame_image[new_y:new_y + new_h, new_x:new_x + new_w, :] if __name__ == '__main__': print 'main' if len(sys.argv) != 3: print 'Usage: ./save_tag_snapshot.py <frame_image_dir> <ground_truth_path>' exit(1) frame_dir = sys.argv[1] ground_truth_path = sys.argv[2] ground_truth_records = analyze_lost.FileToList(ground_truth_path) frame_result_dict = GetFrameRoiMap(ground_truth_records) ordered_frame_result_dict = collections.OrderedDict( sorted(frame_result_dict.items())) #ordered_frame_result_dict = frame_result_dict for frame_id, tags in ordered_frame_result_dict.items(): num = int(frame_id) frame_id = str(int(frame_id)) #print frame_id frame_image = view_log.GetImageFromFrameId(frame_dir, frame_id) draw_image = frame_image.copy() #rois = list() for tag in tags: roi = [x for x in tag[1:]]
***<black_id_track_id_map_file> -- 黑名单ID和track_id映射关系,格式为: <blacklist_id> [track_id0, track_id1, ...] 22351429 2 15 52367262 3 52308398 7 14 52409813 1 13 52598898 6 9 ''' tag_file_path = sys.argv[1] id_map_path = sys.argv[2] output_path = sys.argv[3] map_list = GetIdMapList(id_map_path) print map_list tag_records = analyze_lost.FileToList(tag_file_path) #print tag_records black_list_records = [] for tag_record in tag_records: for map_record in map_list: for x in map_record[1:]: if tag_record[1] == x: label_record = tag_record label_record[1] = map_record[0] black_list_records.append(label_record) else: pass #print black_list_records with open(output_path, 'w') as f:
if len(sys.argv) != 3: print 'Usage: ./convert_tag_res.py <org_tag_fiel> <dest_tag_file>' exit(1) org_tag_fn = sys.argv[1] dest_tag_fn = sys.argv[2] tag_X_res = 1920.0 tag_Y_res = 1080.0 dest_X_res = 1280.0 dest_Y_res = 720.0 x_ratio = dest_X_res / tag_X_res y_ratio = dest_Y_res / tag_Y_res records = analyze_lost.FileToList(org_tag_fn) update_reocrds = list() for record in records: x = float(record[2]) * x_ratio y = float(record[3]) * y_ratio w = float(record[4]) * x_ratio h = float(record[5]) * y_ratio record[2] = str(x) record[3] = str(y) record[4] = str(w) record[5] = str(h) update_reocrds.append(record) with open(dest_tag_fn, 'w') as f: for record in update_reocrds: item = ','.join(x for x in record)
frame_result_dict[frame_id].append(record[2:6]) else: frame_result_dict[frame_id].append(record[2:6]) #print frame_result_dict return frame_result_dict if __name__ == '__main__': print 'main' if len(sys.argv) != 3: print 'Usage: ./view_pred.py <frame_image_dir> <pred_path>' exit(1) frame_dir = sys.argv[1] pred_path = sys.argv[2] pred_records = analyze_lost.FileToList(pred_path) frame_result_dict = GetFrameRoiMap(pred_records) ordered_frame_result_dict = collections.OrderedDict( sorted(frame_result_dict.items())) #ordered_frame_result_dict = frame_result_dict for frame_id, tags in ordered_frame_result_dict.items(): num = int(frame_id) frame_id = str(int(frame_id)) #print frame_id frame_image = view_log.GetImageFromFrameId(frame_dir, frame_id) draw_image = frame_image.copy() #rois = list() for tag in tags: roi = ','.join(x for x in tag)