supervision 0.1.3 → 0.1.5

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.
Files changed (121) hide show
  1. package/dist/index.d.ts +16 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1587 -177
  4. package/dist/index.js.map +1 -1
  5. package/dist/mask-preparation.worker.js +110 -68
  6. package/dist/mask-preparation.worker.js.map +1 -1
  7. package/dist/post-processing/default-tracking-worker.d.ts +3 -0
  8. package/dist/post-processing/default-tracking-worker.d.ts.map +1 -0
  9. package/dist/post-processing/detection-post-processing-pipeline.d.ts +7 -0
  10. package/dist/post-processing/detection-post-processing-pipeline.d.ts.map +1 -0
  11. package/dist/post-processing/embedded-tracking-worker.d.ts +2 -0
  12. package/dist/post-processing/embedded-tracking-worker.d.ts.map +1 -0
  13. package/dist/post-processing/tracking-worker-protocol.d.ts +29 -0
  14. package/dist/post-processing/tracking-worker-protocol.d.ts.map +1 -0
  15. package/dist/post-processing/tracking.worker.d.ts +2 -0
  16. package/dist/post-processing/tracking.worker.d.ts.map +1 -0
  17. package/dist/render-preparation/mask-frame-artifact.d.ts +6 -0
  18. package/dist/render-preparation/mask-frame-artifact.d.ts.map +1 -1
  19. package/dist/render-preparation/mask-frame-compositor.d.ts +1 -0
  20. package/dist/render-preparation/mask-frame-compositor.d.ts.map +1 -1
  21. package/dist/render-preparation/mask-frame-preparer.d.ts.map +1 -1
  22. package/dist/render-preparation/mask-preparation-worker-protocol.d.ts +1 -0
  23. package/dist/render-preparation/mask-preparation-worker-protocol.d.ts.map +1 -1
  24. package/dist/renderers/annotation-shape-styles.d.ts +17 -0
  25. package/dist/renderers/annotation-shape-styles.d.ts.map +1 -0
  26. package/dist/renderers/media-renderer-core.d.ts.map +1 -1
  27. package/dist/renderers/media-renderer-scene.d.ts +17 -2
  28. package/dist/renderers/media-renderer-scene.d.ts.map +1 -1
  29. package/dist/renderers/pixi-annotation-overlay-layer.d.ts.map +1 -1
  30. package/dist/renderers/pixi-focus-layer.d.ts +1 -0
  31. package/dist/renderers/pixi-focus-layer.d.ts.map +1 -1
  32. package/dist/renderers/pixi-interaction-layer.d.ts +2 -0
  33. package/dist/renderers/pixi-interaction-layer.d.ts.map +1 -1
  34. package/dist/renderers/pixi-interaction-presentation-layer.d.ts +2 -1
  35. package/dist/renderers/pixi-interaction-presentation-layer.d.ts.map +1 -1
  36. package/dist/renderers/pixi-mask-halo.d.ts +94 -0
  37. package/dist/renderers/pixi-mask-halo.d.ts.map +1 -0
  38. package/dist/renderers/pixi-mask-layer.d.ts +10 -1
  39. package/dist/renderers/pixi-mask-layer.d.ts.map +1 -1
  40. package/dist/renderers/pixi-media-scene.d.ts.map +1 -1
  41. package/dist/renderers/pixi-path.d.ts +13 -7
  42. package/dist/renderers/pixi-path.d.ts.map +1 -1
  43. package/dist/renderers/pixi-polygon-layer.d.ts.map +1 -1
  44. package/dist/renderers/pixi-region-layer.d.ts +42 -0
  45. package/dist/renderers/pixi-region-layer.d.ts.map +1 -0
  46. package/dist/renderers/pixi-scene-layer-slot.d.ts +1 -0
  47. package/dist/renderers/pixi-scene-layer-slot.d.ts.map +1 -1
  48. package/dist/renderers/pixi-vector-layer.d.ts +3 -1
  49. package/dist/renderers/pixi-vector-layer.d.ts.map +1 -1
  50. package/dist/sessions/media-session.d.ts.map +1 -1
  51. package/dist/tracking.worker.js +1485 -0
  52. package/dist/tracking.worker.js.map +1 -0
  53. package/dist/types/detection-post-processing.d.ts +62 -0
  54. package/dist/types/detection-post-processing.d.ts.map +1 -0
  55. package/dist/types/media-renderer.d.ts +1 -1
  56. package/dist/types/media-renderer.d.ts.map +1 -1
  57. package/dist/workers/worker-rpc-client.d.ts +2 -1
  58. package/dist/workers/worker-rpc-client.d.ts.map +1 -1
  59. package/node_modules/supervision-js-core/dist/index.d.ts +23 -3
  60. package/node_modules/supervision-js-core/dist/index.d.ts.map +1 -1
  61. package/node_modules/supervision-js-core/dist/index.js +2545 -566
  62. package/node_modules/supervision-js-core/dist/index.js.map +1 -1
  63. package/node_modules/supervision-js-core/dist/interactions/detection-picker.d.ts +18 -0
  64. package/node_modules/supervision-js-core/dist/interactions/detection-picker.d.ts.map +1 -1
  65. package/node_modules/supervision-js-core/dist/post-processing/byte-track-tracker.d.ts +4 -0
  66. package/node_modules/supervision-js-core/dist/post-processing/byte-track-tracker.d.ts.map +1 -0
  67. package/node_modules/supervision-js-core/dist/post-processing/cbiou-tracker.d.ts +4 -0
  68. package/node_modules/supervision-js-core/dist/post-processing/cbiou-tracker.d.ts.map +1 -0
  69. package/node_modules/supervision-js-core/dist/post-processing/oc-sort-tracker.d.ts +4 -0
  70. package/node_modules/supervision-js-core/dist/post-processing/oc-sort-tracker.d.ts.map +1 -0
  71. package/node_modules/supervision-js-core/dist/post-processing/sort-tracker.d.ts +4 -0
  72. package/node_modules/supervision-js-core/dist/post-processing/sort-tracker.d.ts.map +1 -0
  73. package/node_modules/supervision-js-core/dist/post-processing/tracking.d.ts +9 -0
  74. package/node_modules/supervision-js-core/dist/post-processing/tracking.d.ts.map +1 -0
  75. package/node_modules/supervision-js-core/dist/styles/annotation-renderer-presentation.d.ts.map +1 -1
  76. package/node_modules/supervision-js-core/dist/styles/annotation-renderer-registry.d.ts +13 -6
  77. package/node_modules/supervision-js-core/dist/styles/annotation-renderer-registry.d.ts.map +1 -1
  78. package/node_modules/supervision-js-core/dist/styles/box-corner-style.d.ts +14 -0
  79. package/node_modules/supervision-js-core/dist/styles/box-corner-style.d.ts.map +1 -0
  80. package/node_modules/supervision-js-core/dist/styles/box-style.d.ts.map +1 -1
  81. package/node_modules/supervision-js-core/dist/styles/default-annotation-presentation.d.ts +19 -0
  82. package/node_modules/supervision-js-core/dist/styles/default-annotation-presentation.d.ts.map +1 -1
  83. package/node_modules/supervision-js-core/dist/styles/interaction-style.d.ts.map +1 -1
  84. package/node_modules/supervision-js-core/dist/styles/keypoint-style.d.ts.map +1 -1
  85. package/node_modules/supervision-js-core/dist/styles/marker-style.d.ts +14 -0
  86. package/node_modules/supervision-js-core/dist/styles/marker-style.d.ts.map +1 -0
  87. package/node_modules/supervision-js-core/dist/styles/polygon-style.d.ts.map +1 -1
  88. package/node_modules/supervision-js-core/dist/styles/polyline-style.d.ts.map +1 -1
  89. package/node_modules/supervision-js-core/dist/styles/source-presentation.d.ts +8 -0
  90. package/node_modules/supervision-js-core/dist/styles/source-presentation.d.ts.map +1 -1
  91. package/node_modules/supervision-js-core/dist/styles/stroke-style.d.ts +12 -0
  92. package/node_modules/supervision-js-core/dist/styles/stroke-style.d.ts.map +1 -0
  93. package/node_modules/supervision-js-core/dist/types/annotation-renderer.d.ts +124 -4
  94. package/node_modules/supervision-js-core/dist/types/annotation-renderer.d.ts.map +1 -1
  95. package/node_modules/supervision-js-core/dist/types/box-corner-style.d.ts +31 -0
  96. package/node_modules/supervision-js-core/dist/types/box-corner-style.d.ts.map +1 -0
  97. package/node_modules/supervision-js-core/dist/types/box-style.d.ts +4 -17
  98. package/node_modules/supervision-js-core/dist/types/box-style.d.ts.map +1 -1
  99. package/node_modules/supervision-js-core/dist/types/detections.d.ts +11 -3
  100. package/node_modules/supervision-js-core/dist/types/detections.d.ts.map +1 -1
  101. package/node_modules/supervision-js-core/dist/types/ellipse-style.d.ts +30 -0
  102. package/node_modules/supervision-js-core/dist/types/ellipse-style.d.ts.map +1 -0
  103. package/node_modules/supervision-js-core/dist/types/interaction.d.ts +12 -0
  104. package/node_modules/supervision-js-core/dist/types/interaction.d.ts.map +1 -1
  105. package/node_modules/supervision-js-core/dist/types/marker-style.d.ts +46 -0
  106. package/node_modules/supervision-js-core/dist/types/marker-style.d.ts.map +1 -0
  107. package/node_modules/supervision-js-core/dist/types/mask-halo-style.d.ts +29 -0
  108. package/node_modules/supervision-js-core/dist/types/mask-halo-style.d.ts.map +1 -0
  109. package/node_modules/supervision-js-core/dist/types/media-rendering.d.ts +18 -2
  110. package/node_modules/supervision-js-core/dist/types/media-rendering.d.ts.map +1 -1
  111. package/node_modules/supervision-js-core/dist/types/paint-style.d.ts +36 -0
  112. package/node_modules/supervision-js-core/dist/types/paint-style.d.ts.map +1 -0
  113. package/node_modules/supervision-js-core/dist/types/post-processing.d.ts +148 -0
  114. package/node_modules/supervision-js-core/dist/types/post-processing.d.ts.map +1 -0
  115. package/node_modules/supervision-js-core/dist/types/shape-style.d.ts +112 -0
  116. package/node_modules/supervision-js-core/dist/types/shape-style.d.ts.map +1 -0
  117. package/node_modules/supervision-js-core/dist/utils/detection-frames.d.ts.map +1 -1
  118. package/node_modules/supervision-js-core/dist/utils/shape-geometry.d.ts +50 -0
  119. package/node_modules/supervision-js-core/dist/utils/shape-geometry.d.ts.map +1 -0
  120. package/node_modules/supervision-js-core/package.json +12 -5
  121. package/package.json +7 -2
