Skip to content

Commit

Permalink
to img
Browse files Browse the repository at this point in the history
  • Loading branch information
mingdong-li committed Oct 15, 2019
1 parent 23c9e7e commit ca09bc7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
52 changes: 52 additions & 0 deletions detector/det_process_by_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import numpy as np
import argparse

# 检测结果后处理

def back_process(vd_name):
txt_path = './result/img/%s/det/det.txt'%vd_name
try:
a = np.loadtxt(txt_path,delimiter=',')
except:
print("no %s file"%vd_name)

# index_small = np.where(a[:,4]*a[:,5]<1000)[0]
index_small = np.where((a[:,4]*a[:,5]<1000)&(a[:,3]>1080//2))[0]

save_det = np.delete(a,index_small,axis=0)

np.savetxt('./result/img/%s/det/det.txt'%vd_name,save_det,fmt="%d,%d,%.3f,%.3f,%.3f,%.3f,%.4f,%d,%d,%d")


# txt_path = './result/img/b4/det/det.txt'
# try:
# a = np.loadtxt(txt_path,delimiter=',')
# except:
# a = np.loadtxt(txt_path)

# index_near = np.where(a[:,2]<100)[0]
# area = np.sort(a[:,4]*a[:,5])[-20:]
# width = np.sort(a[:,4])[-20:]
# length = np.sort(a[:,4])[-20:]
# #print('length',length)
# length_index = np.where(a[:,5] > 600)[0]
# width_index = np.where(a[:,4] > 300)[0]
# frame_length = a[length_index,0]
# #print('fra asd',frame_length)
# index_large = np.where(a[:,4]*a[:,5]>100000)[0]
# #print(index_near,len(index_near) )
# #print('\n',index_large,len(index_large))
# delete_index = np.concatenate((index_near,index_large,length_index,width_index),axis=0)
# save_list = np.delete(a,delete_index,axis=0)
# #print(np.shape(save_list))
# #print(width)
# np.savetxt('./result/img/b4/det/det.txt',save_list,fmt="%d,%d,%.3f,%.3f,%.3f,%.3f,%.4f,%d,%d,%d")


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--file', type=str, help='file name')

opt = parser.parse_args()

back_process(opt.file)
2 changes: 1 addition & 1 deletion test_final.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
python detector/to_img_by_name.py --file c1.mp4
python detector/yolov3/detect.py --source result/img/c1/img1 --output result/img/c1/det --img-size 1280 --save_txt
python detector/det_process.py --file c1
python detector/det_process_by_name.py --file c1
python single_demo.py --seq_name c1 --step_times 4

0 comments on commit ca09bc7

Please sign in to comment.