Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
bf6438f
mot test
Nov 21, 2020
3ea5838
tested 400 frames mot
Nov 23, 2020
4ccc349
tested 400 frames mot
Nov 23, 2020
05abd9c
debug cost
Nov 23, 2020
8ddda7f
flow range
Nov 23, 2020
f2df2ea
build track in loop
Nov 23, 2020
37dbb5d
latest changes
Dec 1, 2020
61e14f1
occlusion model
Dec 3, 2020
ca00eed
tracklet unification
Dec 7, 2020
83763f0
bologna detections
Dec 7, 2020
32ec3ec
preparing for test, claening up
Dec 9, 2020
266934a
visualise bool option
Dec 11, 2020
df1ab29
print arguments
Dec 11, 2020
2b2234d
print bug fix
Dec 11, 2020
6955c0a
hypothesis file offset frame
Dec 12, 2020
c9d548c
match tracking file pattern
Dec 12, 2020
c834c4c
sorting by frame number
Dec 12, 2020
9083f0e
sorting by frame number
Dec 12, 2020
7bf7de0
sorting by frame number
Dec 12, 2020
bd5bf70
sorting by frame number
Dec 12, 2020
a01fdb6
sorting by frame number
Dec 12, 2020
881d766
sorting by frame number
Dec 12, 2020
0177f89
sorting by frame number & preparing test
Dec 12, 2020
32a3921
tlwh
Dec 13, 2020
8480080
tlwh
Dec 13, 2020
547d0ec
tlwh
Dec 13, 2020
bea7d1f
start slice index fix
Dec 13, 2020
0b5e989
last frame index drop fix
Dec 13, 2020
9e8183a
last frame index drop fix
Dec 13, 2020
5f04a10
last frame index drop fix
Dec 13, 2020
6a6fc11
tuning cost paramters
Dec 16, 2020
cd0e63d
tuning cost parameters
Dec 16, 2020
fa58705
tuning cost parameters
Dec 16, 2020
bd9905b
tuning cost parameters
Dec 16, 2020
6f22f43
tuning cost parameters
Dec 16, 2020
2c2d877
reliable - unreliable apperanmce
Dec 17, 2020
66c4718
reliable - unreliable apperanmce
Dec 17, 2020
f78d534
reliable - unreliable apperanmce
Dec 17, 2020
5e92519
debug app mpodel
Dec 17, 2020
3c97806
1000 frames tested
Dec 23, 2020
aeaff4c
refactor code
Dec 28, 2020
9384e99
torchereid framework porting
Dec 29, 2020
c36b40e
adding extrinsic to calculate physical distance
Jan 1, 2021
19b595d
adding extrinsic to calculate physical distance
Jan 1, 2021
8e45ad5
adding physical diustance calculation
Jan 2, 2021
8fcb038
adding physical diustance calculation
Jan 2, 2021
412249e
tuning max distance for track unification
Jan 2, 2021
50b32e6
adding amatch video id argument
Jan 2, 2021
4072ab0
path to child folders
Jan 4, 2021
d39ecea
changing weight of cost
Jan 4, 2021
e4e6c5c
latest chenges
Jan 5, 2021
759bd74
Merge pull request #1 from dimahwang88/local_tmp
Jan 5, 2021
20eade3
cost link - prob_colour
Jan 5, 2021
73953c0
cost link - prob_colour
Jan 5, 2021
968fd86
cost link - prob_colour
Jan 5, 2021
23e4e57
cost link - prob_colour
Jan 5, 2021
61902e2
error handling for empty frame
Jan 5, 2021
73fd081
error handling for empty frame
Jan 5, 2021
ead2b96
error handling for empty frame
Jan 5, 2021
3fcba5a
debugging last
Jan 7, 2021
2019636
testing local changes
Jan 8, 2021
cb02856
lastest tuning and debugging
Jan 11, 2021
9d54038
preparing for test
Jan 11, 2021
710f804
Merge pull request #2 from dimahwang88/local_tmp
Jan 11, 2021
3977d54
remove dets in complex scene
Jan 20, 2021
c2ea3e7
Merge pull request #3 from dimahwang88/local_tmp
Jan 20, 2021
e9fab47
local changes
Jan 26, 2021
c1b79de
restrict complex situation to goal area
Jan 26, 2021
47ae955
Merge pull request #4 from dimahwang88/local_tmp
Jan 26, 2021
6e51b50
bug: track unification wrong condition
Jan 28, 2021
4f6a9ab
Merge pull request #5 from dimahwang88/local_tmp
Jan 28, 2021
d57fb8b
refactor code
Jan 28, 2021
cde574d
adaptive threshold for association
Jan 29, 2021
0a6066a
adaptive threshold
Jan 31, 2021
5edff29
adaptive threshold
Jan 31, 2021
d94ae58
Merge pull request #6 from dimahwang88/local_tmp
Jan 31, 2021
ef61306
fix iou bug
Feb 1, 2021
23e9f5f
[15FPS patch] skipping 1 frame for tracking
Feb 1, 2021
fcd5c1f
PR prepare
Feb 1, 2021
df6ed84
Merge pull request #7 from dimahwang88/local_tmp
Feb 1, 2021
9bbe5ae
reverting 15 FPS patch
Feb 1, 2021
b12a3d7
Merge branch 'master' into local_tmp
Feb 1, 2021
e1d41c5
maxdist assoc. 1.1
Feb 1, 2021
ed0b55d
Merge pull request #8 from dimahwang88/local_tmp
Feb 1, 2021
6ca71da
normalise feature vectors before cos calc
Feb 2, 2021
422672d
remove normalisation before cosine distance
Feb 2, 2021
8146bc0
15 fps with interpolation + tuning
Feb 4, 2021
7f9e546
temporal hungarian frame interpolation
Feb 5, 2021
2adf678
pr
Feb 6, 2021
d276d9d
tuning
Feb 6, 2021
a22a2fc
pr
Feb 6, 2021
4c70041
tested hungarian interp
Feb 6, 2021
8b3e40b
Merge pull request #9 from dimahwang88/local_tmp
Feb 6, 2021
cd66170
fixed: frame slice bug
Feb 7, 2021
29bd1da
pr
Feb 7, 2021
183f04f
Merge pull request #10 from dimahwang88/local_tmp
Feb 7, 2021
0d6edd8
tuning
Feb 8, 2021
dea5323
write last frame's data
Feb 9, 2021
cdb68ea
bug fix: num of frames in chunk
Feb 9, 2021
552e35f
pr
Feb 9, 2021
9952061
Merge pull request #11 from dimahwang88/local_tmp
Feb 9, 2021
8f301ae
fix: inter-chunk connection
Feb 10, 2021
23e8bd5
Merge pull request #12 from dimahwang88/local_tmp
Feb 10, 2021
0f9f6c0
tuning
Feb 10, 2021
5d78ee2
fix: inter-chunk connection
Feb 10, 2021
b7de8dc
Merge pull request #13 from dimahwang88/local_tmp
Feb 10, 2021
1bd83d3
tuning
Feb 21, 2021
f643d16
Merge pull request #14 from dimahwang88/local_tmp
Feb 21, 2021
5a27d05
debugging the graph
Feb 24, 2021
3730059
grid based id removal
Mar 1, 2021
db19e64
last changes
Mar 2, 2021
051a983
implementing tracklet unificatioon
Mar 5, 2021
b45afde
implementing graph for tracklet matching
Mar 6, 2021
a829646
implemented graph for tracklet matching
Mar 8, 2021
0b74c25
debugging track connection
Mar 9, 2021
40b13d4
graph - track connection debugging
Mar 10, 2021
fbc03a8
debug
Mar 10, 2021
050ff21
debugging graph
Mar 11, 2021
57b50b7
iou instead of eucl
Mar 11, 2021
294c4b3
tracklet unif
Mar 11, 2021
5dc8824
tested
Mar 11, 2021
630fc32
preparing for test
Mar 12, 2021
d843e72
Merge pull request #15 from dimahwang88/local_tmp
Mar 12, 2021
4b8b67d
path to reid checkpoint
Mar 12, 2021
f05b78b
wc of top-left for tracklet matching
Mar 12, 2021
f6c85fa
preparing for test
Mar 12, 2021
04848a1
Merge pull request #16 from dimahwang88/local_tmp
Mar 12, 2021
a0781f5
test prob_colour only
Mar 16, 2021
2bbe512
iou->wc
Mar 16, 2021
c34122f
debugging and iou->wc
Mar 17, 2021
a4455ec
assoc wc
Mar 19, 2021
10b90ab
interpolation and debug
Mar 19, 2021
8a4db8f
path 2 checkpt
Mar 19, 2021
fc0c658
nms and filtering
Mar 20, 2021
5557b9f
min confidence 0.3
Mar 20, 2021
ebce86a
test
Mar 20, 2021
1b525c9
adding segmentation and rgb hist
Mar 24, 2021
cde7811
init segmentor
Mar 24, 2021
d9f6c03
removing app model thresholdiong
Mar 26, 2021
e15ecec
color of segm masdk
Mar 26, 2021
c2188a6
masks draw debugging
Mar 27, 2021
cab01fd
debug video with or without mask
Mar 27, 2021
f3a6870
dependencies
Mar 29, 2021
a322427
remove path
Mar 29, 2021
3a2733c
turn off mask viz
Mar 29, 2021
f62ca8d
edge connection wondow
Apr 3, 2021
8a4eec6
no tracklet - backward node connection
Apr 4, 2021
da8557d
max flow 300 -> 40
Apr 6, 2021
c5caffe
clean up
Apr 6, 2021
bbcf2c0
track interpolation
Apr 6, 2021
a560f4e
box prob as cost
Apr 7, 2021
573090d
lower penalty on first frame
Apr 8, 2021
8489686
min confidennce 0.4
Apr 8, 2021
14ca979
first 60 frames backward connection
Apr 8, 2021
22c28dd
kalman filter
Apr 9, 2021
93247f1
kalman for motion
Apr 13, 2021
18fefe8
tuned kalman
Apr 19, 2021
83dd9b0
kalman+mcft
Apr 21, 2021
4cfe983
kf-mcft
Apr 26, 2021
3fa7d9c
kf version
Apr 27, 2021
d730087
ckpt path
Apr 27, 2021
0dd4f1f
print frame num
Apr 29, 2021
bb64240
cost kf+kf
May 6, 2021
5dfbfe4
kf+mcft no app
May 7, 2021
1fa2a45
kf+segmentation appearancec
May 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
179 changes: 179 additions & 0 deletions KalmanFilter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
import numpy as np
import scipy.linalg

