@hackbuild/vision 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/yolo.js CHANGED
@@ -5,11 +5,13 @@
5
5
  * suppression per class. Written from the published output layout; the
6
6
  * weights are external and AGPL-3.0.
7
7
  */
8
+ /** The 80 COCO class names, in YOLO class index order. */
8
9
  export const COCO_LABELS = ("person,bicycle,car,motorcycle,airplane,bus,train,truck,boat,traffic light,fire hydrant,stop sign,parking meter,bench,bird,cat,dog,horse,sheep,cow," +
9
10
  "elephant,bear,zebra,giraffe,backpack,umbrella,handbag,tie,suitcase,frisbee,skis,snowboard,sports ball,kite,baseball bat,baseball glove,skateboard," +
10
11
  "surfboard,tennis racket,bottle,wine glass,cup,fork,knife,spoon,bowl,banana,apple,sandwich,orange,broccoli,carrot,hot dog,pizza,donut,cake,chair,couch," +
11
12
  "potted plant,bed,dining table,toilet,tv,laptop,mouse,remote,keyboard,cell phone,microwave,oven,toaster,sink,refrigerator,book,clock,vase,scissors," +
12
13
  "teddy bear,hair drier,toothbrush").split(",");
14
+ /** The scale and padding that fit a `w` by `h` image into a `size` square (640 by default), centred. */
13
15
  export function letterboxParams(w, h, size = 640) {
14
16
  const scale = Math.min(size / w, size / h);
15
17
  return { scale, padX: Math.floor((size - Math.round(w * scale)) / 2), padY: Math.floor((size - Math.round(h * scale)) / 2), size };
@@ -34,6 +36,7 @@ export function letterboxTensor(px, size = 640) {
34
36
  }
35
37
  return { data, lb };
36
38
  }
39
+ /** Intersection over union of two boxes, 0 to 1. */
37
40
  export function iou(a, b) {
38
41
  const x1 = Math.max(a.x, b.x);
39
42
  const y1 = Math.max(a.y, b.y);
@@ -107,7 +110,7 @@ export function yoloDetector(m, o = {}) {
107
110
  dispose: () => m.dispose(),
108
111
  };
109
112
  }
110
- /** Detection cadence as earlier builds ran it: wait max(0.45 s, 4 times the last latency) between runs. */
113
+ /** Detection cadence: wait max(0.45 s, 4 times the last latency) between runs. */
111
114
  export function detectCadenceMs(lastLatencyMs) {
112
115
  return Math.max(450, 4 * lastLatencyMs);
113
116
  }