Sfoglia il codice sorgente

Image Tracker: introduce spaces NIS, NDC

customisations
alemart 10 mesi fa
parent
commit
b0690ad5b7

+ 40
- 6
src/trackers/image-tracker/image-tracker.ts Vedi File

@@ -58,12 +58,26 @@ import { Pose } from '../../geometry/pose';
58 58
 A few definitions:
59 59
 
60 60
 1. Viewport size:
61
-    size of the drawing buffer of the background canvas = size of the input
62
-    media, in pixels
61
+   size of the drawing buffer of the background canvas, which is the same as
62
+   the size in pixels of the input media (typically a video).
63 63
 
64 64
 2. AR screen size:
65
-    size for image processing operations, determined by the resolution of the
66
-    tracker and by the aspect ratio of the input media
65
+   size in pixels used for image processing operations. It's determined by the
66
+   resolution of the tracker and by the aspect ratio of the input media.
67
+
68
+3. Raster space:
69
+   an image space whose top-left coordinate is (0,0) and whose bottom-right
70
+   coordinate is (w-1,h-1), where (w,h) is its size. The y-axis grows downwards.
71
+
72
+4. AR Screen Space (ASS):
73
+   a raster space whose size is the AR screen size.
74
+
75
+5. Normalized Image Space (NIS):
76
+   a raster space whose size is N x N, where N = NIS_SIZE.
77
+
78
+6. Normalized Device Coordinates (NDC):
79
+   the normalized 2D space [-1,1]x[-1,1]. The origin is at the center. Also,
80
+   the y-axis grows upwards.
67 81
 
68 82
 */
69 83
 
@@ -102,9 +116,15 @@ export interface ImageTrackerOutput extends TrackerOutput
102 116
     /** optional keypoints */
103 117
     readonly keypoints?: SpeedyKeypoint[];
104 118
 
119
+    /** optional keypoints */
120
+    readonly keypointsNIS?: SpeedyKeypoint[];
121
+
105 122
     /** optional polyline for testing */
106 123
     readonly polyline?: SpeedyPoint2[];
107 124
 
125
+    /** optional polyline for testing */
126
+    readonly polylineNDC?: SpeedyPoint2[];
127
+
108 128
     /** optional 3x4 camera matrix in AR screen space */
109 129
     readonly cameraMatrix?: SpeedyMatrix;
110 130
 
@@ -311,8 +331,7 @@ export class ImageTracker extends AREventTarget<ImageTrackerEventType> implement
311 331
         // compute the screen size for image processing purposes
312 332
         // note: this may change over time...!
313 333
         const media = this._source!._internalMedia;
314
-        const aspectRatio = media.width / media.height;
315
-        const screenSize = Utils.resolution(this._resolution, aspectRatio);
334
+        const screenSize = this._computeScreenSize();
316 335
 
317 336
         // run the active state
318 337
         const activeState = this._state[this._activeStateName];
@@ -330,6 +349,21 @@ export class ImageTracker extends AREventTarget<ImageTrackerEventType> implement
330 349
     }
331 350
 
332 351
     /**
352
+     * Compute the current size of the AR screen space
353
+     * Note that this may change over time
354
+     * @returns size
355
+     * @internal
356
+     */
357
+    _computeScreenSize(): SpeedySize
358
+    {
359
+        const media = this._source!._internalMedia;
360
+        const aspectRatio = media.width / media.height;
361
+        const screenSize = Utils.resolution(this._resolution, aspectRatio);
362
+
363
+        return screenSize;
364
+    }
365
+
366
+    /**
333 367
      * Get reference image
334 368
      * @param keypointIndex -1 if not found
335 369
      * @returns reference image

+ 19
- 2
src/trackers/image-tracker/settings.ts Vedi File

@@ -29,8 +29,11 @@ export const TRAIN_MAX_KEYPOINTS = 1024; //512;
29 29
 /** Percentage relative to the screen size adjusted to the aspect ratio of the reference image */
30 30
 export const TRAIN_IMAGE_SCALE = 0.8; // ORB is not scale invariant
31 31
 
32
+/** Width and height of the Normalized Image Space (NIS) */
33
+export const NIS_SIZE = 1024; // keypoint positions are stored as fixed point
34
+
32 35
 /** Normalized width & height of an image target, in pixels */
33
-export const TRAIN_TARGET_NORMALIZED_SIZE = 1024; // keypoint positions are stored as fixed point
36
+export const TRAIN_TARGET_NORMALIZED_SIZE = NIS_SIZE; // keypoint positions are stored as fixed point
34 37
 
35 38
 /** Used to identify the best maches */
36 39
 export const SCAN_MATCH_RATIO = 0.7; // usually a value in [0.6, 0.8]
@@ -54,7 +57,13 @@ export const SCAN_MIN_MATCHES = 20; //30;
54 57
 export const SCAN_CONSECUTIVE_FRAMES = 30;//15;//45;
55 58
 
56 59
 /** Reprojection error, in pixels, used when estimating a motion model (scanning state) */
57
-export const SCAN_RANSAC_REPROJECTIONERROR = 5;
60
+//export const SCAN_RANSAC_REPROJECTIONERROR = 5;
61
+
62
+/** Reprojection error, in NIS pixels, used when estimating a motion model (scanning state) */
63
+export const SCAN_RANSAC_REPROJECTIONERROR_NIS = (NIS_SIZE * 0.02) | 0;
64
+
65
+/** Reprojection error, in NDC, used when estimating a motion model (scanning state) */
66
+export const SCAN_RANSAC_REPROJECTIONERROR_NDC = SCAN_RANSAC_REPROJECTIONERROR_NIS / (NIS_SIZE / 2);
58 67
 
59 68
 /** Number of tables used in the LSH-based keypoint matching */
60 69
 export const SCAN_LSH_TABLES = 8; // up to 32
@@ -119,6 +128,14 @@ export const TRACK_REFINEMENT_ITERATIONS = 3;
119 128
 /** Reprojection error, in pixels, used when estimating a motion model (tracking state) */
120 129
 export const TRACK_RANSAC_REPROJECTIONERROR = 3; //2.5;
121 130
 
131
+// FIXME
132
+
133
+/** Reprojection error, in NIS pixels, used when estimating a motion model (tracking state) */
134
+export const TRACK_RANSAC_REPROJECTIONERROR_NIS = (NIS_SIZE * 0.0125) | 0;
135
+
136
+/** Reprojection error, in NDC, used when estimating a motion model (tracking state) */
137
+export const TRACK_RANSAC_REPROJECTIONERROR_NDC = TRACK_RANSAC_REPROJECTIONERROR_NIS / (NIS_SIZE / 2);
138
+
122 139
 /** We use a N x N grid to spatially distribute the keypoints in order to compute a better homography */
123 140
 export const TRACK_GRID_GRANULARITY = 10; //20; // the value of N
124 141
 

Loading…
Annulla
Salva