瀏覽代碼

Tweaks

customisations
alemart 5 月之前
父節點
當前提交
9147b100e5
共有 2 個檔案被更改,包括 15 行新增18 行删除
  1. 1
    7
      src/trackers/image-tracker/settings.ts
  2. 14
    11
      src/trackers/image-tracker/states/tracking.ts

+ 1
- 7
src/trackers/image-tracker/settings.ts 查看文件

158
 /** Interpolation filter: correction strength for noisy corners */
158
 /** Interpolation filter: correction strength for noisy corners */
159
 export const TRACK_FILTER_BETA = 1;
159
 export const TRACK_FILTER_BETA = 1;
160
 
160
 
161
-/** Interpolation filter: translation factor */
162
-export const TRACK_FILTER_TAU = 0;
163
-
164
-/** Interpolation filter: rotational factor */
165
-export const TRACK_FILTER_OMEGA = 0; // keep it zero or close to zero
166
-
167
 /** Extrapolation filter: extrapolation factor */
161
 /** Extrapolation filter: extrapolation factor */
168
-export const TRACK_EXTRAPOLATION_ALPHA = 6;
162
+export const TRACK_EXTRAPOLATION_ALPHA = 6; // 12+ = follows faster, but looks unstable (jitter)
169
 
163
 
170
 /** Extrapolation filter: correction strength for noisy corners */
164
 /** Extrapolation filter: correction strength for noisy corners */
171
 export const TRACK_EXTRAPOLATION_BETA = 1.33;
165
 export const TRACK_EXTRAPOLATION_BETA = 1.33;

+ 14
- 11
src/trackers/image-tracker/states/tracking.ts 查看文件

57
     SUBPIXEL_GAUSSIAN_KSIZE, SUBPIXEL_GAUSSIAN_SIGMA,
57
     SUBPIXEL_GAUSSIAN_KSIZE, SUBPIXEL_GAUSSIAN_SIGMA,
58
     TRACK_HARRIS_QUALITY, TRACK_DETECTOR_CAPACITY, TRACK_MAX_KEYPOINTS,
58
     TRACK_HARRIS_QUALITY, TRACK_DETECTOR_CAPACITY, TRACK_MAX_KEYPOINTS,
59
     TRACK_RANSAC_REPROJECTIONERROR_NDC, TRACK_MATCH_RATIO,
59
     TRACK_RANSAC_REPROJECTIONERROR_NDC, TRACK_MATCH_RATIO,
60
-    TRACK_FILTER_ALPHA, TRACK_FILTER_BETA, TRACK_FILTER_TAU, TRACK_FILTER_OMEGA,
60
+    TRACK_FILTER_ALPHA, TRACK_FILTER_BETA,
61
     TRACK_EXTRAPOLATION_ALPHA, TRACK_EXTRAPOLATION_BETA,
61
     TRACK_EXTRAPOLATION_ALPHA, TRACK_EXTRAPOLATION_BETA,
62
     NIGHTVISION_QUALITY, SUBPIXEL_METHOD,
62
     NIGHTVISION_QUALITY, SUBPIXEL_METHOD,
63
 } from '../settings';
63
 } from '../settings';
90
     /** current homography (for computing the pose) */
90
     /** current homography (for computing the pose) */
91
     private _poseHomography: SpeedyMatrix;
91
     private _poseHomography: SpeedyMatrix;
92
 
92
 
93
-    /* previous homography */
93
+    /* previous warp homography */
94
     private _prevHomography: SpeedyMatrix;
94
     private _prevHomography: SpeedyMatrix;
95
 
95
 
96
     /** initial keypoints (i.e., the keypoints we found when we first started tracking) */
96
     /** initial keypoints (i.e., the keypoints we found when we first started tracking) */
261
 
261
 
262
         // When using turbo, we reduce the GPU usage by skipping every other frame
262
         // When using turbo, we reduce the GPU usage by skipping every other frame
263
         if(0 == (this._skipCounter = 1 - this._skipCounter)) {
263
         if(0 == (this._skipCounter = 1 - this._skipCounter)) {
264
-            const templateKeypoints = this._templateKeypoints;
264
+            //const templateKeypoints = this._templateKeypoints;
265
             const previousKeypoints = this._lastPipelineOutput.keypoints as SpeedyMatchedKeypoint[];
265
             const previousKeypoints = this._lastPipelineOutput.keypoints as SpeedyMatchedKeypoint[];
266
             //const currentKeypoints = this._predictKeypoints(previousKeypoints, templateKeypoints);
266
             //const currentKeypoints = this._predictKeypoints(previousKeypoints, templateKeypoints);
267
             const currentKeypoints = previousKeypoints; // this actually works
267
             const currentKeypoints = previousKeypoints; // this actually works
268
 
268
 
269
-            this._lastPipelineOutput.keypoints = currentKeypoints;
269
+            // idea: predict keypoints with optical flow?
270
 
270
 
271
+            this._lastPipelineOutput.keypoints = currentKeypoints;
271
             return Speedy.Promise.resolve(this._lastPipelineOutput);
272
             return Speedy.Promise.resolve(this._lastPipelineOutput);
272
         }
273
         }
273
 
274
 
312
         })
313
         })
313
         .then(warpMotion => {
314
         .then(warpMotion => {
314
 
315
 
316
+            const lowPower = (Settings.powerPreference == 'low-power');
317
+            const multiplier = /*!USE_TURBO ||*/ lowPower ? 2 : 1;
318
+
315
             // apply filter
319
             // apply filter
316
             return ImageTrackerUtils.interpolateHomographies(
320
             return ImageTrackerUtils.interpolateHomographies(
317
                 NO_MOTION,
321
                 NO_MOTION,
318
                 Speedy.Matrix(warpMotion),
322
                 Speedy.Matrix(warpMotion),
319
-                TRACK_FILTER_ALPHA,
320
-                TRACK_FILTER_BETA,
321
-                TRACK_FILTER_TAU,
322
-                TRACK_FILTER_OMEGA
323
+                TRACK_FILTER_ALPHA * multiplier,
324
+                TRACK_FILTER_BETA
323
             );
325
             );
324
 
326
 
325
         })
327
         })
336
                 this._prevHomography,
338
                 this._prevHomography,
337
                 this._warpHomography,
339
                 this._warpHomography,
338
                 TRACK_EXTRAPOLATION_ALPHA,
340
                 TRACK_EXTRAPOLATION_ALPHA,
339
-                TRACK_EXTRAPOLATION_BETA
340
-            );
341
+                TRACK_EXTRAPOLATION_BETA,
342
+                //2.5,0.1
343
+            )
341
 
344
 
342
             /*
345
             /*
343
             const lowPower = (Settings.powerPreference == 'low-power');
346
             const lowPower = (Settings.powerPreference == 'low-power');
357
                 0.4,//TRACK_FILTER_ALPHA,
360
                 0.4,//TRACK_FILTER_ALPHA,
358
                 1,//TRACK_FILTER_BETA,
361
                 1,//TRACK_FILTER_BETA,
359
                 0.4,//TRACK_FILTER_TAU,
362
                 0.4,//TRACK_FILTER_TAU,
360
-                0.05,//TRACK_FILTER_OMEGA
363
+                0.05,//TRACK_FILTER_OMEGA // keep it zero or close to zero
361
             );
364
             );
362
             */
365
             */
363
 
366
 

Loading…
取消
儲存