Explorar el Código

Tune the algorithm to increase the stability of the tracking

customisations
alemart hace 5 meses
padre
commit
04fb86b3ea

+ 1
- 0
src/geometry/pnp.ts Ver fichero

@@ -902,6 +902,7 @@ export function solvePlanarPnPRansac(referencePoints: SpeedyMatrix, observedPoin
902 902
         // We're just using n = 4. We'll refine the homography later.
903 903
         const newPose = pose;
904 904
         const newError = error;
905
+        //const newError = n - count;
905 906
 
906 907
         // Not the best model? Discard it
907 908
         if(newError > bestError)

+ 12
- 3
src/trackers/image-tracker/settings.ts Ver fichero

@@ -129,16 +129,25 @@ export const TRACK_CLIPPING_BORDER = TRACK_RECTIFIED_BORDER * 1.20; //1.25; //1.
129 129
 export const TRACK_RECTIFIED_SCALE = 1 - 2 * TRACK_RECTIFIED_BORDER;
130 130
 
131 131
 /** Reprojection error, in NIS pixels, used when estimating a motion model (tracking state) */
132
-export const TRACK_RANSAC_REPROJECTIONERROR_NIS = (NIS_SIZE * 0.0125) | 0;
132
+export const TRACK_RANSAC_REPROJECTIONERROR_NIS = (NIS_SIZE * 0.0125 * 0.5) | 0;
133 133
 
134 134
 /** Reprojection error, in NDC, used when estimating a motion model (tracking state) */
135 135
 export const TRACK_RANSAC_REPROJECTIONERROR_NDC = TRACK_RANSAC_REPROJECTIONERROR_NIS / (NIS_SIZE / 2);
136 136
 
137 137
 /** We use a N x N grid to spatially distribute the keypoints in order to compute a better homography */
138
-export const TRACK_GRID_GRANULARITY = 10; //20; // the value of N
138
+export const TRACK_GRID_GRANULARITY = 15; //20; //10; // the value of N
139 139
 
140 140
 /** Used to identify the best maches */
141 141
 export const TRACK_MATCH_RATIO = 0.7; // usually a value in [0.6, 0.8] - low values => strict tracking
142 142
 
143 143
 /** Number of consecutive frames in which we tolerate a  "target lost" situation */
144
-export const TRACK_LOST_TOLERANCE = 15;
144
+export const TRACK_LOST_TOLERANCE = 15;
145
+
146
+/** Interpolation filter: interpolation factor */
147
+export const TRACK_FILTER_ALPHA = 0.125;
148
+
149
+/** Interpolation filter: correction strength for noisy corners */
150
+export const TRACK_FILTER_BETA = 1;
151
+
152
+/** Interpolation filter: translation factor */
153
+export const TRACK_FILTER_TAU = 0.25;

+ 21
- 13
src/trackers/image-tracker/states/tracking.ts Ver fichero

@@ -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
 

Loading…
Cancelar
Guardar