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