Browse Source

Make database.capacity writable

customisations
alemart 1 year ago
parent
commit
5708fb983c

+ 3
- 1
docs/api/reference-image-database.md View File

12
 
12
 
13
 ### capacity
13
 ### capacity
14
 
14
 
15
-`database.capacity: number, read-only`
15
+`database.capacity: number`
16
 
16
 
17
 The maximum number of reference images that can be stored in this database.
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
 ## Methods
21
 ## Methods
20
 
22
 
21
 ### add
23
 ### add

+ 6
- 4
src/trackers/image-tracker/reference-image-database.ts View File

27
 import { IllegalArgumentError, IllegalOperationError } from '../../utils/errors';
27
 import { IllegalArgumentError, IllegalOperationError } from '../../utils/errors';
28
 
28
 
29
 /** Default capacity of a Reference Image Database */
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
 /** Generate a unique name for a reference image */
35
 /** Generate a unique name for a reference image */
33
 const generateUniqueName = () => 'target-' + Math.random().toString(16).substr(2);
36
 const generateUniqueName = () => 'target-' + Math.random().toString(16).substr(2);
88
 
91
 
89
     /**
92
     /**
90
      * Maximum number of elements
93
      * Maximum number of elements
94
+     * Increasing the capacity is considered experimental
91
      */
95
      */
92
-    /*
93
     set capacity(value: number)
96
     set capacity(value: number)
94
     {
97
     {
95
         const capacity = Math.max(0, value | 0);
98
         const capacity = Math.max(0, value | 0);
96
 
99
 
97
         if(this.count > capacity)
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
         this._capacity = capacity;
103
         this._capacity = capacity;
101
     }
104
     }
102
-    */
103
 
105
 
104
     /**
106
     /**
105
      * Iterates over the collection
107
      * Iterates over the collection

Loading…
Cancel
Save