@@ -138,22 +138,56 @@
138
138
  AnnotationFrameMutationKind["Update"] = "update";
139
139
  })(AnnotationFrameMutationKind || (AnnotationFrameMutationKind = {}));
140
140
 
141
- var DetectionPickTarget;
142
- (function (DetectionPickTarget) {
143
- DetectionPickTarget["Box"] = "box";
144
- DetectionPickTarget["Edge"] = "edge";
145
- DetectionPickTarget["Keypoint"] = "keypoint";
146
- DetectionPickTarget["Label"] = "label";
147
- DetectionPickTarget["Mask"] = "mask";
148
- DetectionPickTarget["Polygon"] = "polygon";
149
- DetectionPickTarget["Polyline"] = "polyline";
150
- })(DetectionPickTarget || (DetectionPickTarget = {}));
151
- var MediaInteractionMode;
152
- (function (MediaInteractionMode) {
153
- MediaInteractionMode["Always"] = "always";
154
- MediaInteractionMode["Disabled"] = "disabled";
155
- MediaInteractionMode["PausedOnly"] = "pausedOnly";
156
- })(MediaInteractionMode || (MediaInteractionMode = {}));
141
+ /** Geometry projected into a tracker. The original detection payload is retained. */
142
+ var TrackingGeometry;
143
+ (function (TrackingGeometry) {
144
+ TrackingGeometry["Box"] = "box";
145
+ TrackingGeometry["Mask"] = "mask";
146
+ TrackingGeometry["Keypoints"] = "keypoints";
147
+ })(TrackingGeometry || (TrackingGeometry = {}));
148
+
149
+ var DetectionMaskPayloadFormat;
150
+ (function (DetectionMaskPayloadFormat) {
151
+ DetectionMaskPayloadFormat["RawCocoRle"] = "rawCocoRle";
152
+ DetectionMaskPayloadFormat["DeflatedBase64"] = "deflatedBase64";
153
+ })(DetectionMaskPayloadFormat || (DetectionMaskPayloadFormat = {}));
154
+ function encodeBinaryMask(data, width, height) {
155
+ assertMaskDimensions(data, width, height);
156
+ const runs = [];
157
+ let currentValue = 0;
158
+ let runLength = 0;
159
+ for (let x = 0; x < width; x += 1) {
160
+ for (let y = 0; y < height; y += 1) {
161
+ const value = data[y * width + x] ? 1 : 0;
162
+ if (value === currentValue) {
163
+ runLength += 1;
164
+ }
165
+ else {
166
+ runs.push(runLength);
167
+ currentValue = value;
168
+ runLength = 1;
169
+ }
170
+ }
171
+ }
172
+ runs.push(runLength);
173
+ return {
174
+ counts: encodeCompressedRleCounts(runs),
175
+ encoding: DetectionMaskEncoding.CompressedRle,
176
+ height,
177
+ width,
178
+ };
179
+ }
180
+ function assertMaskDimensions(data, width, height) {
181
+ if (!Number.isInteger(width) || width <= 0) {
182
+ throw new Error("Mask width must be a positive integer.");
183
+ }
184
+ if (!Number.isInteger(height) || height <= 0) {
185
+ throw new Error("Mask height must be a positive integer.");
186
+ }
187
+ if (data.length !== width * height) {
188
+ throw new Error("Mask data length must equal width * height.");
189
+ }
190
+ }
157
191
 