class KalmanFilter(object):

def __init__(self):
ndim, dt = 2, 1.

# Create Kalman filter model matrices.
self._motion_mat = np.eye(2 * ndim, 2 * ndim)

for i in range(ndim):
self._motion_mat[i, ndim + i] = dt

self._update_mat = np.eye(ndim, 2 * ndim)

self._std_position = 0.200
self._std_velocity = 0.0350

def initiate(self, measurement):
"""Create track from unassociated measurement.

Parameters
----------
measurement : ndarray
world coordinates of a box (x,y)

Returns
-------
(ndarray, ndarray)
Returns the mean vector (4 dimensional) and covariance matrix (4x4
dimensional) of the new track. Unobserved velocities are initialized
to 0 mean.

"""
mean_pos = measurement
mean_vel = np.zeros_like(mean_pos)
mean = np.r_[mean_pos, mean_vel]

std = [
self._std_position,
self._std_position,
self._std_velocity,
self._std_velocity
]

covariance = np.diag(np.square(std))

return mean, covariance

def predict(self, mean, covariance):
"""Run Kalman filter prediction step.

Parameters
----------
mean : ndarray
The 4 dimensional mean vector of the object state at the previous time step.
covariance : ndarray
The 4x4 dimensional covariance matrix of the object state at the previous time step.

Returns
-------
(ndarray, ndarray)
Returns the mean vector and covariance matrix of the predicted
state. Unobserved velocities are initialized to 0 mean.
"""

