Skip to content

Commit eb648cf

Browse files
author
Tim Sheerman-Chase
committed
Retain trackers in gui demo
1 parent 8444f59 commit eb648cf

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

examplegui.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def Process(self, toWorker,fromWorker):
136136
currentFrame = None
137137
tc = klt.KLT_TrackingContext()
138138
tc.sequentialMode = True
139-
tc.min_determinant = 0.
139+
tc.retainTrackers = True
140140
fl = []
141141
prevImg = None
142142

@@ -162,7 +162,8 @@ def Process(self, toWorker,fromWorker):
162162
fl = selectGoodFeatures.KLTSelectGoodFeatures(tc, currentFrame, nFeatures)
163163
else:
164164
trackFeatures.KLTTrackFeatures(tc, prevImg, currentFrame, fl)
165-
#print fl
165+
for feat in fl:
166+
print feat.val
166167
fromWorker.put(("TRACKING",fl))
167168
prevImg = currentFrame
168169
currentFrame = None

klt.py

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def __init__(self):
4444
self.window_width = 7
4545
self.window_height = 7
4646
self.sequentialMode = False
47+
self.retainTrackers = False
4748
self.smoothBeforeSelecting = True
4849
self.writeInternalImages = False
4950
self.lighting_insensitive = False

trackFeatures.py

+4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ def _trackFeature(
123123
if np.abs(np.array(imgdiff)).sum()/(width*height) > max_residue:
124124
status = kltState.KLT_LARGE_RESIDUE
125125

126+
if tc.retainTrackers:
127+
# Try to continue and don't remo
128+
return kltState.KLT_TRACKED, x2, y2
129+
126130
# Return appropriate value
127131
if status == kltState.KLT_SMALL_DET: return kltState.KLT_SMALL_DET, x2, y2
128132
elif status == kltState.KLT_OOB: return kltState.KLT_OOB, x2, y2

trackFeaturesUtils.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,8 @@ def trackFeatureIterateCKLT(float x2,
447447

448448
# Using matrices, solve equation for new displacement */
449449
status = _solveEquation(gradientMatrix, errorMatrix, small, predictedMotion)
450-
if status == kltState.KLT_SMALL_DET: break
450+
if status == kltState.KLT_SMALL_DET:
451+
break
451452

452453
x2 += predictedMotion[0]
453454
y2 += predictedMotion[1]

0 commit comments

Comments
 (0)