This repository has been archived by the owner on Feb 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
79 lines (63 loc) · 2.57 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
import numpy as np
import glob
import pickle
from vedio2traject import *
def getConfig():
config = {
'dumpFrames2tmp': True, ## If need video2frames
'newDetect': True, ## frames2taginfo
'loadInfoDictFromPickle': False, ## dump frames2taginfo
'dumpInfoDictPickle': True, ## load frames2taginfo
'dumpTxt': True, ## dump (x, y, theta)
'dumpVisualization': True ## Draw the trajectory
}
return config
if __name__ == "__main__":
config = getConfig()
## 90 FOV
vedio_CM = np.array([732.9546741360766, 0.0, 626.491008574248, 0.0, 728.6085953040948, 366.17003214171933, 0.0, 0.0, 1.0]).reshape((3, 3))
tag_size = 0.07
tmp_outdir = './tmp/'
input_dir = './data/'
output_dir = './outputs/'
createFolderIfNotExist(tmp_outdir)
createFolderIfNotExist(output_dir)
## Grab all in input folder
vedio_list = glob.glob(input_dir + 'circle_02.mov')
vedio_list = sorted(vedio_list)
## Grab latest video in input folder
#latest_file = max(list_of_files, key=os.path.getctime)
#vedio_list = [latest_file]
## Grab specify video in input folder
# vedio_list = ['motion_01_1.mov']
# vedio_list = [os.path.join(input_dir, x) for x in vedio_list]
print(vedio_list)
for v in vedio_list:
if not os.path.isfile(v):
print("Check file {} locations. This file does not exists".format(v))
continue
v_basename = os.path.basename(v)
v_basename = v_basename.replace('.mp4', '')
print("Working on " + v_basename + "......")
outdir = os.path.join(
tmp_outdir, get_valid_filename(v_basename))
if config['dumpFrames2tmp']:
vedio2frames(v, outdir)
if config['newDetect']:
[tag_info_dict, msg] = getAprilTagsInfo(outdir,
vedio_CM, tag_size)
print(msg)
if config['dumpInfoDictPickle']:
with open(output_dir + v_basename+'_dict_info.pkl', 'wb') as f:
pickle.dump(tag_info_dict, f)
if config['loadInfoDictFromPickle']:
with open(output_dir + v_basename + '_dict_info.pkl', 'rb') as f:
tag_info_dict = pickle.load(f)
if config['dumpVisualization']:
figpath = output_dir + v_basename + '.png'
else:
figpath = None
if config['dumpTxt']:
dump2txt(
tag_info_dict, output_dir + v_basename+'.txt', figpath)