Skip to content

Commit 89c61e0

Browse files
committed
small correction to camera so legacy matching could still run
1 parent 88696d2 commit 89c61e0

File tree

2 files changed

+52
-5
lines changed

2 files changed

+52
-5
lines changed

myptv/imaging_mod.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,5 +307,13 @@ def O(self):
307307
elif self.modelName == 'extendedZolof':
308308
return self.camera.O
309309

310+
311+
@property
312+
def name(self):
313+
'''
314+
Returns the camera name
315+
'''
316+
return self.camera.name
317+
310318

311319

myptv/makePlots/plot_trajectories.py

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
from pandas import read_csv
11-
from numpy import ptp, array, arange, amin, amax, percentile
11+
from numpy import ptp, array, arange, amin, amax, percentile, gradient
1212
import matplotlib.pyplot as plt
1313

1414
from moviepy.video.io.bindings import mplfig_to_npimage
@@ -62,7 +62,10 @@ def plot_trajectories(fname, min_length, write_trajID=False, t0=0, te=-1):
6262

6363
trajIDs = list(trajectories.keys())
6464

65-
count = 0
65+
66+
# estimate maximum velocity
67+
v_lst = [[],[],[]]
68+
used_ids = []
6669
for id_ in trajIDs:
6770
if len(trajectories[id_][:,1])<min_length: continue
6871
time = trajectories[id_][:,-1]
@@ -85,9 +88,45 @@ def plot_trajectories(fname, min_length, write_trajID=False, t0=0, te=-1):
8588
xs = trajectories[id_][i0:ie,1]
8689
ys = trajectories[id_][i0:ie,2]
8790
zs = trajectories[id_][i0:ie,3]
88-
c = (1-(xs[0]-xmin)/(xmax-xmin)*0.97,
89-
(ys[0]-ymin)/(ymax-ymin)*0.97,
90-
(zs[0]-zmin)/(zmax-zmin)*0.97)
91+
if len(xs)<2: continue
92+
v_lst[0].append(abs(sum(gradient(xs))/len(xs)))
93+
v_lst[1].append(abs(sum(gradient(ys))/len(ys)))
94+
v_lst[2].append(abs(sum(gradient(zs))/len(zs)))
95+
used_ids.append(id_)
96+
97+
V = amax(v_lst)
98+
99+
count = 0
100+
for id_ in used_ids:
101+
time = trajectories[id_][:,-1]
102+
inds = arange(len(trajectories[id_]))
103+
104+
if time[0]>=te or time[-1]<=t0:
105+
continue
106+
107+
if time[0]>=t0:
108+
i0 = 0
109+
else:
110+
i0 = inds[time==t0][0]
111+
112+
if time[-1]<=te:
113+
ie = -1
114+
else:
115+
ie = inds[time==te][0]
116+
117+
118+
xs = trajectories[id_][i0:ie,1]
119+
ys = trajectories[id_][i0:ie,2]
120+
zs = trajectories[id_][i0:ie,3]
121+
vx = sum(gradient(xs))/len(xs) / V
122+
vy = sum(gradient(ys))/len(ys) / V
123+
vz = sum(gradient(zs))/len(zs) / V
124+
#c = (1-(xs[0]-xmin)/(xmax-xmin)*0.97,
125+
# (ys[0]-ymin)/(ymax-ymin)*0.97,
126+
# (zs[0]-zmin)/(zmax-zmin)*0.97)
127+
c = [0.5-vx, 0.5+vy, 0.5+vz]
128+
c = [1*(ci>1) + ci*(ci<=1) for ci in c]
129+
c = [0*(ci<0) + ci*(ci>=0) for ci in c]
91130
l = ax.plot(xs, zs, ys, 'o-', ms=1, lw=0.5, color=c)
92131

93132
xm.append(amin(xs)) ; xm.append(amax(xs))

0 commit comments

Comments
 (0)