std_pos = [
self._std_position,
self._std_position
]

std_vel = [
self._std_velocity,
self._std_velocity
]

motion_cov = np.diag(np.square(np.r_[std_pos, std_vel]))
mean = np.dot(self._motion_mat, mean)

covariance = np.linalg.multi_dot((self._motion_mat, covariance, self._motion_mat.T)) + motion_cov

return mean, covariance

def project(self, mean, covariance):
"""Project state distribution to measurement space.

Parameters
----------
mean : ndarray
The state's mean vector (4 dimensional array).
covariance : ndarray
The state's covariance matrix (4x4 dimensional).

Returns
-------
(ndarray, ndarray)
Returns the projected mean and covariance matrix of the given state
estimate.

"""

std = [
self._std_position,
self._std_position
]

innovation_cov = np.diag(np.square(std))

mean = np.dot(self._update_mat, mean)
covariance = np.linalg.multi_dot((
self._update_mat, covariance, self._update_mat.T))

return mean, covariance + innovation_cov

def update(self, mean, covariance, measurement):
"""Run Kalman filter correction step.

Parameters
----------
mean : ndarray
The predicted state's mean vector (4 dimensional).
covariance : ndarray
The state's covariance matrix (4x4 dimensional).
measurement : ndarray
world coordinates of a box (x, y)

Returns
-------
(ndarray, ndarray)
Returns the measurement-corrected state distribution.
"""

projected_mean, projected_cov = self.project(mean, covariance)

chol_factor, lower = scipy.linalg.cho_factor(
projected_cov, lower=True, check_finite=False)
kalman_gain = scipy.linalg.cho_solve(
(chol_factor, lower), np.dot(covariance, self._update_mat.T).T,
check_finite=False).T

innovation = measurement - projected_mean

new_mean = mean + np.dot(innovation, kalman_gain.T)
new_covariance = covariance - np.linalg.multi_dot((
kalman_gain, projected_cov, kalman_gain.T))

return new_mean, new_covariance

def gating_distance(self, mean, covariance, pos):
"""Compute gating distance between state distribution and measurements.

A suitable distance threshold can be obtained from `chi2inv95`. If
`only_position` is False, the chi-square distribution has 4 degrees of
freedom, otherwise 2.

Parameters
----------
mean : ndarray
Mean vector over the state distribution (4 dimensional).
covariance : ndarray
Covariance of the state distribution (4x4 dimensional).
pos : ndarray

Returns
-------
ndarray
"""

