supervision 0.1.1 → 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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +163 -16
- package/dist/index.js.map +1 -1
- package/dist/mask-preparation.worker.js.map +1 -1
- package/dist/renderers/media-frame-capture.d.ts +24 -0
- package/dist/renderers/media-frame-capture.d.ts.map +1 -0
- package/dist/renderers/media-renderer-core.d.ts.map +1 -1
- package/dist/renderers/media-renderer-scene.d.ts +6 -1
- package/dist/renderers/media-renderer-scene.d.ts.map +1 -1
- package/dist/renderers/pixi-focus-layer.d.ts.map +1 -1
- package/dist/renderers/pixi-media-scene.d.ts.map +1 -1
- package/dist/sessions/media-session.d.ts.map +1 -1
- package/dist/types/media-renderer.d.ts +44 -0
- package/dist/types/media-renderer.d.ts.map +1 -1
- package/dist/types/media-session.d.ts +9 -1
- package/dist/types/media-session.d.ts.map +1 -1
- package/node_modules/supervision-js-core/dist/index.d.ts +3 -1
- package/node_modules/supervision-js-core/dist/index.d.ts.map +1 -1
- package/node_modules/supervision-js-core/dist/index.js +242 -89
- package/node_modules/supervision-js-core/dist/index.js.map +1 -1
- package/node_modules/supervision-js-core/dist/styles/annotation-renderer-presentation.d.ts +9 -0
- package/node_modules/supervision-js-core/dist/styles/annotation-renderer-presentation.d.ts.map +1 -0
- package/node_modules/supervision-js-core/dist/styles/annotation-renderer-registry.d.ts +40 -0
- package/node_modules/supervision-js-core/dist/styles/annotation-renderer-registry.d.ts.map +1 -0
- package/node_modules/supervision-js-core/dist/styles/default-annotation-presentation.d.ts +19 -0
- package/node_modules/supervision-js-core/dist/styles/default-annotation-presentation.d.ts.map +1 -1
- package/node_modules/supervision-js-core/dist/styles/source-presentation.d.ts +10 -2
- package/node_modules/supervision-js-core/dist/styles/source-presentation.d.ts.map +1 -1
- package/node_modules/supervision-js-core/dist/types/annotation-renderer.d.ts +77 -0
- package/node_modules/supervision-js-core/dist/types/annotation-renderer.d.ts.map +1 -0
- package/node_modules/supervision-js-core/dist/types/media-rendering.d.ts +10 -1
- package/node_modules/supervision-js-core/dist/types/media-rendering.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { createImageUrlMediaSource, createStaticImageMediaSource, type HostFrame
|
|
|
15
15
|
export { createMediaStreamRendererSource, type MediaStreamRendererSourceOptions, } from "#media/media-stream-media-source";
|
|
16
16
|
export { createMediaRenderer } from "#renderers/media-renderer";
|
|
17
17
|
export { createMediaSession } from "#sessions/media-session";
|
|
18
|
+
export type { MediaFrameCapture, MediaFrameCaptureOptions, } from "#types/media-renderer";
|
|
18
19
|
export { BaseBoxStyle } from "supervision-js-core";
|
|
19
20
|
export type { BaseBoxStyleOptions } from "supervision-js-core";
|
|
20
21
|
export { BaseFocusStyle } from "supervision-js-core";
|
|
@@ -31,6 +32,7 @@ export { BasePolylineStyle } from "supervision-js-core";
|
|
|
31
32
|
export type { BasePolylineStyleOptions } from "supervision-js-core";
|
|
32
33
|
export { BaseKeypointStyle, KeypointMarkerShape } from "supervision-js-core";
|
|
33
34
|
export type { BaseKeypointStyleOptions } from "supervision-js-core";
|
|
35
|
+
export { annotationRendererKinds, annotationRenderers, type AnnotationRenderer, type AnnotationRendererFactory, type AnnotationRendererKind, type BoxAnnotationRenderer, type KeypointAnnotationRenderer, type LabelAnnotationRenderer, type MaskAnnotationRenderer, type PolygonAnnotationRenderer, type PolylineAnnotationRenderer, } from "supervision-js-core";
|
|
34
36
|
export { createDefaultAnnotationPresentation, type DefaultAnnotationPresentationOptions, } from "supervision-js-core";
|
|
35
37
|
export { DEFAULT_DETECTION_CLASS_STYLES, DEFAULT_DETECTION_COLOR_SEQUENCE, SUPERVISION_ROBOFLOW_COLOR, normalizeDetectionClassName, resolveDetectionClassColorStyle, type DetectionClassColorStyle, } from "supervision-js-core";
|
|
36
38
|
export { BoxShape, BoxStrokeAlignment } from "supervision-js-core";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,gDAAgD,CAAC;AACtG,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,mCAAmC,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,mCAAmC,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAGzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EACL,cAAc,EACd,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,YAAY,EACZ,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,YAAY,EACV,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,yBAAyB,EACzB,4BAA4B,EAC5B,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,+BAA+B,EAC/B,KAAK,gCAAgC,GACtC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.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AAC/B,OAAO,EACL,oCAAoC,EACpC,6BAA6B,EAC7B,8BAA8B,EAC9B,qBAAqB,EACrB,6BAA6B,EAC7B,KAAK,uCAAuC,EAC5C,KAAK,oCAAoC,EACzC,KAAK,0CAA0C,EAC/C,KAAK,4BAA4B,EACjC,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,oCAAoC,EACzC,KAAK,8BAA8B,GACpC,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { copySortedDetectionFrames, detectionFrameOverlapsRange, includeDefined, MediaSourceStatus, MediaRendererPlaybackState, MediaRendererFit, createDefaultAnnotationPresentation, createArrayDetectionFrameSource, createBufferedDetectionTimeline, createIdleDetectionBufferState, MediaInteractionMode, BoxStrokeAlignment, BaseBoxStyle, centerRectToTopLeftRect, BoxShape, BaseFocusStyle, AnnotationGestureStateKind, AnnotationHandleKind, getDetectionRect, DetectionPickTarget, createDetectionPickKey, rebaseDetectionPickToFrame, pickDetectionAtPoint, pickAnnotationHandle, getAnnotationHandles, createIdMaskFrame, encodeBinaryMask, rasterizePolygonToMask,
|
|
2
|
-
export { BaseBoxStyle, BaseFocusStyle, BaseInteractionStyle, BaseKeypointStyle, BaseLabelStyle, BaseMaskStyle, BasePolygonStyle, BasePolylineStyle, BoxShape, BoxStrokeAlignment, DEFAULT_DETECTION_CLASS_STYLES, DEFAULT_DETECTION_COLOR_SEQUENCE, DetectionBufferStatus, DetectionFrameRetentionMode, DetectionFrameSelectionMode, DetectionInteractionState, DetectionMaskEncoding, DetectionPickTarget, FocusTargetMode, KeypointMarkerShape, KeypointVisibility, LabelPlacement, LabelVisibilityMode, MaskRenderMode, MediaInteractionMode, MediaRendererFit, MediaRendererPlaybackState, MediaSessionActivityKind, MediaSessionActivityStatus, MediaSessionMode, MediaSessionStatus, MediaSourceStatus, SUPERVISION_ROBOFLOW_COLOR, createArrayDetectionFrameSource, createBufferedDetectionTimeline, createColdDetectionFrameSource, createCompositeDetectionFrameSource, createDefaultAnnotationPresentation, createMemoryColdDetectionFrameStore, createWritableDetectionFrameSource, normalizeDetectionClassName, pickDetectionAtPoint, resolveDetectionClassColorStyle } from 'supervision-js-core';
|
|
1
|
+
import { copySortedDetectionFrames, detectionFrameOverlapsRange, includeDefined, MediaSourceStatus, MediaRendererPlaybackState, MediaRendererFit, createDefaultAnnotationPresentation, createArrayDetectionFrameSource, createBufferedDetectionTimeline, resolveAnnotationRendererPresentation, createIdleDetectionBufferState, MediaInteractionMode, BoxStrokeAlignment, BaseBoxStyle, centerRectToTopLeftRect, BoxShape, BaseFocusStyle, decodeCompressedRleMask, extractMaskRectRuns, AnnotationGestureStateKind, AnnotationHandleKind, getDetectionRect, DetectionPickTarget, createDetectionPickKey, rebaseDetectionPickToFrame, pickDetectionAtPoint, pickAnnotationHandle, getAnnotationHandles, createIdMaskFrame, encodeBinaryMask, rasterizePolygonToMask, LabelPlacement, BasePolygonStyle, BasePolylineStyle, BaseKeypointStyle, KeypointMarkerShape, BaseInteractionStyle, DetectionInteractionState, MAX_ID_MASK_PALETTE_ENTRIES, DetectionBufferStatus, canReuseMaskStyleArtifacts, getBufferedDetectionTimelineFrameSnapshot, MAX_ID_MASK_STROKE_WIDTH, resolveMaskStyleOpacity, pickDetectionByMaskId, resolveStyleValue, lightenColor, createViewportController, resolveAnnotationStyleState, MediaSessionMode, DetectionFrameRetentionMode, createMemoryColdDetectionFrameStore, createWritableDetectionFrameSource, createCompositeDetectionFrameSource, MediaSessionActivityStatus, MediaSessionActivityKind, MediaSessionStatus, createSourceAwarePresentation } from 'supervision-js-core';
|
|
2
|
+
export { BaseBoxStyle, BaseFocusStyle, BaseInteractionStyle, BaseKeypointStyle, BaseLabelStyle, BaseMaskStyle, BasePolygonStyle, BasePolylineStyle, BoxShape, BoxStrokeAlignment, DEFAULT_DETECTION_CLASS_STYLES, DEFAULT_DETECTION_COLOR_SEQUENCE, DetectionBufferStatus, DetectionFrameRetentionMode, DetectionFrameSelectionMode, DetectionInteractionState, DetectionMaskEncoding, DetectionPickTarget, FocusTargetMode, KeypointMarkerShape, KeypointVisibility, LabelPlacement, LabelVisibilityMode, MaskRenderMode, MediaInteractionMode, MediaRendererFit, MediaRendererPlaybackState, MediaSessionActivityKind, MediaSessionActivityStatus, MediaSessionMode, MediaSessionStatus, MediaSourceStatus, SUPERVISION_ROBOFLOW_COLOR, annotationRendererKinds, annotationRenderers, createArrayDetectionFrameSource, createBufferedDetectionTimeline, createColdDetectionFrameSource, createCompositeDetectionFrameSource, createDefaultAnnotationPresentation, createMemoryColdDetectionFrameStore, createWritableDetectionFrameSource, normalizeDetectionClassName, pickDetectionAtPoint, resolveDetectionClassColorStyle } from 'supervision-js-core';
|
|
3
3
|
|
|
4
4
|
const DEFAULT_DATABASE_NAME = "supervision-js-detection-frames";
|
|
5
5
|
const DEFAULT_CHUNK_DURATION_SECONDS = 1;
|
|
@@ -2231,7 +2231,7 @@ async function createMediaRendererCore(options, providers) {
|
|
|
2231
2231
|
throw new RangeError("playbackRate must be a finite number greater than zero.");
|
|
2232
2232
|
}
|
|
2233
2233
|
const defaultPresentation = createDefaultAnnotationPresentation();
|
|
2234
|
-
const resolvePresentation = (presentation) => ({
|
|
2234
|
+
const resolvePresentation = (presentation) => resolveAnnotationRendererPresentation({
|
|
2235
2235
|
...defaultPresentation,
|
|
2236
2236
|
...presentation,
|
|
2237
2237
|
});
|
|
@@ -2246,6 +2246,7 @@ async function createMediaRendererCore(options, providers) {
|
|
|
2246
2246
|
maskStyle: options.maskStyle,
|
|
2247
2247
|
polygonStyle: options.polygonStyle,
|
|
2248
2248
|
polylineStyle: options.polylineStyle,
|
|
2249
|
+
renderers: options.renderers,
|
|
2249
2250
|
visibility: options.visibility,
|
|
2250
2251
|
});
|
|
2251
2252
|
let detectionTimeline;
|
|
@@ -2413,6 +2414,15 @@ async function createMediaRendererCore(options, providers) {
|
|
|
2413
2414
|
runtimeState.recordPresentationUpdate(presentedSample);
|
|
2414
2415
|
}
|
|
2415
2416
|
},
|
|
2417
|
+
async captureFrame(captureOptions) {
|
|
2418
|
+
if (runtimeState.isDestroyed()) {
|
|
2419
|
+
throw new Error("Media renderer has been destroyed.");
|
|
2420
|
+
}
|
|
2421
|
+
if (!mediaScene?.captureFrame) {
|
|
2422
|
+
throw new Error("Media renderer is not ready.");
|
|
2423
|
+
}
|
|
2424
|
+
return mediaScene.captureFrame(captureOptions);
|
|
2425
|
+
},
|
|
2416
2426
|
getState() {
|
|
2417
2427
|
return runtimeState.snapshot();
|
|
2418
2428
|
},
|
|
@@ -2725,6 +2735,56 @@ function clampSeekTime(options) {
|
|
|
2725
2735
|
return Math.min(Math.max(mediaTime, startTime), endTime ?? mediaTime);
|
|
2726
2736
|
}
|
|
2727
2737
|
|
|
2738
|
+
/** Encoded image type used when a capture does not request one. */
|
|
2739
|
+
const DEFAULT_MEDIA_FRAME_CAPTURE_TYPE = "image/jpeg";
|
|
2740
|
+
/** Lossy encoder quality used when a capture does not request one. */
|
|
2741
|
+
const DEFAULT_MEDIA_FRAME_CAPTURE_QUALITY = 0.92;
|
|
2742
|
+
/**
|
|
2743
|
+
* Encodes media pixels a renderer has already presented.
|
|
2744
|
+
*
|
|
2745
|
+
* The presented pixels and their timestamp are copied synchronously before the
|
|
2746
|
+
* first await, so a frame presented while the encoder runs cannot change the
|
|
2747
|
+
* captured image or desynchronize it from `mediaTime`.
|
|
2748
|
+
*/
|
|
2749
|
+
async function captureCanvasMediaFrame(request) {
|
|
2750
|
+
const { height, width } = request.source;
|
|
2751
|
+
if (width <= 0 || height <= 0) {
|
|
2752
|
+
throw new Error("No media frame has been presented yet.");
|
|
2753
|
+
}
|
|
2754
|
+
const type = request.capture?.type ?? DEFAULT_MEDIA_FRAME_CAPTURE_TYPE;
|
|
2755
|
+
const quality = request.capture?.quality ?? DEFAULT_MEDIA_FRAME_CAPTURE_QUALITY;
|
|
2756
|
+
if (!Number.isFinite(quality) || quality < 0 || quality > 1) {
|
|
2757
|
+
throw new RangeError("quality must be a number between 0 and 1.");
|
|
2758
|
+
}
|
|
2759
|
+
const snapshot = request.createCanvas();
|
|
2760
|
+
snapshot.width = width;
|
|
2761
|
+
snapshot.height = height;
|
|
2762
|
+
const context = snapshot.getContext("2d");
|
|
2763
|
+
if (!context) {
|
|
2764
|
+
throw new Error("Unable to create a media frame capture context.");
|
|
2765
|
+
}
|
|
2766
|
+
context.drawImage(request.source, 0, 0);
|
|
2767
|
+
const blob = await encodeCanvas(snapshot, type, quality);
|
|
2768
|
+
return {
|
|
2769
|
+
blob,
|
|
2770
|
+
height,
|
|
2771
|
+
mediaTime: request.mediaTime,
|
|
2772
|
+
type: blob.type || type,
|
|
2773
|
+
width,
|
|
2774
|
+
};
|
|
2775
|
+
}
|
|
2776
|
+
function encodeCanvas(canvas, type, quality) {
|
|
2777
|
+
return new Promise((resolve, reject) => {
|
|
2778
|
+
canvas.toBlob((blob) => {
|
|
2779
|
+
if (blob) {
|
|
2780
|
+
resolve(blob);
|
|
2781
|
+
return;
|
|
2782
|
+
}
|
|
2783
|
+
reject(new Error(`Unable to encode the presented media frame as ${type}.`));
|
|
2784
|
+
}, type, quality);
|
|
2785
|
+
});
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2728
2788
|
function resolveScreenLength(value, viewportScale) {
|
|
2729
2789
|
return value / Math.max(viewportScale, Number.EPSILON);
|
|
2730
2790
|
}
|
|
@@ -2996,6 +3056,10 @@ function createPixiFocusLayer(options) {
|
|
|
2996
3056
|
let targetAlpha = 0;
|
|
2997
3057
|
let lastTick = null;
|
|
2998
3058
|
let isDestroyed = false;
|
|
3059
|
+
// A frame can fall back to a composited RGBA texture when its colored ID-mask
|
|
3060
|
+
// palette is exhausted. Keep decoded row runs by the immutable mask payload so
|
|
3061
|
+
// that fallback focus still cuts out the actual mask, not its bounding rect.
|
|
3062
|
+
const maskCutoutRuns = new WeakMap();
|
|
2999
3063
|
return {
|
|
3000
3064
|
createDisplay({ width, height }) {
|
|
3001
3065
|
mediaWidth = width;
|
|
@@ -3104,8 +3168,10 @@ function createPixiFocusLayer(options) {
|
|
|
3104
3168
|
if (!focusGraphics) {
|
|
3105
3169
|
return;
|
|
3106
3170
|
}
|
|
3107
|
-
const
|
|
3108
|
-
|
|
3171
|
+
const targetsWithGeometry = instruction.targets.filter((target) => target.detection.mask ||
|
|
3172
|
+
target.detection.rect ||
|
|
3173
|
+
target.detection.polygon);
|
|
3174
|
+
if (targetsWithGeometry.length === 0) {
|
|
3109
3175
|
hideVectorFocus();
|
|
3110
3176
|
return;
|
|
3111
3177
|
}
|
|
@@ -3116,24 +3182,30 @@ function createPixiFocusLayer(options) {
|
|
|
3116
3182
|
if (focusMaskGraphics) {
|
|
3117
3183
|
focusMaskGraphics.visible = true;
|
|
3118
3184
|
focusMaskGraphics.clear();
|
|
3119
|
-
for (const target of
|
|
3120
|
-
drawCutoutShape(focusMaskGraphics, target, instruction)
|
|
3121
|
-
|
|
3185
|
+
for (const target of targetsWithGeometry) {
|
|
3186
|
+
if (drawCutoutShape(focusMaskGraphics, target, instruction) === "drawn") {
|
|
3187
|
+
focusMaskGraphics.fill({ alpha: 1, color: 0xffffff });
|
|
3188
|
+
}
|
|
3122
3189
|
}
|
|
3123
3190
|
return;
|
|
3124
3191
|
}
|
|
3125
|
-
for (const target of
|
|
3126
|
-
drawCutoutShape(focusGraphics, target, instruction)
|
|
3127
|
-
|
|
3192
|
+
for (const target of targetsWithGeometry) {
|
|
3193
|
+
if (drawCutoutShape(focusGraphics, target, instruction) === "drawn") {
|
|
3194
|
+
focusGraphics.cut();
|
|
3195
|
+
}
|
|
3128
3196
|
}
|
|
3129
3197
|
}
|
|
3130
3198
|
function drawCutoutShape(graphics, target, instruction) {
|
|
3199
|
+
const maskCutout = drawMaskCutout(graphics, target);
|
|
3200
|
+
if (maskCutout) {
|
|
3201
|
+
return maskCutout;
|
|
3202
|
+
}
|
|
3131
3203
|
if (target.detection.polygon?.points.length && graphics.poly) {
|
|
3132
3204
|
graphics.poly(target.detection.polygon.points.flatMap(({ x, y }) => [x, y]), true);
|
|
3133
|
-
return;
|
|
3205
|
+
return "drawn";
|
|
3134
3206
|
}
|
|
3135
3207
|
if (!target.detection.rect) {
|
|
3136
|
-
return;
|
|
3208
|
+
return "empty";
|
|
3137
3209
|
}
|
|
3138
3210
|
const { rect } = target.detection;
|
|
3139
3211
|
const fallback = instruction.fallback;
|
|
@@ -3144,6 +3216,44 @@ function createPixiFocusLayer(options) {
|
|
|
3144
3216
|
else {
|
|
3145
3217
|
graphics.rect(left, top, rect.width, rect.height);
|
|
3146
3218
|
}
|
|
3219
|
+
return "drawn";
|
|
3220
|
+
}
|
|
3221
|
+
function drawMaskCutout(graphics, target) {
|
|
3222
|
+
const mask = target.detection.mask;
|
|
3223
|
+
if (!mask) {
|
|
3224
|
+
return undefined;
|
|
3225
|
+
}
|
|
3226
|
+
let runs;
|
|
3227
|
+
if (!maskCutoutRuns.has(mask)) {
|
|
3228
|
+
try {
|
|
3229
|
+
const decoded = decodeCompressedRleMask(mask);
|
|
3230
|
+
runs = {
|
|
3231
|
+
height: decoded.height,
|
|
3232
|
+
runs: extractMaskRectRuns(decoded.data, decoded.width, decoded.height) ??
|
|
3233
|
+
[],
|
|
3234
|
+
width: decoded.width,
|
|
3235
|
+
};
|
|
3236
|
+
}
|
|
3237
|
+
catch {
|
|
3238
|
+
// Preserve the documented rectangle fallback for malformed masks. A
|
|
3239
|
+
// valid mask must never lose its shape merely because ID-mask rendering
|
|
3240
|
+
// is unavailable, but an unreadable payload still has only bounds.
|
|
3241
|
+
runs = null;
|
|
3242
|
+
}
|
|
3243
|
+
maskCutoutRuns.set(mask, runs);
|
|
3244
|
+
}
|
|
3245
|
+
else {
|
|
3246
|
+
runs = maskCutoutRuns.get(mask);
|
|
3247
|
+
}
|
|
3248
|
+
if (runs === null) {
|
|
3249
|
+
return undefined;
|
|
3250
|
+
}
|
|
3251
|
+
const horizontalScale = mediaWidth / runs.width;
|
|
3252
|
+
const verticalScale = mediaHeight / runs.height;
|
|
3253
|
+
for (const run of runs.runs) {
|
|
3254
|
+
graphics.rect(run.x * horizontalScale, run.y * verticalScale, run.width * horizontalScale, run.height * verticalScale);
|
|
3255
|
+
}
|
|
3256
|
+
return runs.runs.length === 0 ? "empty" : "drawn";
|
|
3147
3257
|
}
|
|
3148
3258
|
function hide() {
|
|
3149
3259
|
hideVectorFocus();
|
|
@@ -7799,6 +7909,11 @@ async function createPixiMediaScene(options) {
|
|
|
7799
7909
|
let viewportScale = 1;
|
|
7800
7910
|
const viewport = createViewportController({ scale: 1 });
|
|
7801
7911
|
let hasPresentedSample = false;
|
|
7912
|
+
/**
|
|
7913
|
+
* Timestamp of the sample whose pixels are on the staging canvas. Unlike
|
|
7914
|
+
* `currentMediaTime`, presentation and selection updates never move it.
|
|
7915
|
+
*/
|
|
7916
|
+
let presentedSampleTimestamp = null;
|
|
7802
7917
|
let baseFit;
|
|
7803
7918
|
const interactionLayer = options.interaction || options.editingEngine
|
|
7804
7919
|
? createPixiInteractionLayer({
|
|
@@ -8057,6 +8172,7 @@ async function createPixiMediaScene(options) {
|
|
|
8057
8172
|
hasPresentedSample = true;
|
|
8058
8173
|
if (!collectFrameTimings) {
|
|
8059
8174
|
sample.draw(stagingContext, 0, 0, mediaWidth, mediaHeight);
|
|
8175
|
+
presentedSampleTimestamp = sample.timestamp;
|
|
8060
8176
|
stagingTextureSource?.update();
|
|
8061
8177
|
stagingTexture?.update();
|
|
8062
8178
|
maskLayer?.drawFrame(sample.timestamp);
|
|
@@ -8083,6 +8199,7 @@ async function createPixiMediaScene(options) {
|
|
|
8083
8199
|
let focusMs = 0;
|
|
8084
8200
|
mediaUploadMs = measure(() => {
|
|
8085
8201
|
sample.draw(stagingContext, 0, 0, mediaWidth, mediaHeight);
|
|
8202
|
+
presentedSampleTimestamp = sample.timestamp;
|
|
8086
8203
|
stagingTextureSource?.update();
|
|
8087
8204
|
stagingTexture?.update();
|
|
8088
8205
|
});
|
|
@@ -8129,6 +8246,17 @@ async function createPixiMediaScene(options) {
|
|
|
8129
8246
|
sample.close();
|
|
8130
8247
|
}
|
|
8131
8248
|
},
|
|
8249
|
+
captureFrame(captureOptions) {
|
|
8250
|
+
if (presentedSampleTimestamp === null) {
|
|
8251
|
+
return Promise.reject(new Error("No media frame has been presented yet."));
|
|
8252
|
+
}
|
|
8253
|
+
return captureCanvasMediaFrame({
|
|
8254
|
+
capture: captureOptions,
|
|
8255
|
+
createCanvas: () => document.createElement("canvas"),
|
|
8256
|
+
mediaTime: presentedSampleTimestamp,
|
|
8257
|
+
source: stagingCanvas,
|
|
8258
|
+
});
|
|
8259
|
+
},
|
|
8132
8260
|
waitForRenderPreparation(mediaTime, gateOptions) {
|
|
8133
8261
|
return Promise.all([
|
|
8134
8262
|
maskLayer?.waitForRenderPreparation(mediaTime, gateOptions),
|
|
@@ -9255,8 +9383,21 @@ async function createMediaSession(options) {
|
|
|
9255
9383
|
const sessionDetections = preparedDetections;
|
|
9256
9384
|
const defaultPresentation = createDefaultAnnotationPresentation();
|
|
9257
9385
|
let currentPresentation = options.presentation;
|
|
9258
|
-
const resolvePresentation = (presentation) =>
|
|
9259
|
-
|
|
9386
|
+
const resolvePresentation = (presentation) => {
|
|
9387
|
+
const renderers = presentation?.renderers;
|
|
9388
|
+
const resolvedPresentation = resolveAnnotationRendererPresentation({
|
|
9389
|
+
...defaultPresentation,
|
|
9390
|
+
...presentation,
|
|
9391
|
+
});
|
|
9392
|
+
return createSourceAwarePresentation(resolvedPresentation, sessionDetections.sourcePresentations, renderers === undefined
|
|
9393
|
+
? undefined
|
|
9394
|
+
: { enabledRendererKinds: renderers.map(({ kind }) => kind) });
|
|
9395
|
+
};
|
|
9396
|
+
const resolveRendererPresentation = (presentation) => ({
|
|
9397
|
+
...resolvePresentation(presentation),
|
|
9398
|
+
renderers: undefined,
|
|
9399
|
+
});
|
|
9400
|
+
const initialPresentation = resolveRendererPresentation(currentPresentation);
|
|
9260
9401
|
const renderer = await createMediaRenderer({
|
|
9261
9402
|
...options.renderer,
|
|
9262
9403
|
...sessionMedia.rendererSourceOption,
|
|
@@ -9347,9 +9488,15 @@ async function createMediaSession(options) {
|
|
|
9347
9488
|
refresh() {
|
|
9348
9489
|
return renderer.refresh();
|
|
9349
9490
|
},
|
|
9491
|
+
captureFrame(captureOptions) {
|
|
9492
|
+
if (destroyed) {
|
|
9493
|
+
throw new Error("Media session has been destroyed.");
|
|
9494
|
+
}
|
|
9495
|
+
return renderer.captureFrame(captureOptions);
|
|
9496
|
+
},
|
|
9350
9497
|
setPresentation(presentation) {
|
|
9351
9498
|
currentPresentation = presentation;
|
|
9352
|
-
renderer.setPresentation(
|
|
9499
|
+
renderer.setPresentation(resolveRendererPresentation(currentPresentation));
|
|
9353
9500
|
},
|
|
9354
9501
|
setRenderQuality(quality) {
|
|
9355
9502
|
renderer.setRenderQuality(quality);
|