158
192
  function centerRectToTopLeftRect(rect) {
159
193
  return {
@@ -185,6 +219,23 @@
185
219
  };
186
220
  }
187
221
 
222
+ var DetectionPickTarget;
223
+ (function (DetectionPickTarget) {
224
+ DetectionPickTarget["Box"] = "box";
225
+ DetectionPickTarget["Edge"] = "edge";
226
+ DetectionPickTarget["Keypoint"] = "keypoint";
227
+ DetectionPickTarget["Label"] = "label";
228
+ DetectionPickTarget["Mask"] = "mask";
229
+ DetectionPickTarget["Polygon"] = "polygon";
230
+ DetectionPickTarget["Polyline"] = "polyline";
231
+ })(DetectionPickTarget || (DetectionPickTarget = {}));
232
+ var MediaInteractionMode;
233
+ (function (MediaInteractionMode) {
234
+ MediaInteractionMode["Always"] = "always";
235
+ MediaInteractionMode["Disabled"] = "disabled";
236
+ MediaInteractionMode["PausedOnly"] = "pausedOnly";
237
+ })(MediaInteractionMode || (MediaInteractionMode = {}));
238
+
188
239
  var AnnotationGeometryKind;
189
240
  (function (AnnotationGeometryKind) {
190
241
  AnnotationGeometryKind["Box"] = "box";
@@ -209,17 +260,19 @@
209
260
  AnnotationHandleKind["Keypoint"] = "keypoint";
210
261
  })(AnnotationHandleKind || (AnnotationHandleKind = {}));