mean, covariance = self.project(mean, covariance)

cholesky_factor = np.linalg.cholesky(covariance)
d = pos - mean
z = scipy.linalg.solve_triangular(
cholesky_factor, d.T, lower=True, check_finite=False,
overwrite_b=True)
squared_maha = np.sum(z * z, axis=0)

return squared_maha
23 changes: 23 additions & 0 deletions Track.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class OnlineTrack:
def __init__(self, id, mean, covariance, kf):
"""
each Track object has mean [x,y,dx,dy] and covariance matrix
and receives Kalman Filter object
"""
self.id = id
self.mean = mean
self.covariance = covariance
self.kf = kf

def update(self, detection):
"""
updates corresponding Kalman Filter object's parameters & mean and covariance of the track
detection - is a box in x,y,w,h format
"""
self.mean, self.covariance = self.kf.update(self.mean, self.covariance, detection)

def predict(self):
"""
updates track's mean and covariance
"""
self.mean, self.covariance = self.kf.predict(self.mean, self.covariance)
71 changes: 71 additions & 0 deletions Tracker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from Track import OnlineTrack
import numpy as np
import KalmanFilter

from scipy.optimize import linear_sum_assignment
import utils

class OnlineTracker:

def __init__(self):
self.tracks = []
self._next_id = 1

def onlineTrackerInit(self, boxes_init):

for box in boxes_init:
new_kf = KalmanFilter.KalmanFilter()
mean, cov = new_kf.initiate(np.asarray(box.to_world()))
self.tracks.append(OnlineTrack(self._next_id, mean, cov, new_kf))
self._next_id += 1

# print ('%d tracks created' % (len(self.tracks)))

return

def onlineTrackerAssign(self, measurements, fnum, thresh=5.9915, inf=1000000):

for track in self.tracks:
track.predict() # updates track.mean and track.covariance

cost_matrix = np.zeros((len(self.tracks), len(measurements)))

for i, track in enumerate(self.tracks):
for j, box in enumerate(measurements):
sq_mah_dist = track.kf.gating_distance(track.mean, track.covariance, box.to_world())
cost_matrix[i][j] = inf if sq_mah_dist >= thresh else sq_mah_dist

row_indices, col_indices = linear_sum_assignment(cost_matrix)

matches = []
unmatched_tracks = []
unmatched_dets = []

for row, col in zip(row_indices, col_indices):
if cost_matrix[row][col] == inf:
# print ('f:%d id:%d cost:%f' % (fnum, self.tracks[row].id, cost_matrix[row][col]))
unmatched_tracks.append(row)
unmatched_dets.append(col)
else:
matches.append((row, col))

for i, _ in enumerate(self.tracks):
if i not in row_indices:
unmatched_tracks.append(i)

for j, _ in enumerate(measurements):
if j not in col_indices:
unmatched_dets.append(j)

# for tidx in unmatched_tracks:
# print ('f:%d id:%d unmatched' % (fnum, self.tracks[tidx].id))

return matches, unmatched_tracks, unmatched_dets

def onlineTrackerUpdate(self, matches, measurements):
"""
tracks.update - new_measurements
"""

for match in matches:
self.tracks[match[0]].update(measurements[match[1]].to_world())
7 changes: 7 additions & 0 deletions TrackletNode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class TrackletNode:
def __init__(self, idx, sfIdx, s3dc, efIdx, e3dc):
self._id = idx + 1
self._sfIdx = sfIdx
self._efIdx = efIdx
self._s3dc = s3dc
self._e3dc = e3dc
30 changes: 30 additions & 0 deletions bbox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import numpy as np

class Box(object):
def __init__(self, tlbr, confidence, transform, imsize):
self.tlbr = np.asarray(tlbr, dtype=np.float)
self.confidence = float(confidence)
self.transform = transform
self.size = imsize

def to_tlwh(self):
tlbr = self.tlbr.copy()
w = tlbr[2]-tlbr[0]
h = tlbr[3]-tlbr[1]
x, y = tlbr[0], tlbr[1]
tlwh = [x,y,w,h]
return tlwh

def box2midpoint_normalised(self, box, iw, ih):
w = box[2]-box[0]
x, y = box[0] + w/2, box[3]
return (x/iw, y/ih)

def to_world(self):
p = self.box2midpoint_normalised(self.tlbr, self.size[1], self.size[0])
cx, cy = self.transform.video_to_ground(p[0], p[1])
cx, cy = cx*self.transform.parameter.get("ground_width"), cy*self.transform.parameter.get("ground_height")
return np.asarray([cx,cy], dtype=np.float)



Loading