Mercurial Hosting > traffic-intelligence
annotate scripts/nomad/site-parameters-optimization.py @ 1241:ab4c72b9475c
work in progress
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 05 Feb 2024 17:06:01 -0500 |
parents | a09a80cdc118 |
children |
rev | line source |
---|---|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
1 #! /usr/bin/env python3 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
2 import os |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
3 import sys |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
4 import glob |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
5 from trafficintelligence import storage, moving |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
6 import subprocess |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
7 import numpy as np |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
8 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
9 |
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
10 def loadParameters(filename): |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
11 # load initial parameters from x.txt |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
12 f = open(filename, 'r+') |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
13 l = f.readline() |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
14 x = [s for s in l.strip().split(" ")] |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
15 f.close() |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
16 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
17 # create para-value list |
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
18 return paraValueList(x) |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
19 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
20 def paraValueList(x): |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
21 #create para-value list |
1223
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
22 #list of the parameters and their values |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
23 p = ['--feature-quality', #]0.-0.4] |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
24 '--min-feature-distanceklt', #]0.-10] |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
25 '--block-size', #[1-10]integer |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
26 '--window-size', #[1-10]integer |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
27 '--min-feature-displacement', #[0.0001-0.1] 0.05 |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
28 '--acceleration-bound', #[1.-5.] 3 |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
29 '--deviation-bound', #[-1, 1] 0.6 |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
30 #p[3] = '--min-tracking-error' #[0.01-0.3] |
1224
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
31 '--min-feature-time', #[2-100] integer |
1223
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
32 '--mm-connection-distance', #[0.5-100] |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
33 '--mm-segmentation-distance', #[1-100] ~mm-connection-distance / 2.5 |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
34 '--min-nfeatures-group'] #[2-4] |
1224
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
35 integerParameters = [2, 3, 7] |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
36 para = [] |
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
37 if len(x) == 4: |
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
38 for n in range(4): |
1224
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
39 if n+7 in integerParameters: |
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
40 value = x[n].split('.')[0] #int(np.floor(float(x[n]))) recast to str |
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
41 else: |
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
42 value = x[n] |
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
43 para = para + [p[-4+n],value] |
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
44 else: |
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
45 for n in range(len(x)): |
1224
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
46 if n in integerParameters: |
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
47 value = x[n].split('.')[0] |
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
48 else: |
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
49 value = x[n] |
a09a80cdc118
solving the issue of integer parameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1223
diff
changeset
|
50 para = para + [p[n], value] |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
51 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
52 return para |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
53 |
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
54 def process(para, intersections, recursive): |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
55 Mota = [] |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
56 gtDatabaseaAbsPaths = [] |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
57 configFileAbsPaths = [] |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
58 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
59 cwd = os.getcwd() |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
60 # move to the location of the intersection |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
61 for intersectionPath in intersections: |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
62 intersectionAbsPath = os.path.abspath(intersectionPath) |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
63 os.chdir(intersectionAbsPath) |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
64 # iterate through all the subdirectories to find ground truth sqlite files |
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
65 newPaths = [os.path.abspath(fn) for fn in glob.glob(intersectionAbsPath+'/*_gt.sqlite', recursive=recursive)] |
1190
d24d57e4de24
work on optimization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1189
diff
changeset
|
66 gtDatabaseaAbsPaths.extend(newPaths) |
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
67 configFilename = os.path.abspath(glob.glob(intersectionAbsPath+'/*.cfg', recursive=recursive)[0]) |
1190
d24d57e4de24
work on optimization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1189
diff
changeset
|
68 configFileAbsPaths.extend([configFilename]*len(newPaths)) |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
69 os.chdir(cwd) |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
70 for gtDatabaseAbsPath, configFileAbsPath in zip(gtDatabaseaAbsPaths, configFileAbsPaths): |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
71 gtDatabaseBasename = gtDatabaseAbsPath[:-10] |
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
72 videoFilename = gtDatabaseBasename + ".avi" # careful, it may be necessary to check video type / extension |
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
73 if not os.path.exists(videoFilename): |
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
74 print('Video file {} does not exist'.format(videoFilename)) |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
75 databaseFilename = gtDatabaseBasename + ".sqlite" |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
76 gtDatabaseDirname = os.path.dirname(gtDatabaseAbsPath) |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
77 homographyFilename = gtDatabaseDirname + "/homography.txt" |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
78 maskFilename = gtDatabaseDirname + "/mask.png" |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
79 # Skip feature tracking if the user specified to optimize only grouping parameters |
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
80 if len(para) > 8: |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
81 # Track features |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
82 trackingFeature(para, configFileAbsPath, videoFilename, databaseFilename, homographyFilename, maskFilename) |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
83 # Group features |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
84 groupFeature(para, configFileAbsPath, videoFilename, databaseFilename, homographyFilename, maskFilename) |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
85 #load trajectory |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
86 objects = storage.loadTrajectoriesFromSqlite(databaseFilename, 'object') |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
87 #load ground truth |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
88 annotations = storage.loadTrajectoriesFromSqlite(gtDatabaseAbsPath, 'object') |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
89 # Appending negative mota because nomad minimizes the output |
1191
f3b3696f5640
adding time interval for MOTA computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1190
diff
changeset
|
90 matchingDistance = 5 |
1192
606817bc31e8
bug correction
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1191
diff
changeset
|
91 inter = moving.TimeInterval.unionIntervals([a.getTimeInterval() for a in annotations]) |
1191
f3b3696f5640
adding time interval for MOTA computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1190
diff
changeset
|
92 motp, mota, mt, mme, fpt, gt, gtMatches, toMatches = moving.computeClearMOT(annotations, objects, matchingDistance, inter.first, inter.last) |
f3b3696f5640
adding time interval for MOTA computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1190
diff
changeset
|
93 Mota.append(-mota) |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
94 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
95 # Change to the previous directory |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
96 os.chdir(cwd) |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
97 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
98 return np.mean(Mota) |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
99 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
100 def trackingFeature(para, config, video, db, homo, mask): |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
101 # remove previous tracking |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
102 if os.path.exists(db): |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
103 os.remove(db) |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
104 # trackingfeature command parameters |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
105 tf = ['feature-based-tracking', config, '--tf', '--video-filename', video, '--database-filename', db, '--homography-filename', homo, '--mask-filename', mask] |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
106 # run in command line and print directly |
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
107 subprocess.check_output(tf + para) |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
108 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
109 def groupFeature(para, config, video, db, homo, mask): |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
110 #remove previous grouping |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
111 storage.deleteFromSqlite(db, 'object') |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
112 #groupfeature command parameters |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
113 gf = ['feature-based-tracking', config, '--gf', '--video-filename', video, '--database-filename', db, '--homography-filename', homo, '--mask-filename', mask] |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
114 #run in command line and print directly |
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
115 subprocess.check_output(gf + para) # ['--min-feature-time', 'x', '--mm-connection-distance', 'x', '--mm-segmentation-distance', 'x', '--min-nfeatures-group', 'x'] |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
116 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
117 |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
118 if __name__ == "__main__": |
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
119 # Load args that were given with select-arguments.py |
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
120 # with open('arguments.txt', 'r') as f: |
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
121 # args = f.read().split('\n') |
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
122 # intersections = args[0] |
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
123 # optimizeGroupingOnly = eval(args[1]) |
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
124 # intersections = eval(intersections) |
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
125 |
1223
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
126 # Just write the intersections to optimize here: do not use '~' for home directory |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
127 intersections = ['/home/nicolas/Research/Data3/test-optimization/12-laurier'] |
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
128 recursive = False |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
129 |
1223
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
130 # first and only argument should be the |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
131 if len(sys.argv) == 2: |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
132 para = loadParameters(sys.argv[1]) |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
133 # run process including trackingfeature, groupfeature, load groundtruth, compute mota |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
134 print(process(para, intersections, recursive)) |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
135 else: |
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
136 print('Usage: site-parameters-optimization.py [initial-parameters text file]') |
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
137 sys.exit(0) |