Selaa lähdekoodia

Training state: simplify

customisations
alemart 10 kuukautta sitten
vanhempi
commit
e5d6f6a4c2
1 muutettua tiedostoa jossa 13 lisäystä ja 14 poistoa
  1. 13
    14
      src/trackers/image-tracker/states/training.ts

+ 13
- 14
src/trackers/image-tracker/states/training.ts Näytä tiedosto

@@ -53,14 +53,11 @@ import {
53 53
 /** The training map maps keypoints to reference images */
54 54
 interface TrainingMap
55 55
 {
56
-    /** maps a keypoint index to an image index */
57
-    readonly referenceImageIndex: number[];
58
-
59
-    /** maps an image index to a reference image */
60
-    readonly referenceImage: ReferenceImage[];
61
-
62 56
     /** the collection of all keypoints (of all images) */
63 57
     readonly keypoints: SpeedyKeypoint[];
58
+
59
+    /** maps a keypoint index to an image index */
60
+    readonly referenceImageIndex: number[];
64 61
 }
65 62
 
66 63
 
@@ -70,8 +67,13 @@ interface TrainingMap
70 67
  */
71 68
 export class ImageTrackerTrainingState extends ImageTrackerState
72 69
 {
70
+    /** index of the image being used to train the tracker */
73 71
     private _currentImageIndex = 0;
72
+
73
+    /** reference images */
74 74
     private _image: ReferenceImage[] = [];
75
+
76
+    /** training map */
75 77
     private _trainingMap: TrainingMap;
76 78
 
77 79
 
@@ -86,9 +88,8 @@ export class ImageTrackerTrainingState extends ImageTrackerState
86 88
 
87 89
         // initialize the training map
88 90
         this._trainingMap = {
89
-            referenceImageIndex: [],
90
-            referenceImage: [],
91
-            keypoints: []
91
+            keypoints: [],
92
+            referenceImageIndex: []
92 93
         };
93 94
     }
94 95
 
@@ -108,7 +109,6 @@ export class ImageTrackerTrainingState extends ImageTrackerState
108 109
         this._currentImageIndex = 0;
109 110
         this._image.length = 0;
110 111
         this._trainingMap.referenceImageIndex.length = 0;
111
-        this._trainingMap.referenceImage.length = 0;
112 112
         this._trainingMap.keypoints.length = 0;
113 113
 
114 114
         // lock the database
@@ -209,7 +209,6 @@ export class ImageTrackerTrainingState extends ImageTrackerState
209 209
         Utils.log(`Image Tracker: found ${keypoints.length} keypoints in reference image "${referenceImage.name}"`);
210 210
 
211 211
         // set the training map, so that we can map all keypoints of the current image to the current image
212
-        this._trainingMap.referenceImage.push(referenceImage);
213 212
         for(let i = 0; i < keypoints.length; i++) {
214 213
             this._trainingMap.keypoints.push(keypoints[i]);
215 214
             this._trainingMap.referenceImageIndex.push(this._currentImageIndex);
@@ -313,7 +312,7 @@ export class ImageTrackerTrainingState extends ImageTrackerState
313 312
         // keypoint description
314 313
         greyscale.output().connectTo(blur.input());
315 314
         blur.output().connectTo(descriptor.input('image'));
316
-        clipper.output().connectTo(descriptor.input('keypoints'));
315
+        subpixel.output().connectTo(descriptor.input('keypoints'));
317 316
 
318 317
         // prepare output
319 318
         descriptor.output().connectTo(keypointScaler.input());
@@ -343,7 +342,7 @@ export class ImageTrackerTrainingState extends ImageTrackerState
343 342
         if(imageIndex < 0)
344 343
             return null;
345 344
 
346
-        return this._trainingMap.referenceImage[imageIndex];
345
+        return this._image[imageIndex];
347 346
     }
348 347
 
349 348
     /**
@@ -358,7 +357,7 @@ export class ImageTrackerTrainingState extends ImageTrackerState
358 357
             return -1;
359 358
 
360 359
         const imageIndex = this._trainingMap.referenceImageIndex[keypointIndex];
361
-        if(imageIndex < 0 || imageIndex >= this._trainingMap.referenceImage.length)
360
+        if(imageIndex < 0 || imageIndex >= this._image.length)
362 361
             return -1;
363 362
 
364 363
         return imageIndex;

Loading…
Peruuta
Tallenna