211
262
 
263
+ /** Alignment for strokes applied to closed rendered geometry. */
264
+ var StrokeAlignment;
265
+ (function (StrokeAlignment) {
266
+ StrokeAlignment["Inside"] = "inside";
267
+ StrokeAlignment["Center"] = "center";
268
+ StrokeAlignment["Outside"] = "outside";
269
+ })(StrokeAlignment || (StrokeAlignment = {}));
270
+
212
271
  var BoxShape;
213
272
  (function (BoxShape) {
214
273
  BoxShape["Rect"] = "rect";
215
274
  BoxShape["RoundedRect"] = "roundedRect";
216
275
  })(BoxShape || (BoxShape = {}));
217
- var BoxStrokeAlignment;
218
- (function (BoxStrokeAlignment) {
219
- BoxStrokeAlignment["Inside"] = "inside";
220
- BoxStrokeAlignment["Center"] = "center";
221
- BoxStrokeAlignment["Outside"] = "outside";
222
- })(BoxStrokeAlignment || (BoxStrokeAlignment = {}));
223
276
 
224
277
  var FocusTargetMode;
225
278
  (function (FocusTargetMode) {
@@ -256,54 +309,37 @@
256
309
  MaskRenderMode["StrokeOnly"] = "strokeOnly";
257
310
  })(MaskRenderMode || (MaskRenderMode = {}));
258
311
 
312
+ /**
313
+ * Discriminator for renderer-neutral shape draw instructions.
314
+ */
315
+ var ShapeInstructionKind;
316
+ (function (ShapeInstructionKind) {
317
+ ShapeInstructionKind["Ellipse"] = "ellipse";
318
+ ShapeInstructionKind["Marker"] = "marker";
319
+ ShapeInstructionKind["Path"] = "path";
320
+ })(ShapeInstructionKind || (ShapeInstructionKind = {}));
321
+ var MarkerShape;
322
+ (function (MarkerShape) {
323
+ MarkerShape["Circle"] = "circle";
324
+ MarkerShape["Cross"] = "cross";
325
+ MarkerShape["Square"] = "square";
326
+ MarkerShape["Triangle"] = "triangle";
327
+ })(MarkerShape || (MarkerShape = {}));
328
+ /**
329
+ * Coordinate space for marker sizing. Media sizes scale with the viewport;
330
+ * screen sizes stay constant on screen, matching stroke-width semantics.
331
+ */
332
+ var MarkerSizeSpace;
333
+ (function (MarkerSizeSpace) {
334
+ MarkerSizeSpace["Media"] = "media";
335
+ MarkerSizeSpace["Screen"] = "screen";
336
+ })(MarkerSizeSpace || (MarkerSizeSpace = {}));
337
+
259
338
  var KeypointMarkerShape;
