Pārlūkot izejas kodu

Tune the pre-tracking stage

customisations
alemart 5 mēnešus atpakaļ
vecāks
revīzija
b9ca91131b

+ 12
- 3
src/trackers/image-tracker/settings.ts Parādīt failu

95
 /** Minimum acceptable number of matched keypoints when in a pre-tracking state */
95
 /** Minimum acceptable number of matched keypoints when in a pre-tracking state */
96
 export const PRE_TRACK_MIN_MATCHES = 4;
96
 export const PRE_TRACK_MIN_MATCHES = 4;
97
 
97
 
98
-/** Maximum number of iterations in Pre-tracking B */
99
-export const PRE_TRACK_MAX_ITERATIONS = 3;
98
+/** Used to identify the best maches */
99
+export const PRE_TRACK_MATCH_RATIO = 0.6; // usually a value in [0.6, 0.8] - low values => strict tracking
100
 
100
 
101
 /** Reprojection error, in NIS pixels, used when pre-tracking */
101
 /** Reprojection error, in NIS pixels, used when pre-tracking */
102
 export const PRE_TRACK_RANSAC_REPROJECTIONERROR_NIS = (NIS_SIZE * 0.0125 * 0.5) | 0;
102
 export const PRE_TRACK_RANSAC_REPROJECTIONERROR_NIS = (NIS_SIZE * 0.0125 * 0.5) | 0;
104
 /** Reprojection error, in NDC, used when pre-tracking */
104
 /** Reprojection error, in NDC, used when pre-tracking */
105
 export const PRE_TRACK_RANSAC_REPROJECTIONERROR_NDC = PRE_TRACK_RANSAC_REPROJECTIONERROR_NIS / (NIS_SIZE / 2);
105
 export const PRE_TRACK_RANSAC_REPROJECTIONERROR_NDC = PRE_TRACK_RANSAC_REPROJECTIONERROR_NIS / (NIS_SIZE / 2);
106
 
106
 
107
+/** Interpolation filter: interpolation factor */
108
+export const PRE_TRACK_FILTER_ALPHA = 0.8;
109
+
110
+/** Interpolation filter: correction strength for noisy corners */
111
+export const PRE_TRACK_FILTER_BETA = 1;
112
+
113
+/** Maximum number of iterations in Pre-tracking B */
114
+export const PRE_TRACK_MAX_ITERATIONS = 6; // the less the interpolation factor, the more iterations are needed
115
+
107
 /** Minimum acceptable number of matched keypoints when in the tracking state */
116
 /** Minimum acceptable number of matched keypoints when in the tracking state */
108
 export const TRACK_MIN_MATCHES = 4;//10; //20;
117
 export const TRACK_MIN_MATCHES = 4;//10; //20;
109
 
118
 
153
 export const TRACK_FILTER_TAU = 0.2;
162
 export const TRACK_FILTER_TAU = 0.2;
154
 
163
 
155
 /** Interpolation filter: rotational factor */
164
 /** Interpolation filter: rotational factor */
156
-export const TRACK_FILTER_OMEGA = 0.05; // keep it close to zero
165
+export const TRACK_FILTER_OMEGA = 0.05; // keep it zero or close to zero

+ 23
- 4
src/trackers/image-tracker/states/pre-tracking-b.ts Parādīt failu

50
     TRACK_HARRIS_QUALITY, TRACK_DETECTOR_CAPACITY, TRACK_MAX_KEYPOINTS,
50
     TRACK_HARRIS_QUALITY, TRACK_DETECTOR_CAPACITY, TRACK_MAX_KEYPOINTS,
51
     SUBPIXEL_GAUSSIAN_KSIZE, SUBPIXEL_GAUSSIAN_SIGMA,
51
     SUBPIXEL_GAUSSIAN_KSIZE, SUBPIXEL_GAUSSIAN_SIGMA,
52
     PRE_TRACK_MIN_MATCHES, PRE_TRACK_MAX_ITERATIONS,
52
     PRE_TRACK_MIN_MATCHES, PRE_TRACK_MAX_ITERATIONS,
53
-    TRACK_MATCH_RATIO, PRE_TRACK_RANSAC_REPROJECTIONERROR_NDC,
53
+    PRE_TRACK_MATCH_RATIO, PRE_TRACK_RANSAC_REPROJECTIONERROR_NDC,
54
+    PRE_TRACK_FILTER_ALPHA, PRE_TRACK_FILTER_BETA,
54
     NIGHTVISION_QUALITY,
55
     NIGHTVISION_QUALITY,
55
     SUBPIXEL_METHOD,
56
     SUBPIXEL_METHOD,
56
 } from '../settings';
57
 } from '../settings';
216
             sourceBuffer.frozen = true;
217
             sourceBuffer.frozen = true;
217
 
218
 
218
             // refine the homography
219
             // refine the homography
219
-            return this._homography.setTo(warp.times(this._homography));
220
+            //return this._homography.setTo(warp.times(this._homography));
221
+
222
+            // apply filter
223
+            return ImageTrackerUtils.interpolateHomographies(
224
+                this._homography,
225
+                Speedy.Matrix(warp.times(this._homography)),
226
+                PRE_TRACK_FILTER_ALPHA,
227
+                PRE_TRACK_FILTER_BETA
228
+            );
229
+
230
+        })
231
+        .then(filteredHomography => {
232
+
233
+            // test: count the number of iterations needed
234
+            // for stabilization with this setup of the filter
235
+            //console.log(this._iterations);
236
+
237
+            // refine the homography
238
+            return this._homography.setTo(filteredHomography);
220
 
239
 
221
         })
240
         })
222
         .then(_ => ({
241
         .then(_ => ({
252
         return ImageTrackerUtils.findPerspectiveWarpNDC(points, {
271
         return ImageTrackerUtils.findPerspectiveWarpNDC(points, {
253
             method: 'pransac',
272
             method: 'pransac',
254
             reprojectionError: PRE_TRACK_RANSAC_REPROJECTIONERROR_NDC,
273
             reprojectionError: PRE_TRACK_RANSAC_REPROJECTIONERROR_NDC,
255
-            numberOfHypotheses: 512*8, // we want a really good homography
274
+            numberOfHypotheses: 512,
256
             bundleSize: 128,
275
             bundleSize: 128,
257
             mask: undefined // score is not needed
276
             mask: undefined // score is not needed
258
         }).then(([ warp, score ]) => {
277
         }).then(([ warp, score ]) => {
295
 
314
 
296
                 // the best match should be "much better" than the second best match,
315
                 // the best match should be "much better" than the second best match,
297
                 // which means that they are "distinct enough"
316
                 // which means that they are "distinct enough"
298
-                if(d1 <= TRACK_MATCH_RATIO * d2) {
317
+                if(d1 <= PRE_TRACK_MATCH_RATIO * d2) {
299
                     const srcKeypoint = srcKeypoints[destKeypoint.matches[0].index];
318
                     const srcKeypoint = srcKeypoints[destKeypoint.matches[0].index];
300
                     pairs.push([srcKeypoint, destKeypoint]);
319
                     pairs.push([srcKeypoint, destKeypoint]);
301
                 }
320
                 }

Notiek ielāde…
Atcelt
Saglabāt