Selaa lähdekoodia

Make database.capacity writable

customisations
alemart 1 vuosi sitten
vanhempi
commit
5708fb983c

+ 3
- 1
docs/api/reference-image-database.md Näytä tiedosto

@@ -12,10 +12,12 @@ The number of reference images stored in this database.
12 12
 
13 13
 ### capacity
14 14
 
15
-`database.capacity: number, read-only`
15
+`database.capacity: number`
16 16
 
17 17
 The maximum number of reference images that can be stored in this database.
18 18
 
19
+*Note:* this property is writable since version 0.2.1 (experimental).
20
+
19 21
 ## Methods
20 22
 
21 23
 ### add

+ 6
- 4
src/trackers/image-tracker/reference-image-database.ts Näytä tiedosto

@@ -27,7 +27,10 @@ import { ReferenceImage } from './reference-image';
27 27
 import { IllegalArgumentError, IllegalOperationError } from '../../utils/errors';
28 28
 
29 29
 /** Default capacity of a Reference Image Database */
30
-const DEFAULT_CAPACITY = 100;
30
+const DEFAULT_CAPACITY = 100; // this number should exceed normal usage
31
+                              // XXX this number may be changed (is 100 too conservative?)
32
+                              // further testing is needed to verify the appropriateness of this number;
33
+                              // it depends on the images, on the keypoint descriptors, and even on the target devices
31 34
 
32 35
 /** Generate a unique name for a reference image */
33 36
 const generateUniqueName = () => 'target-' + Math.random().toString(16).substr(2);
@@ -88,18 +91,17 @@ export class ReferenceImageDatabase implements Iterable<ReferenceImage>
88 91
 
89 92
     /**
90 93
      * Maximum number of elements
94
+     * Increasing the capacity is considered experimental
91 95
      */
92
-    /*
93 96
     set capacity(value: number)
94 97
     {
95 98
         const capacity = Math.max(0, value | 0);
96 99
 
97 100
         if(this.count > capacity)
98
-            throw new IllegalArgumentError(`Can't set the capacity of the database to ${this._capacity}: it currently stores ${this.count} entries`);
101
+            throw new IllegalArgumentError(`Can't set the capacity of the database to ${capacity}: it currently stores ${this.count} entries`);
99 102
 
100 103
         this._capacity = capacity;
101 104
     }
102
-    */
103 105
 
104 106
     /**
105 107
      * Iterates over the collection

Loading…
Peruuta
Tallenna