260
339
  (function (KeypointMarkerShape) {
261
340
  KeypointMarkerShape["Circle"] = "circle";
262
341
  KeypointMarkerShape["Cross"] = "cross";
263
342
  })(KeypointMarkerShape || (KeypointMarkerShape = {}));
264
-
265
- var DetectionMaskPayloadFormat;
266
- (function (DetectionMaskPayloadFormat) {
267
- DetectionMaskPayloadFormat["RawCocoRle"] = "rawCocoRle";
268
- DetectionMaskPayloadFormat["DeflatedBase64"] = "deflatedBase64";
269
- })(DetectionMaskPayloadFormat || (DetectionMaskPayloadFormat = {}));
270
- function encodeBinaryMask(data, width, height) {
271
- assertMaskDimensions(data, width, height);
272
- const runs = [];
273
- let currentValue = 0;
274
- let runLength = 0;
275
- for (let x = 0; x < width; x += 1) {
276
- for (let y = 0; y < height; y += 1) {
277
- const value = data[y * width + x] ? 1 : 0;
278
- if (value === currentValue) {
279
- runLength += 1;
280
- }
281
- else {
282
- runs.push(runLength);
283
- currentValue = value;
284
- runLength = 1;
285
- }
286
- }
287
- }
288
- runs.push(runLength);
289
- return {
290
- counts: encodeCompressedRleCounts(runs),
291
- encoding: DetectionMaskEncoding.CompressedRle,
292
- height,
293
- width,
294
- };
295
- }
296
- function assertMaskDimensions(data, width, height) {
297
- if (!Number.isInteger(width) || width <= 0) {
298
- throw new Error("Mask width must be a positive integer.");
299
- }
300
- if (!Number.isInteger(height) || height <= 0) {
301
- throw new Error("Mask height must be a positive integer.");
302
- }
303
- if (data.length !== width * height) {
304
- throw new Error("Mask data length must equal width * height.");
305
- }
306
- }
307
343
  function rasterizePolygonToMask(points, dimensions) {
308
344
  const data = createEmptyMask(dimensions);
309
345
  if (points.length < 3) {
@@ -510,8 +546,11 @@
510
546
  }
511
547
  return { data, height, width };
512
548
  }
549
+ function createMaskIdFrame(instructions) {
550
+ return createIdMaskFrame(materializeMaskInstructions(instructions));
551
+ }
513
552
  async function createPngIdMaskFrame(instructions) {
514
- const frame = createIdMaskFrame(materializeMaskInstructions(instructions));
553
+ const frame = createMaskIdFrame(instructions);
515
554
  if (!frame) {
516
555
  return undefined;
517
556
  }
@@ -742,21 +781,24 @@
742
781
  }
743
782
  const imageData = new ImageData(compositedFrame.data, compositedFrame.width, compositedFrame.height);
744
783
  const imageBitmap = createImageBitmapFromImageData(imageData);
784
+ const idMaskData = createMaskIdFrame(message.job.instructions)?.data;
745
785
  if (imageBitmap) {
746
786
  workerScope.postMessage({
747
787
  imageBitmap,
788
+ idMaskData,
748
789
  key: message.job.key,
749
790
  requestId: message.requestId,
750
791
  type: MaskPreparationWorkerMessageType.Complete,
751
- }, [imageBitmap]);
792
+ }, [...(idMaskData ? [idMaskData.buffer] : []), imageBitmap]);
752
793
  return;
753
794
  }
754
795
  workerScope.postMessage({
796
+ idMaskData,
755
797
  imageData,
756
798
  key: message.job.key,
757
799
  requestId: message.requestId,
758
800
  type: MaskPreparationWorkerMessageType.Complete,
759
- }, [imageData.data.buffer]);
801
+ }, [...(idMaskData ? [idMaskData.buffer] : []), imageData.data.buffer]);
760
802
  }
761
803
  catch (error) {
762
804
  workerScope.postMessage({