|
@@ -57,6 +57,7 @@ import {
|
57
|
57
|
SUBPIXEL_GAUSSIAN_KSIZE, SUBPIXEL_GAUSSIAN_SIGMA,
|
58
|
58
|
TRACK_HARRIS_QUALITY, TRACK_DETECTOR_CAPACITY, TRACK_MAX_KEYPOINTS,
|
59
|
59
|
TRACK_RANSAC_REPROJECTIONERROR_NDC, TRACK_MATCH_RATIO,
|
|
60
|
+ TRACK_FILTER_ALPHA, TRACK_FILTER_BETA, TRACK_FILTER_TAU,
|
60
|
61
|
NIGHTVISION_QUALITY, SUBPIXEL_METHOD,
|
61
|
62
|
} from '../settings';
|
62
|
63
|
import { Settings } from '../../../core/settings';
|
|
@@ -298,17 +299,12 @@ export class ImageTrackerTrackingState extends ImageTrackerState
|
298
|
299
|
if(pairs.length < TRACK_MIN_MATCHES)
|
299
|
300
|
throw new TrackingError('Not enough data points to continue the tracking');
|
300
|
301
|
|
301
|
|
- // find motion models
|
|
302
|
+ // find motion model
|
302
|
303
|
const points = ImageTrackerUtils.compilePairsOfKeypointsNDC(pairs);
|
303
|
|
- return Speedy.Promise.all<SpeedyMatrixExpr>([
|
304
|
|
- //this._findAffineMotionNDC(points),
|
305
|
|
- //this._findPerspectiveMotionNDC(points),
|
306
|
|
- this._find6DoFPerspectiveMotionNDC(points),
|
307
|
|
- Speedy.Promise.resolve(NO_MOTION),
|
308
|
|
- ]);
|
|
304
|
+ return this._find6DoFPerspectiveMotionNDC(points);
|
309
|
305
|
|
310
|
306
|
})
|
311
|
|
- .then(([warpMotion, poseMotion]) => {
|
|
307
|
+ .then(warpMotion => {
|
312
|
308
|
|
313
|
309
|
const lowPower = (Settings.powerPreference == 'low-power');
|
314
|
310
|
const delay = NUMBER_OF_PBOS * (!lowPower ? 2 : 1);
|
|
@@ -317,15 +313,26 @@ export class ImageTrackerTrackingState extends ImageTrackerState
|
317
|
313
|
if(!USE_TURBO || this._counter % delay == 1) // skip the first frame (PBOs)
|
318
|
314
|
this._warpHomography.setToSync(warpMotion.times(this._warpHomography));
|
319
|
315
|
|
|
316
|
+ // update counter
|
|
317
|
+ this._counter = (this._counter + 1) % delay;
|
|
318
|
+
|
|
319
|
+ // apply filter
|
|
320
|
+ return ImageTrackerUtils.interpolateHomographies(
|
|
321
|
+ this._poseHomography,
|
|
322
|
+ Speedy.Matrix(warpMotion.times(this._warpHomography)),
|
|
323
|
+ TRACK_FILTER_ALPHA,
|
|
324
|
+ TRACK_FILTER_BETA,
|
|
325
|
+ TRACK_FILTER_TAU
|
|
326
|
+ );
|
|
327
|
+
|
|
328
|
+ })
|
|
329
|
+ .then(filteredHomography => {
|
|
330
|
+
|
320
|
331
|
// update pose homography
|
321
|
|
- //poseMotion = warpMotion; // commented: reduce jitter, increase delay
|
322
|
|
- this._poseHomography.setToSync(poseMotion.times(this._warpHomography));
|
|
332
|
+ this._poseHomography.setToSync(filteredHomography);
|
323
|
333
|
if(Number.isNaN(this._poseHomography.at(0,0)))
|
324
|
334
|
throw new NumericalError('Bad homography'); // normalize? 1 / h33
|
325
|
335
|
|
326
|
|
- // update counter
|
327
|
|
- this._counter = (this._counter + 1) % delay;
|
328
|
|
-
|
329
|
336
|
/*
|
330
|
337
|
// test
|
331
|
338
|
console.log("POSE ", this._poseHomography.toString());
|
|
@@ -344,6 +351,7 @@ export class ImageTrackerTrackingState extends ImageTrackerState
|
344
|
351
|
|
345
|
352
|
// update camera model
|
346
|
353
|
return this._camera.update(homography);
|
|
354
|
+
|
347
|
355
|
})
|
348
|
356
|
.then(() => {
|
349
|
357
|
|