@pose-tracker/pose-estimation-web 0.1.0 → 0.2.0
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/README.md +21 -4
- package/dist/index.cjs +536 -129
- package/dist/index.d.cts +100 -11
- package/dist/index.d.ts +100 -11
- package/dist/index.js +536 -130
- package/dist/pose-tracker.global.js +6 -5
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _tensorflow_tfjs from '@tensorflow/tfjs';
|
|
2
2
|
|
|
3
3
|
/** Bumped with package.json version (keep in sync). */
|
|
4
|
-
declare const SDK_VERSION = "0.
|
|
4
|
+
declare const SDK_VERSION = "0.2.0";
|
|
5
5
|
declare const SDK_NAME: "posetracker-web";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -310,7 +310,7 @@ type PoseTrackerStatus = 'idle' | 'configuring' | 'downloading' | 'warming' | 'r
|
|
|
310
310
|
* restarting the camera pipeline, via `configure()` or a preload retry.
|
|
311
311
|
*/
|
|
312
312
|
type PoseTrackerMode = 'keypoints-only' | 'full-engine';
|
|
313
|
-
type InitializationStep = 'configuring' | 'downloading' | 'warming' | 'accessing_webcam' | 'loading_pose_model' | 'ready';
|
|
313
|
+
type InitializationStep = 'configuring' | 'downloading' | 'warming' | 'accessing_webcam' | 'loading_media' | 'loading_pose_model' | 'ready';
|
|
314
314
|
interface InitializationEvent {
|
|
315
315
|
type: 'initialization';
|
|
316
316
|
/**
|
|
@@ -359,7 +359,7 @@ interface ErrorEvent {
|
|
|
359
359
|
/** Unknown exercise id (WebView parity: `invalid_exercise`). */
|
|
360
360
|
| 'invalid_exercise'
|
|
361
361
|
/** jump_analysis requires `userHeightCm` (WebView parity). */
|
|
362
|
-
| 'jump_analysis_missing_height' | 'model_load_failed' | 'engine_load_failed' | 'integrity_check_failed' | 'webview_error' | 'device_too_slow' | 'backend_fallback_wasm' | 'camera_denied' | 'camera_unavailable' | 'internal';
|
|
362
|
+
| 'jump_analysis_missing_height' | 'model_load_failed' | 'engine_load_failed' | 'integrity_check_failed' | 'webview_error' | 'device_too_slow' | 'backend_fallback_wasm' | 'camera_denied' | 'camera_unavailable' | 'media_load_failed' | 'media_unavailable' | 'internal';
|
|
363
363
|
message: string;
|
|
364
364
|
}
|
|
365
365
|
/**
|
|
@@ -811,6 +811,52 @@ declare class UsageTracker {
|
|
|
811
811
|
private enqueue;
|
|
812
812
|
}
|
|
813
813
|
|
|
814
|
+
/**
|
|
815
|
+
* Input source for pose estimation (camera / uploaded video / still image).
|
|
816
|
+
* Default remains camera for quickstart compatibility.
|
|
817
|
+
*/
|
|
818
|
+
type PoseSourceType = 'camera' | 'video' | 'image';
|
|
819
|
+
type CameraFacingMode = 'user' | 'environment';
|
|
820
|
+
interface CameraPoseSource {
|
|
821
|
+
type: 'camera';
|
|
822
|
+
facingMode?: CameraFacingMode;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Uploaded or remote video. `src` may be a URL string, File/Blob (object URL),
|
|
826
|
+
* or an existing HTMLVideoElement (SDK uses it as the frame source).
|
|
827
|
+
*/
|
|
828
|
+
interface VideoPoseSource {
|
|
829
|
+
type: 'video';
|
|
830
|
+
src: string | File | Blob | HTMLVideoElement;
|
|
831
|
+
/** Autoplay when attached. Default true. */
|
|
832
|
+
autoplay?: boolean;
|
|
833
|
+
/** Loop the file. Default true for continuous inference demos. */
|
|
834
|
+
loop?: boolean;
|
|
835
|
+
muted?: boolean;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Still image — single-shot estimate (re-run via `analyze()`).
|
|
839
|
+
*/
|
|
840
|
+
interface ImagePoseSource {
|
|
841
|
+
type: 'image';
|
|
842
|
+
src: string | File | Blob | HTMLImageElement | ImageBitmap;
|
|
843
|
+
}
|
|
844
|
+
type PoseSource = CameraPoseSource | VideoPoseSource | ImagePoseSource;
|
|
845
|
+
/** Narrow helper for prop-style APIs (`source` + `sourceUrl` / `sourceFile`). */
|
|
846
|
+
interface PoseSourceProps {
|
|
847
|
+
source?: PoseSourceType;
|
|
848
|
+
sourceUrl?: string;
|
|
849
|
+
sourceFile?: File | Blob;
|
|
850
|
+
facingMode?: CameraFacingMode;
|
|
851
|
+
}
|
|
852
|
+
/** Frame types accepted by detector adapters. */
|
|
853
|
+
type PoseEstimateInput = HTMLVideoElement | HTMLImageElement | HTMLCanvasElement | ImageBitmap;
|
|
854
|
+
declare function normalizePoseSource(source?: PoseSource | PoseSourceType | null, extras?: {
|
|
855
|
+
sourceUrl?: string;
|
|
856
|
+
sourceFile?: File | Blob;
|
|
857
|
+
facingMode?: CameraFacingMode;
|
|
858
|
+
}): PoseSource;
|
|
859
|
+
|
|
814
860
|
/**
|
|
815
861
|
* Online pose-model catalog (web) — mirrors RN light `poseModels.ts`.
|
|
816
862
|
*
|
|
@@ -954,6 +1000,14 @@ interface PoseTrackerClientOptions extends ConfigureOptions {
|
|
|
954
1000
|
onDiagnostic?: (message: string) => void;
|
|
955
1001
|
/** Alias of preload coldStart when using start(). Default full on camera screens. */
|
|
956
1002
|
coldStart?: ColdStartMode;
|
|
1003
|
+
/**
|
|
1004
|
+
* Input source. Default `{ type: 'camera' }` (webcam).
|
|
1005
|
+
* Use `{ type: 'video', src }` or `{ type: 'image', src }` for file / URL / element.
|
|
1006
|
+
*/
|
|
1007
|
+
source?: PoseSource | PoseSourceType;
|
|
1008
|
+
/** Convenience with `source: 'video' | 'image'` (string / File / Blob). */
|
|
1009
|
+
sourceUrl?: string;
|
|
1010
|
+
sourceFile?: File | Blob;
|
|
957
1011
|
}
|
|
958
1012
|
/** @deprecated Prefer PoseTrackerClientOptions — kept for vanilla DX. */
|
|
959
1013
|
type PoseTrackerOptions = PoseTrackerClientOptions;
|
|
@@ -989,6 +1043,10 @@ declare class PoseTrackerClient {
|
|
|
989
1043
|
private opts;
|
|
990
1044
|
private shell;
|
|
991
1045
|
private stream;
|
|
1046
|
+
private poseSource;
|
|
1047
|
+
private objectUrlRevoke;
|
|
1048
|
+
private estimateInput;
|
|
1049
|
+
private imageShotPending;
|
|
992
1050
|
private adapter;
|
|
993
1051
|
private resolved;
|
|
994
1052
|
private running;
|
|
@@ -1013,6 +1071,8 @@ declare class PoseTrackerClient {
|
|
|
1013
1071
|
getAccelerationDiagnostics(): AccelerationDiagnostics;
|
|
1014
1072
|
getResolvedModel(): ResolvedPoseModel;
|
|
1015
1073
|
getColdStartMode(): ColdStartMode;
|
|
1074
|
+
/** Active pose input source (`camera` | `video` | `image`). */
|
|
1075
|
+
getSource(): PoseSource;
|
|
1016
1076
|
addEventListener(listener: PoseTrackerEventListener): () => void;
|
|
1017
1077
|
on(type: PoseTrackerEvent['type'] | '*', listener: PoseTrackerEventListener): () => void;
|
|
1018
1078
|
addMessageListener(listener: ClassicMessageListener): () => void;
|
|
@@ -1024,9 +1084,27 @@ declare class PoseTrackerClient {
|
|
|
1024
1084
|
*/
|
|
1025
1085
|
preload(options?: PreloadOptions): Promise<void>;
|
|
1026
1086
|
warmup(options?: PreloadOptions): Promise<void>;
|
|
1027
|
-
/**
|
|
1087
|
+
/**
|
|
1088
|
+
* Mount + load model + open source + start inference.
|
|
1089
|
+
* Camera / video stream continuously; image runs a single shot (re-run with {@link analyze}).
|
|
1090
|
+
*/
|
|
1028
1091
|
start(): Promise<void>;
|
|
1092
|
+
/**
|
|
1093
|
+
* Switch input source. Stops the current media, attaches the new source, and
|
|
1094
|
+
* restarts the loop when previously running.
|
|
1095
|
+
*/
|
|
1096
|
+
setSource(source: PoseSource | PoseSourceType, extras?: {
|
|
1097
|
+
sourceUrl?: string;
|
|
1098
|
+
sourceFile?: File | Blob;
|
|
1099
|
+
facingMode?: 'user' | 'environment';
|
|
1100
|
+
}): Promise<void>;
|
|
1101
|
+
/**
|
|
1102
|
+
* Re-run pose estimation on the current still image (no-op for camera/video
|
|
1103
|
+
* while the loop is already running — for those, call {@link start}).
|
|
1104
|
+
*/
|
|
1105
|
+
analyze(): Promise<Pose | null>;
|
|
1029
1106
|
stop(): void;
|
|
1107
|
+
private stopMediaOnly;
|
|
1030
1108
|
dispose(): Promise<void>;
|
|
1031
1109
|
configure(apiToken?: string): Promise<boolean>;
|
|
1032
1110
|
getAvailableExercises(): ExerciseConfig[];
|
|
@@ -1042,8 +1120,13 @@ declare class PoseTrackerClient {
|
|
|
1042
1120
|
private doPreload;
|
|
1043
1121
|
private ensureColdStartMode;
|
|
1044
1122
|
private ensureAdapter;
|
|
1045
|
-
private
|
|
1123
|
+
private ensureSource;
|
|
1124
|
+
private scheduleReveal;
|
|
1125
|
+
private attachVideoSource;
|
|
1126
|
+
private attachImageSource;
|
|
1046
1127
|
private beginLoop;
|
|
1128
|
+
private frameReady;
|
|
1129
|
+
private runOneFrame;
|
|
1047
1130
|
private loop;
|
|
1048
1131
|
private resolveSkeletonFromOptions;
|
|
1049
1132
|
private resolveManifestOnce;
|
|
@@ -1095,14 +1178,16 @@ interface DetectorFrameResult {
|
|
|
1095
1178
|
letterbox: Letterbox;
|
|
1096
1179
|
}
|
|
1097
1180
|
type Float32ArrayLike = ArrayLike<number>;
|
|
1181
|
+
|
|
1098
1182
|
interface PoseDetectorAdapter {
|
|
1099
1183
|
readonly modelId: string;
|
|
1100
1184
|
load(): Promise<void>;
|
|
1101
1185
|
/**
|
|
1102
|
-
* Run one frame.
|
|
1186
|
+
* Run one frame. Input must have non-zero dimensions
|
|
1187
|
+
* (HTMLVideoElement, HTMLImageElement, canvas, or ImageBitmap).
|
|
1103
1188
|
* Returns null when the frame should be skipped.
|
|
1104
1189
|
*/
|
|
1105
|
-
estimate(
|
|
1190
|
+
estimate(input: PoseEstimateInput, options: {
|
|
1106
1191
|
facingMode: 'user' | 'environment';
|
|
1107
1192
|
displayWidth: number;
|
|
1108
1193
|
displayHeight: number;
|
|
@@ -1133,7 +1218,7 @@ declare class MoveNetGraphAdapter implements PoseDetectorAdapter {
|
|
|
1133
1218
|
private poseCanvasCtx;
|
|
1134
1219
|
private prepareInput;
|
|
1135
1220
|
private smooth;
|
|
1136
|
-
estimate(
|
|
1221
|
+
estimate(input: PoseEstimateInput, options: {
|
|
1137
1222
|
facingMode: 'user' | 'environment';
|
|
1138
1223
|
displayWidth: number;
|
|
1139
1224
|
displayHeight: number;
|
|
@@ -1162,7 +1247,7 @@ declare class BlazePoseAdapter implements PoseDetectorAdapter {
|
|
|
1162
1247
|
constructor(_ctx: CreateAdapterContext);
|
|
1163
1248
|
getBackend(): string | null;
|
|
1164
1249
|
load(): Promise<void>;
|
|
1165
|
-
estimate(
|
|
1250
|
+
estimate(input: PoseEstimateInput, options: {
|
|
1166
1251
|
facingMode: 'user' | 'environment';
|
|
1167
1252
|
displayWidth: number;
|
|
1168
1253
|
displayHeight: number;
|
|
@@ -1266,6 +1351,8 @@ declare function drawSkeleton(ctx: CanvasRenderingContext2D, kps: DrawKeypoint[]
|
|
|
1266
1351
|
interface DomShell {
|
|
1267
1352
|
root: HTMLElement;
|
|
1268
1353
|
video: HTMLVideoElement;
|
|
1354
|
+
/** Still-image element for `source: image` mode. */
|
|
1355
|
+
image: HTMLImageElement;
|
|
1269
1356
|
canvas: HTMLCanvasElement;
|
|
1270
1357
|
boot: HTMLElement;
|
|
1271
1358
|
bootMsg: HTMLElement;
|
|
@@ -1274,10 +1361,12 @@ interface DomShell {
|
|
|
1274
1361
|
placement: HTMLElement;
|
|
1275
1362
|
setBootMessage(text: string, isError?: boolean): void;
|
|
1276
1363
|
setCameraVisible(visible: boolean): void;
|
|
1364
|
+
/** Show video preview, still image, or neither (boot only). */
|
|
1365
|
+
setMediaMode(mode: 'video' | 'image' | 'none'): void;
|
|
1277
1366
|
setWatermarkVisible(visible: boolean): void;
|
|
1278
1367
|
setHud(text: string, debug: boolean): void;
|
|
1279
1368
|
setPlacementVisible(visible: boolean, paddingPercent?: number): void;
|
|
1280
|
-
applyMirror(facingMode: 'user' | 'environment'): void;
|
|
1369
|
+
applyMirror(facingMode: 'user' | 'environment' | 'none'): void;
|
|
1281
1370
|
destroy(): void;
|
|
1282
1371
|
}
|
|
1283
1372
|
declare function mountDomShell(host: HTMLElement, options?: {
|
|
@@ -1322,4 +1411,4 @@ declare function findExerciseByIdOrAlias<T extends {
|
|
|
1322
1411
|
id: string;
|
|
1323
1412
|
}>(exerciseId: string, exercises: readonly T[]): T | undefined;
|
|
1324
1413
|
|
|
1325
|
-
export { type AccelerationDiagnostics, type AccelerationState, type AngleValue, type AnglesEvent, BRAND_COLORS, BlazePoseAdapter, type BlazePoseModelType, COCO_KEYPOINT_NAMES, COMBINED_REFERENCE_EXERCISE_MESSAGE, type CameraOptions, type ClassicMessageListener, type ClassicNativeMessage, type CocoKeypointName, type ColdStartMode, ConfigureError, type ConfigureOptions, type ConfigureRequest, type CounterEvent, type CounterFormScore, type CustomExerciseDescriptor, type CustomSessionOptions, DEFAULT_BASE_URL, DEFAULT_FEATURES, DEFAULT_LOADING_TEXT, DEFAULT_MOVENET_LIGHTNING_URL, DEFAULT_SKELETON, DEFAULT_SKELETON_DEFINITION, type DetectorFrameResult, type DiagnosticListener, EXERCISE_ALIASES, type EngineBundleDescriptor, type EngineLoadResult, EngineLoader, type EngineLoaderOptions, type EngineSession, type EngineSessionFeatures, type EngineSessionOptions, type ErrorEvent, type EventSink, type ExerciseConfig, type ExerciseSummaryEvent, FREE_PLAN_FEATURES_MESSAGE, type FetchSkeletonOptions, type FileStore, type FormGrade, type FormScoreEvent, INVALID_TOKEN_MESSAGE, type InferenceRuntime, type InitialPosture, type InitializationEvent, type InitializationStep, type JumpCalibrationEvent, type JumpDiscardedEvent, type JumpHeightEvent, type JumpResultEvent, type JumpStartedEvent, type JumpSummaryEntry, type JumpSummaryEvent, type KeyValueStore, type Keypoint, type KeypointName, type KeypointsEvent, type MinGrade, type ModelDescriptor, type ModelFormat, type ModelsByProfile, MoveNetGraphAdapter, type MovementDefinition, type MovementRecommendation, type MovementStep, type MovementStepParameter, ONLINE_POSE_DETECTION_VERSION, ONLINE_TFJS_VERSION, POSETRACKER_LOGO_URL, type PerformanceWarningEvent, type PlanInfo, type Pose, PoseCamera, PoseCamera_mount, type PoseDetectionModule, type PoseDetectorAdapter, type PoseModelAlias, type PoseModelKind, type PoseModelProfile, type PoseRuntimeDescriptor, type PoseRuntimePartDescriptor, type PoseTracker, type PoseTrackerCallbacks, PoseTrackerClient, type PoseTrackerClientOptions, type PoseTrackerEngine, type PoseTrackerEvent, type PoseTrackerEventListener, type PoseTrackerEventType, type PoseTrackerFeatures, type PoseTrackerMode, type PoseTrackerOptions, type PoseTrackerStatus, type PostureEvent, type PreloadOptions, type ProgressionEvent, type QualityChangedEvent, type RecommendationsEvent, type ReferenceMovementDescriptor, type RepSummary, type ResolvePoseModelOptions, type ResolvedFeatures, type ResolvedPoseModel, type RuntimeDownloadProgressEvent, SDK_NAME, SDK_VERSION, type SdkManifest, type SkeletonAnglesStyle, type SkeletonCirclesStyle, type SkeletonDefinition, SkeletonFetchError, type SkeletonLinesStyle, type StartExerciseOptions, type StatsEvent, type TfModule, type TfjsCdnUrls, TrackError, type TrackRequest, type TrackResponse, UsageTracker, type UsageTrackerOptions, type VisibleHipsInfo, type WarningEvent, configure, createLocalFileStore, createLocalKeyValueStore, createMemoryFileStore, createPoseAdapter, createPoseTracker, createWebFileStore, defaultPoseDetectionCdnUrl, defaultTfjsCdnUrls, drawSkeleton, featureNotSupportedMessage, fetchSkeletonDefinition, findExerciseByIdOrAlias, freeBlockedFeatures, initWebGlBackend, isPaidPlan, mapVideoKeypointsToDisplay, mountDomShell, openCameraStream, resolveExerciseName, resolveFeatures, resolvePoseDetection, resolvePoseModel, resolveTf, shouldShowWatermark, stopMediaStream, toClassicNativeMessage };
|
|
1414
|
+
export { type AccelerationDiagnostics, type AccelerationState, type AngleValue, type AnglesEvent, BRAND_COLORS, BlazePoseAdapter, type BlazePoseModelType, COCO_KEYPOINT_NAMES, COMBINED_REFERENCE_EXERCISE_MESSAGE, type CameraFacingMode, type CameraOptions, type CameraPoseSource, type ClassicMessageListener, type ClassicNativeMessage, type CocoKeypointName, type ColdStartMode, ConfigureError, type ConfigureOptions, type ConfigureRequest, type CounterEvent, type CounterFormScore, type CustomExerciseDescriptor, type CustomSessionOptions, DEFAULT_BASE_URL, DEFAULT_FEATURES, DEFAULT_LOADING_TEXT, DEFAULT_MOVENET_LIGHTNING_URL, DEFAULT_SKELETON, DEFAULT_SKELETON_DEFINITION, type DetectorFrameResult, type DiagnosticListener, EXERCISE_ALIASES, type EngineBundleDescriptor, type EngineLoadResult, EngineLoader, type EngineLoaderOptions, type EngineSession, type EngineSessionFeatures, type EngineSessionOptions, type ErrorEvent, type EventSink, type ExerciseConfig, type ExerciseSummaryEvent, FREE_PLAN_FEATURES_MESSAGE, type FetchSkeletonOptions, type FileStore, type FormGrade, type FormScoreEvent, INVALID_TOKEN_MESSAGE, type ImagePoseSource, type InferenceRuntime, type InitialPosture, type InitializationEvent, type InitializationStep, type JumpCalibrationEvent, type JumpDiscardedEvent, type JumpHeightEvent, type JumpResultEvent, type JumpStartedEvent, type JumpSummaryEntry, type JumpSummaryEvent, type KeyValueStore, type Keypoint, type KeypointName, type KeypointsEvent, type MinGrade, type ModelDescriptor, type ModelFormat, type ModelsByProfile, MoveNetGraphAdapter, type MovementDefinition, type MovementRecommendation, type MovementStep, type MovementStepParameter, ONLINE_POSE_DETECTION_VERSION, ONLINE_TFJS_VERSION, POSETRACKER_LOGO_URL, type PerformanceWarningEvent, type PlanInfo, type Pose, PoseCamera, PoseCamera_mount, type PoseDetectionModule, type PoseDetectorAdapter, type PoseEstimateInput, type PoseModelAlias, type PoseModelKind, type PoseModelProfile, type PoseRuntimeDescriptor, type PoseRuntimePartDescriptor, type PoseSource, type PoseSourceProps, type PoseSourceType, type PoseTracker, type PoseTrackerCallbacks, PoseTrackerClient, type PoseTrackerClientOptions, type PoseTrackerEngine, type PoseTrackerEvent, type PoseTrackerEventListener, type PoseTrackerEventType, type PoseTrackerFeatures, type PoseTrackerMode, type PoseTrackerOptions, type PoseTrackerStatus, type PostureEvent, type PreloadOptions, type ProgressionEvent, type QualityChangedEvent, type RecommendationsEvent, type ReferenceMovementDescriptor, type RepSummary, type ResolvePoseModelOptions, type ResolvedFeatures, type ResolvedPoseModel, type RuntimeDownloadProgressEvent, SDK_NAME, SDK_VERSION, type SdkManifest, type SkeletonAnglesStyle, type SkeletonCirclesStyle, type SkeletonDefinition, SkeletonFetchError, type SkeletonLinesStyle, type StartExerciseOptions, type StatsEvent, type TfModule, type TfjsCdnUrls, TrackError, type TrackRequest, type TrackResponse, UsageTracker, type UsageTrackerOptions, type VideoPoseSource, type VisibleHipsInfo, type WarningEvent, configure, createLocalFileStore, createLocalKeyValueStore, createMemoryFileStore, createPoseAdapter, createPoseTracker, createWebFileStore, defaultPoseDetectionCdnUrl, defaultTfjsCdnUrls, drawSkeleton, featureNotSupportedMessage, fetchSkeletonDefinition, findExerciseByIdOrAlias, freeBlockedFeatures, initWebGlBackend, isPaidPlan, mapVideoKeypointsToDisplay, mountDomShell, normalizePoseSource, openCameraStream, resolveExerciseName, resolveFeatures, resolvePoseDetection, resolvePoseModel, resolveTf, shouldShowWatermark, stopMediaStream, toClassicNativeMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _tensorflow_tfjs from '@tensorflow/tfjs';
|
|
2
2
|
|
|
3
3
|
/** Bumped with package.json version (keep in sync). */
|
|
4
|
-
declare const SDK_VERSION = "0.
|
|
4
|
+
declare const SDK_VERSION = "0.2.0";
|
|
5
5
|
declare const SDK_NAME: "posetracker-web";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -310,7 +310,7 @@ type PoseTrackerStatus = 'idle' | 'configuring' | 'downloading' | 'warming' | 'r
|
|
|
310
310
|
* restarting the camera pipeline, via `configure()` or a preload retry.
|
|
311
311
|
*/
|
|
312
312
|
type PoseTrackerMode = 'keypoints-only' | 'full-engine';
|
|
313
|
-
type InitializationStep = 'configuring' | 'downloading' | 'warming' | 'accessing_webcam' | 'loading_pose_model' | 'ready';
|
|
313
|
+
type InitializationStep = 'configuring' | 'downloading' | 'warming' | 'accessing_webcam' | 'loading_media' | 'loading_pose_model' | 'ready';
|
|
314
314
|
interface InitializationEvent {
|
|
315
315
|
type: 'initialization';
|
|
316
316
|
/**
|
|
@@ -359,7 +359,7 @@ interface ErrorEvent {
|
|
|
359
359
|
/** Unknown exercise id (WebView parity: `invalid_exercise`). */
|
|
360
360
|
| 'invalid_exercise'
|
|
361
361
|
/** jump_analysis requires `userHeightCm` (WebView parity). */
|
|
362
|
-
| 'jump_analysis_missing_height' | 'model_load_failed' | 'engine_load_failed' | 'integrity_check_failed' | 'webview_error' | 'device_too_slow' | 'backend_fallback_wasm' | 'camera_denied' | 'camera_unavailable' | 'internal';
|
|
362
|
+
| 'jump_analysis_missing_height' | 'model_load_failed' | 'engine_load_failed' | 'integrity_check_failed' | 'webview_error' | 'device_too_slow' | 'backend_fallback_wasm' | 'camera_denied' | 'camera_unavailable' | 'media_load_failed' | 'media_unavailable' | 'internal';
|
|
363
363
|
message: string;
|
|
364
364
|
}
|
|
365
365
|
/**
|
|
@@ -811,6 +811,52 @@ declare class UsageTracker {
|
|
|
811
811
|
private enqueue;
|
|
812
812
|
}
|
|
813
813
|
|
|
814
|
+
/**
|
|
815
|
+
* Input source for pose estimation (camera / uploaded video / still image).
|
|
816
|
+
* Default remains camera for quickstart compatibility.
|
|
817
|
+
*/
|
|
818
|
+
type PoseSourceType = 'camera' | 'video' | 'image';
|
|
819
|
+
type CameraFacingMode = 'user' | 'environment';
|
|
820
|
+
interface CameraPoseSource {
|
|
821
|
+
type: 'camera';
|
|
822
|
+
facingMode?: CameraFacingMode;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Uploaded or remote video. `src` may be a URL string, File/Blob (object URL),
|
|
826
|
+
* or an existing HTMLVideoElement (SDK uses it as the frame source).
|
|
827
|
+
*/
|
|
828
|
+
interface VideoPoseSource {
|
|
829
|
+
type: 'video';
|
|
830
|
+
src: string | File | Blob | HTMLVideoElement;
|
|
831
|
+
/** Autoplay when attached. Default true. */
|
|
832
|
+
autoplay?: boolean;
|
|
833
|
+
/** Loop the file. Default true for continuous inference demos. */
|
|
834
|
+
loop?: boolean;
|
|
835
|
+
muted?: boolean;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Still image — single-shot estimate (re-run via `analyze()`).
|
|
839
|
+
*/
|
|
840
|
+
interface ImagePoseSource {
|
|
841
|
+
type: 'image';
|
|
842
|
+
src: string | File | Blob | HTMLImageElement | ImageBitmap;
|
|
843
|
+
}
|
|
844
|
+
type PoseSource = CameraPoseSource | VideoPoseSource | ImagePoseSource;
|
|
845
|
+
/** Narrow helper for prop-style APIs (`source` + `sourceUrl` / `sourceFile`). */
|
|
846
|
+
interface PoseSourceProps {
|
|
847
|
+
source?: PoseSourceType;
|
|
848
|
+
sourceUrl?: string;
|
|
849
|
+
sourceFile?: File | Blob;
|
|
850
|
+
facingMode?: CameraFacingMode;
|
|
851
|
+
}
|
|
852
|
+
/** Frame types accepted by detector adapters. */
|
|
853
|
+
type PoseEstimateInput = HTMLVideoElement | HTMLImageElement | HTMLCanvasElement | ImageBitmap;
|
|
854
|
+
declare function normalizePoseSource(source?: PoseSource | PoseSourceType | null, extras?: {
|
|
855
|
+
sourceUrl?: string;
|
|
856
|
+
sourceFile?: File | Blob;
|
|
857
|
+
facingMode?: CameraFacingMode;
|
|
858
|
+
}): PoseSource;
|
|
859
|
+
|
|
814
860
|
/**
|
|
815
861
|
* Online pose-model catalog (web) — mirrors RN light `poseModels.ts`.
|
|
816
862
|
*
|
|
@@ -954,6 +1000,14 @@ interface PoseTrackerClientOptions extends ConfigureOptions {
|
|
|
954
1000
|
onDiagnostic?: (message: string) => void;
|
|
955
1001
|
/** Alias of preload coldStart when using start(). Default full on camera screens. */
|
|
956
1002
|
coldStart?: ColdStartMode;
|
|
1003
|
+
/**
|
|
1004
|
+
* Input source. Default `{ type: 'camera' }` (webcam).
|
|
1005
|
+
* Use `{ type: 'video', src }` or `{ type: 'image', src }` for file / URL / element.
|
|
1006
|
+
*/
|
|
1007
|
+
source?: PoseSource | PoseSourceType;
|
|
1008
|
+
/** Convenience with `source: 'video' | 'image'` (string / File / Blob). */
|
|
1009
|
+
sourceUrl?: string;
|
|
1010
|
+
sourceFile?: File | Blob;
|
|
957
1011
|
}
|
|
958
1012
|
/** @deprecated Prefer PoseTrackerClientOptions — kept for vanilla DX. */
|
|
959
1013
|
type PoseTrackerOptions = PoseTrackerClientOptions;
|
|
@@ -989,6 +1043,10 @@ declare class PoseTrackerClient {
|
|
|
989
1043
|
private opts;
|
|
990
1044
|
private shell;
|
|
991
1045
|
private stream;
|
|
1046
|
+
private poseSource;
|
|
1047
|
+
private objectUrlRevoke;
|
|
1048
|
+
private estimateInput;
|
|
1049
|
+
private imageShotPending;
|
|
992
1050
|
private adapter;
|
|
993
1051
|
private resolved;
|
|
994
1052
|
private running;
|
|
@@ -1013,6 +1071,8 @@ declare class PoseTrackerClient {
|
|
|
1013
1071
|
getAccelerationDiagnostics(): AccelerationDiagnostics;
|
|
1014
1072
|
getResolvedModel(): ResolvedPoseModel;
|
|
1015
1073
|
getColdStartMode(): ColdStartMode;
|
|
1074
|
+
/** Active pose input source (`camera` | `video` | `image`). */
|
|
1075
|
+
getSource(): PoseSource;
|
|
1016
1076
|
addEventListener(listener: PoseTrackerEventListener): () => void;
|
|
1017
1077
|
on(type: PoseTrackerEvent['type'] | '*', listener: PoseTrackerEventListener): () => void;
|
|
1018
1078
|
addMessageListener(listener: ClassicMessageListener): () => void;
|
|
@@ -1024,9 +1084,27 @@ declare class PoseTrackerClient {
|
|
|
1024
1084
|
*/
|
|
1025
1085
|
preload(options?: PreloadOptions): Promise<void>;
|
|
1026
1086
|
warmup(options?: PreloadOptions): Promise<void>;
|
|
1027
|
-
/**
|
|
1087
|
+
/**
|
|
1088
|
+
* Mount + load model + open source + start inference.
|
|
1089
|
+
* Camera / video stream continuously; image runs a single shot (re-run with {@link analyze}).
|
|
1090
|
+
*/
|
|
1028
1091
|
start(): Promise<void>;
|
|
1092
|
+
/**
|
|
1093
|
+
* Switch input source. Stops the current media, attaches the new source, and
|
|
1094
|
+
* restarts the loop when previously running.
|
|
1095
|
+
*/
|
|
1096
|
+
setSource(source: PoseSource | PoseSourceType, extras?: {
|
|
1097
|
+
sourceUrl?: string;
|
|
1098
|
+
sourceFile?: File | Blob;
|
|
1099
|
+
facingMode?: 'user' | 'environment';
|
|
1100
|
+
}): Promise<void>;
|
|
1101
|
+
/**
|
|
1102
|
+
* Re-run pose estimation on the current still image (no-op for camera/video
|
|
1103
|
+
* while the loop is already running — for those, call {@link start}).
|
|
1104
|
+
*/
|
|
1105
|
+
analyze(): Promise<Pose | null>;
|
|
1029
1106
|
stop(): void;
|
|
1107
|
+
private stopMediaOnly;
|
|
1030
1108
|
dispose(): Promise<void>;
|
|
1031
1109
|
configure(apiToken?: string): Promise<boolean>;
|
|
1032
1110
|
getAvailableExercises(): ExerciseConfig[];
|
|
@@ -1042,8 +1120,13 @@ declare class PoseTrackerClient {
|
|
|
1042
1120
|
private doPreload;
|
|
1043
1121
|
private ensureColdStartMode;
|
|
1044
1122
|
private ensureAdapter;
|
|
1045
|
-
private
|
|
1123
|
+
private ensureSource;
|
|
1124
|
+
private scheduleReveal;
|
|
1125
|
+
private attachVideoSource;
|
|
1126
|
+
private attachImageSource;
|
|
1046
1127
|
private beginLoop;
|
|
1128
|
+
private frameReady;
|
|
1129
|
+
private runOneFrame;
|
|
1047
1130
|
private loop;
|
|
1048
1131
|
private resolveSkeletonFromOptions;
|
|
1049
1132
|
private resolveManifestOnce;
|
|
@@ -1095,14 +1178,16 @@ interface DetectorFrameResult {
|
|
|
1095
1178
|
letterbox: Letterbox;
|
|
1096
1179
|
}
|
|
1097
1180
|
type Float32ArrayLike = ArrayLike<number>;
|
|
1181
|
+
|
|
1098
1182
|
interface PoseDetectorAdapter {
|
|
1099
1183
|
readonly modelId: string;
|
|
1100
1184
|
load(): Promise<void>;
|
|
1101
1185
|
/**
|
|
1102
|
-
* Run one frame.
|
|
1186
|
+
* Run one frame. Input must have non-zero dimensions
|
|
1187
|
+
* (HTMLVideoElement, HTMLImageElement, canvas, or ImageBitmap).
|
|
1103
1188
|
* Returns null when the frame should be skipped.
|
|
1104
1189
|
*/
|
|
1105
|
-
estimate(
|
|
1190
|
+
estimate(input: PoseEstimateInput, options: {
|
|
1106
1191
|
facingMode: 'user' | 'environment';
|
|
1107
1192
|
displayWidth: number;
|
|
1108
1193
|
displayHeight: number;
|
|
@@ -1133,7 +1218,7 @@ declare class MoveNetGraphAdapter implements PoseDetectorAdapter {
|
|
|
1133
1218
|
private poseCanvasCtx;
|
|
1134
1219
|
private prepareInput;
|
|
1135
1220
|
private smooth;
|
|
1136
|
-
estimate(
|
|
1221
|
+
estimate(input: PoseEstimateInput, options: {
|
|
1137
1222
|
facingMode: 'user' | 'environment';
|
|
1138
1223
|
displayWidth: number;
|
|
1139
1224
|
displayHeight: number;
|
|
@@ -1162,7 +1247,7 @@ declare class BlazePoseAdapter implements PoseDetectorAdapter {
|
|
|
1162
1247
|
constructor(_ctx: CreateAdapterContext);
|
|
1163
1248
|
getBackend(): string | null;
|
|
1164
1249
|
load(): Promise<void>;
|
|
1165
|
-
estimate(
|
|
1250
|
+
estimate(input: PoseEstimateInput, options: {
|
|
1166
1251
|
facingMode: 'user' | 'environment';
|
|
1167
1252
|
displayWidth: number;
|
|
1168
1253
|
displayHeight: number;
|
|
@@ -1266,6 +1351,8 @@ declare function drawSkeleton(ctx: CanvasRenderingContext2D, kps: DrawKeypoint[]
|
|
|
1266
1351
|
interface DomShell {
|
|
1267
1352
|
root: HTMLElement;
|
|
1268
1353
|
video: HTMLVideoElement;
|
|
1354
|
+
/** Still-image element for `source: image` mode. */
|
|
1355
|
+
image: HTMLImageElement;
|
|
1269
1356
|
canvas: HTMLCanvasElement;
|
|
1270
1357
|
boot: HTMLElement;
|
|
1271
1358
|
bootMsg: HTMLElement;
|
|
@@ -1274,10 +1361,12 @@ interface DomShell {
|
|
|
1274
1361
|
placement: HTMLElement;
|
|
1275
1362
|
setBootMessage(text: string, isError?: boolean): void;
|
|
1276
1363
|
setCameraVisible(visible: boolean): void;
|
|
1364
|
+
/** Show video preview, still image, or neither (boot only). */
|
|
1365
|
+
setMediaMode(mode: 'video' | 'image' | 'none'): void;
|
|
1277
1366
|
setWatermarkVisible(visible: boolean): void;
|
|
1278
1367
|
setHud(text: string, debug: boolean): void;
|
|
1279
1368
|
setPlacementVisible(visible: boolean, paddingPercent?: number): void;
|
|
1280
|
-
applyMirror(facingMode: 'user' | 'environment'): void;
|
|
1369
|
+
applyMirror(facingMode: 'user' | 'environment' | 'none'): void;
|
|
1281
1370
|
destroy(): void;
|
|
1282
1371
|
}
|
|
1283
1372
|
declare function mountDomShell(host: HTMLElement, options?: {
|
|
@@ -1322,4 +1411,4 @@ declare function findExerciseByIdOrAlias<T extends {
|
|
|
1322
1411
|
id: string;
|
|
1323
1412
|
}>(exerciseId: string, exercises: readonly T[]): T | undefined;
|
|
1324
1413
|
|
|
1325
|
-
export { type AccelerationDiagnostics, type AccelerationState, type AngleValue, type AnglesEvent, BRAND_COLORS, BlazePoseAdapter, type BlazePoseModelType, COCO_KEYPOINT_NAMES, COMBINED_REFERENCE_EXERCISE_MESSAGE, type CameraOptions, type ClassicMessageListener, type ClassicNativeMessage, type CocoKeypointName, type ColdStartMode, ConfigureError, type ConfigureOptions, type ConfigureRequest, type CounterEvent, type CounterFormScore, type CustomExerciseDescriptor, type CustomSessionOptions, DEFAULT_BASE_URL, DEFAULT_FEATURES, DEFAULT_LOADING_TEXT, DEFAULT_MOVENET_LIGHTNING_URL, DEFAULT_SKELETON, DEFAULT_SKELETON_DEFINITION, type DetectorFrameResult, type DiagnosticListener, EXERCISE_ALIASES, type EngineBundleDescriptor, type EngineLoadResult, EngineLoader, type EngineLoaderOptions, type EngineSession, type EngineSessionFeatures, type EngineSessionOptions, type ErrorEvent, type EventSink, type ExerciseConfig, type ExerciseSummaryEvent, FREE_PLAN_FEATURES_MESSAGE, type FetchSkeletonOptions, type FileStore, type FormGrade, type FormScoreEvent, INVALID_TOKEN_MESSAGE, type InferenceRuntime, type InitialPosture, type InitializationEvent, type InitializationStep, type JumpCalibrationEvent, type JumpDiscardedEvent, type JumpHeightEvent, type JumpResultEvent, type JumpStartedEvent, type JumpSummaryEntry, type JumpSummaryEvent, type KeyValueStore, type Keypoint, type KeypointName, type KeypointsEvent, type MinGrade, type ModelDescriptor, type ModelFormat, type ModelsByProfile, MoveNetGraphAdapter, type MovementDefinition, type MovementRecommendation, type MovementStep, type MovementStepParameter, ONLINE_POSE_DETECTION_VERSION, ONLINE_TFJS_VERSION, POSETRACKER_LOGO_URL, type PerformanceWarningEvent, type PlanInfo, type Pose, PoseCamera, PoseCamera_mount, type PoseDetectionModule, type PoseDetectorAdapter, type PoseModelAlias, type PoseModelKind, type PoseModelProfile, type PoseRuntimeDescriptor, type PoseRuntimePartDescriptor, type PoseTracker, type PoseTrackerCallbacks, PoseTrackerClient, type PoseTrackerClientOptions, type PoseTrackerEngine, type PoseTrackerEvent, type PoseTrackerEventListener, type PoseTrackerEventType, type PoseTrackerFeatures, type PoseTrackerMode, type PoseTrackerOptions, type PoseTrackerStatus, type PostureEvent, type PreloadOptions, type ProgressionEvent, type QualityChangedEvent, type RecommendationsEvent, type ReferenceMovementDescriptor, type RepSummary, type ResolvePoseModelOptions, type ResolvedFeatures, type ResolvedPoseModel, type RuntimeDownloadProgressEvent, SDK_NAME, SDK_VERSION, type SdkManifest, type SkeletonAnglesStyle, type SkeletonCirclesStyle, type SkeletonDefinition, SkeletonFetchError, type SkeletonLinesStyle, type StartExerciseOptions, type StatsEvent, type TfModule, type TfjsCdnUrls, TrackError, type TrackRequest, type TrackResponse, UsageTracker, type UsageTrackerOptions, type VisibleHipsInfo, type WarningEvent, configure, createLocalFileStore, createLocalKeyValueStore, createMemoryFileStore, createPoseAdapter, createPoseTracker, createWebFileStore, defaultPoseDetectionCdnUrl, defaultTfjsCdnUrls, drawSkeleton, featureNotSupportedMessage, fetchSkeletonDefinition, findExerciseByIdOrAlias, freeBlockedFeatures, initWebGlBackend, isPaidPlan, mapVideoKeypointsToDisplay, mountDomShell, openCameraStream, resolveExerciseName, resolveFeatures, resolvePoseDetection, resolvePoseModel, resolveTf, shouldShowWatermark, stopMediaStream, toClassicNativeMessage };
|
|
1414
|
+
export { type AccelerationDiagnostics, type AccelerationState, type AngleValue, type AnglesEvent, BRAND_COLORS, BlazePoseAdapter, type BlazePoseModelType, COCO_KEYPOINT_NAMES, COMBINED_REFERENCE_EXERCISE_MESSAGE, type CameraFacingMode, type CameraOptions, type CameraPoseSource, type ClassicMessageListener, type ClassicNativeMessage, type CocoKeypointName, type ColdStartMode, ConfigureError, type ConfigureOptions, type ConfigureRequest, type CounterEvent, type CounterFormScore, type CustomExerciseDescriptor, type CustomSessionOptions, DEFAULT_BASE_URL, DEFAULT_FEATURES, DEFAULT_LOADING_TEXT, DEFAULT_MOVENET_LIGHTNING_URL, DEFAULT_SKELETON, DEFAULT_SKELETON_DEFINITION, type DetectorFrameResult, type DiagnosticListener, EXERCISE_ALIASES, type EngineBundleDescriptor, type EngineLoadResult, EngineLoader, type EngineLoaderOptions, type EngineSession, type EngineSessionFeatures, type EngineSessionOptions, type ErrorEvent, type EventSink, type ExerciseConfig, type ExerciseSummaryEvent, FREE_PLAN_FEATURES_MESSAGE, type FetchSkeletonOptions, type FileStore, type FormGrade, type FormScoreEvent, INVALID_TOKEN_MESSAGE, type ImagePoseSource, type InferenceRuntime, type InitialPosture, type InitializationEvent, type InitializationStep, type JumpCalibrationEvent, type JumpDiscardedEvent, type JumpHeightEvent, type JumpResultEvent, type JumpStartedEvent, type JumpSummaryEntry, type JumpSummaryEvent, type KeyValueStore, type Keypoint, type KeypointName, type KeypointsEvent, type MinGrade, type ModelDescriptor, type ModelFormat, type ModelsByProfile, MoveNetGraphAdapter, type MovementDefinition, type MovementRecommendation, type MovementStep, type MovementStepParameter, ONLINE_POSE_DETECTION_VERSION, ONLINE_TFJS_VERSION, POSETRACKER_LOGO_URL, type PerformanceWarningEvent, type PlanInfo, type Pose, PoseCamera, PoseCamera_mount, type PoseDetectionModule, type PoseDetectorAdapter, type PoseEstimateInput, type PoseModelAlias, type PoseModelKind, type PoseModelProfile, type PoseRuntimeDescriptor, type PoseRuntimePartDescriptor, type PoseSource, type PoseSourceProps, type PoseSourceType, type PoseTracker, type PoseTrackerCallbacks, PoseTrackerClient, type PoseTrackerClientOptions, type PoseTrackerEngine, type PoseTrackerEvent, type PoseTrackerEventListener, type PoseTrackerEventType, type PoseTrackerFeatures, type PoseTrackerMode, type PoseTrackerOptions, type PoseTrackerStatus, type PostureEvent, type PreloadOptions, type ProgressionEvent, type QualityChangedEvent, type RecommendationsEvent, type ReferenceMovementDescriptor, type RepSummary, type ResolvePoseModelOptions, type ResolvedFeatures, type ResolvedPoseModel, type RuntimeDownloadProgressEvent, SDK_NAME, SDK_VERSION, type SdkManifest, type SkeletonAnglesStyle, type SkeletonCirclesStyle, type SkeletonDefinition, SkeletonFetchError, type SkeletonLinesStyle, type StartExerciseOptions, type StatsEvent, type TfModule, type TfjsCdnUrls, TrackError, type TrackRequest, type TrackResponse, UsageTracker, type UsageTrackerOptions, type VideoPoseSource, type VisibleHipsInfo, type WarningEvent, configure, createLocalFileStore, createLocalKeyValueStore, createMemoryFileStore, createPoseAdapter, createPoseTracker, createWebFileStore, defaultPoseDetectionCdnUrl, defaultTfjsCdnUrls, drawSkeleton, featureNotSupportedMessage, fetchSkeletonDefinition, findExerciseByIdOrAlias, freeBlockedFeatures, initWebGlBackend, isPaidPlan, mapVideoKeypointsToDisplay, mountDomShell, normalizePoseSource, openCameraStream, resolveExerciseName, resolveFeatures, resolvePoseDetection, resolvePoseModel, resolveTf, shouldShowWatermark, stopMediaStream, toClassicNativeMessage };
|