@pose-tracker/react-native-pose-estimation-light 0.3.4 → 0.3.6

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.
@@ -0,0 +1,53 @@
1
+ /**
2
+ * External frames: the host app owns the camera and the preview, and pushes
3
+ * frames to {@link PoseTrackerClient.processFrame}. The SDK infers, runs the
4
+ * active exercise engine, and returns data. It draws nothing.
5
+ */
6
+
7
+ import type { PoseTrackerEvent } from './events';
8
+ import type { Pose } from './pose';
9
+
10
+ export interface ExternalFrame {
11
+ /** Encoded image (JPEG / PNG) without the `data:` prefix. */
12
+ base64?: string;
13
+ /** `file://`, `data:` or `https:` URL the WebView can load. */
14
+ uri?: string;
15
+ /** Width of the frame you send. Keep the longest side at 256 px or less. */
16
+ width: number;
17
+ height: number;
18
+ /** Capture time of the frame. The exercise engine uses it for timing. */
19
+ timestampMs: number;
20
+ /**
21
+ * Mirror keypoints horizontally, as for a selfie preview. Default `true`.
22
+ * Pass `false` for a back camera or an unmirrored preview.
23
+ */
24
+ mirrored?: boolean;
25
+ /** MIME type of `base64`. Default `image/jpeg`. */
26
+ mime?: string;
27
+ }
28
+
29
+ export interface ExternalFrameResult {
30
+ /** True when a previous frame was still running. Nothing was inferred. */
31
+ dropped: boolean;
32
+ /**
33
+ * Pose for this frame, or the last pose when `dropped`. Keypoints are
34
+ * normalized 0–1 to the frame you sent.
35
+ */
36
+ pose: Pose | null;
37
+ /**
38
+ * Events produced by this frame (keypoints, counter, posture, angles,
39
+ * form score, …), in emission order. They are also delivered to the
40
+ * existing listeners. Empty when `dropped`.
41
+ */
42
+ events: PoseTrackerEvent[];
43
+ }
44
+
45
+ export function isExternalFrame(frame: unknown): frame is ExternalFrame {
46
+ if (frame == null || typeof frame !== 'object') return false;
47
+ const f = frame as Partial<ExternalFrame>;
48
+ return (
49
+ (typeof f.base64 === 'string' || typeof f.uri === 'string') &&
50
+ typeof f.width === 'number' &&
51
+ typeof f.height === 'number'
52
+ );
53
+ }