@meeeetup/camera-react-native 0.4.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/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ Copyright (c) 2026 MeeeetUp1120. All rights reserved.
2
+
3
+ PROPRIETARY SOFTWARE LICENCE
4
+
5
+ The `@meeeetup1120/core`, `@meeeetup1120/web` and `@meeeetup1120/react-native`
6
+ packages (the "Software") are proprietary to MeeeetUp1120.
7
+
8
+ Permission to use, copy and integrate the Software into your own application is
9
+ granted solely to parties holding a current written agreement with MeeeetUp1120
10
+ covering the Meeeetup face-identification service, and only for the purpose of
11
+ interoperating with that service. No other rights are granted.
12
+
13
+ You may not, without prior written permission from MeeeetUp1120:
14
+
15
+ - redistribute, sublicense, sell or lease the Software;
16
+ - modify, reverse-engineer, decompile or disassemble the Software, or create
17
+ derivative works from it, except as permitted by applicable law;
18
+ - remove or alter this notice or any copyright notice in the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23
+ MEEEETUP1120 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+
27
+ Third-party components retain their own licences. In particular the Software
28
+ loads `@mediapipe/tasks-vision` and its face-detection model at runtime, which
29
+ are licensed by Google under the Apache License 2.0.
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # @meeeetup/camera-react-native
2
+
3
+ React Native face-capture SDK for the Meeeetup face-ID service. Face detection
4
+ runs on the camera's worklet thread through a native Vision Camera frame
5
+ processor (ML Kit), and the results feed the shared tracking and
6
+ quality-selection pipeline.
7
+
8
+ **Transport is yours.** The SDK never makes a network request and never holds a
9
+ credential: it calls `onBatchCapture` with base64 JPEG data URLs, and sending
10
+ them is your code. No HTTP client, no credential storage, no pairing UI.
11
+
12
+ You own the `<Camera>` element and its ref; the hook owns the pipeline.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pnpm add @meeeetup/camera-react-native
18
+ pnpm add react-native-vision-camera react-native-vision-camera-face-detector
19
+ pnpm add react-native-worklets-core react-native-fs
20
+ ```
21
+
22
+ `@meeeetup/camera-core` arrives as a dependency. For Expo, swap `pnpm add` for
23
+ `npx expo install` on the four native packages.
24
+
25
+ | Peer | Range | Why |
26
+ |---|---|---|
27
+ | `react` | `^18 \|\| ^19` | Hook host |
28
+ | `react-native` | `>=0.73.0` | `NativeModules` / new-arch support |
29
+ | `react-native-vision-camera` | `>=4.0.0` | `<Camera>`, `useFrameProcessor`, `runAtTargetFps` |
30
+ | `react-native-vision-camera-face-detector` | `>=1.10.0` | Native ML Kit detector |
31
+ | `react-native-worklets-core` | `>=1.5.0` | Worklet → JS hop |
32
+ | `react-native-fs` | `>=2.20.0` | Reads the cached snapshot as base64 |
33
+
34
+ `react-native-fs` is not optional: without it the hook reports
35
+ `"react-native-fs is required as a peer dependency"` through `error` and never
36
+ caches a JPEG, so no face is ever committed.
37
+
38
+ Frame processors also need Vision Camera's worklets Babel plugin — follow
39
+ `react-native-vision-camera`'s frame-processor setup for
40
+ `react-native-worklets-core` first.
41
+
42
+ Permissions: `android.permission.CAMERA` in `AndroidManifest.xml`,
43
+ `NSCameraUsageDescription` in `Info.plist`.
44
+
45
+ ## Usage
46
+
47
+ ```tsx
48
+ import { useRef } from "react";
49
+ import { useWindowDimensions } from "react-native";
50
+ import { Camera, useCameraDevice } from "react-native-vision-camera";
51
+ import { useFaceCaptureSession } from "@meeeetup/camera-react-native";
52
+
53
+ function CaptureScreen({ captureKey }: { captureKey: string }) {
54
+ const camera = useRef<Camera>(null);
55
+ const device = useCameraDevice("front");
56
+ const { width, height } = useWindowDimensions();
57
+
58
+ const { ready, error, trackedCount, frameProcessor } = useFaceCaptureSession({
59
+ cameraRef: camera,
60
+ sessionType: "passive",
61
+ // Preview size in px — makes the native detector emit window-space
62
+ // coordinates, so detections line up with the preview.
63
+ windowWidth: width,
64
+ windowHeight: height,
65
+ cameraFacing: "front",
66
+ onBatchCapture: async (faces) => {
67
+ const res = await fetch("https://api.example.com/capture", {
68
+ method: "POST",
69
+ headers: {
70
+ Authorization: `Bearer ${captureKey}`,
71
+ "Content-Type": "application/json",
72
+ },
73
+ body: JSON.stringify({
74
+ images: faces.map((f) => ({
75
+ image: f.dataUrl,
76
+ capturedAt: new Date(f.createdAt).toISOString(),
77
+ })),
78
+ }),
79
+ });
80
+ // Throw to report failure. A missing status, <400 or >=500 is retried;
81
+ // 4xx drops that batch.
82
+ if (!res.ok) throw Object.assign(new Error("send failed"), { status: res.status });
83
+ },
84
+ });
85
+
86
+ if (!device) return null;
87
+
88
+ return (
89
+ <Camera
90
+ ref={camera}
91
+ device={device}
92
+ isActive
93
+ photo
94
+ frameProcessor={frameProcessor}
95
+ style={{ flex: 1 }}
96
+ />
97
+ );
98
+ }
99
+ ```
100
+
101
+ `photo` must stay enabled: the hook falls back to `takePhoto()` on cameras that
102
+ do not expose `takeSnapshot()`.
103
+
104
+ `sessionType: "interactive"` runs the same pipeline without the batch timer —
105
+ call `flushBatch()` yourself. Either way, a flush only hands over faces whose
106
+ track has settled for more than 5 s, so a still-improving track is never sent
107
+ early.
108
+
109
+ ## Exports
110
+
111
+ `useFaceCaptureSession`, `RNFrameBuffer`, `facesToDetections`,
112
+ `FaceCaptureSession`, plus the `Detection`, `FrameBuffer`, `SelectedFace`,
113
+ `NoseLandmark`, `CameraLike`, `VisionCameraFace`,
114
+ `UseFaceCaptureSessionOptions` and `UseFaceCaptureSessionReturn` types.
115
+
116
+ ## Licence
117
+
118
+ Proprietary — see `LICENSE`. Use requires a current agreement with MeeeetUp1120.
@@ -0,0 +1,44 @@
1
+ import type { Detection } from "@meeeetup/camera-core";
2
+ /**
3
+ * Minimal shape of a face returned by `react-native-vision-camera-face-detector`.
4
+ * Landmarks are optional and coordinates are in pixel space of the frame.
5
+ */
6
+ export interface VisionCameraFace {
7
+ bounds: {
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ };
13
+ landmarks?: {
14
+ LEFT_EYE?: {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ RIGHT_EYE?: {
19
+ x: number;
20
+ y: number;
21
+ };
22
+ NOSE_BASE?: {
23
+ x: number;
24
+ y: number;
25
+ };
26
+ };
27
+ }
28
+ /**
29
+ * Convert `react-native-vision-camera-face-detector` `Face[]` into the SDK's
30
+ * `Detection[]` contract.
31
+ *
32
+ * - Coordinates are normalised from pixel space to 0–1 using the frame dimensions.
33
+ * - Keypoint slot ordering matches the SDK contract: `[0]=rightEye, [1]=leftEye, [2]=nose*`.
34
+ * - ML Kit does not expose a distinct `noseTip` landmark, only `NOSE_BASE`. That is
35
+ * put in slot `[2]`; call `getFrontalness()` with `noseLandmark: "noseBase"` so
36
+ * the vertical-tilt formula uses the correct reference ratio.
37
+ * - Faces missing any of the three required landmarks are **dropped** rather than
38
+ * filled with synthetic keypoints — synthetic keypoints falsely score as perfectly
39
+ * frontal and cause the wrong frames to commit.
40
+ *
41
+ * This function is a pure data mapper — safe to call from a worklet OR the JS thread.
42
+ */
43
+ export declare function facesToDetections(faces: VisionCameraFace[], frameWidth: number, frameHeight: number): Detection[];
44
+ //# sourceMappingURL=vision-camera-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vision-camera-detector.d.ts","sourceRoot":"","sources":["../../src/detectors/vision-camera-detector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,SAAS,CAAC,EAAE;QACV,QAAQ,CAAC,EAAG;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACrC,SAAS,CAAC,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACrC,SAAS,CAAC,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KACtC,CAAC;CACH;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,gBAAgB,EAAE,EACzB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,SAAS,EAAE,CA2Bb"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.facesToDetections = facesToDetections;
4
+ /**
5
+ * Convert `react-native-vision-camera-face-detector` `Face[]` into the SDK's
6
+ * `Detection[]` contract.
7
+ *
8
+ * - Coordinates are normalised from pixel space to 0–1 using the frame dimensions.
9
+ * - Keypoint slot ordering matches the SDK contract: `[0]=rightEye, [1]=leftEye, [2]=nose*`.
10
+ * - ML Kit does not expose a distinct `noseTip` landmark, only `NOSE_BASE`. That is
11
+ * put in slot `[2]`; call `getFrontalness()` with `noseLandmark: "noseBase"` so
12
+ * the vertical-tilt formula uses the correct reference ratio.
13
+ * - Faces missing any of the three required landmarks are **dropped** rather than
14
+ * filled with synthetic keypoints — synthetic keypoints falsely score as perfectly
15
+ * frontal and cause the wrong frames to commit.
16
+ *
17
+ * This function is a pure data mapper — safe to call from a worklet OR the JS thread.
18
+ */
19
+ function facesToDetections(faces, frameWidth, frameHeight) {
20
+ const out = [];
21
+ for (const face of faces) {
22
+ const lm = face.landmarks;
23
+ const rightEyeRaw = lm?.RIGHT_EYE;
24
+ const leftEyeRaw = lm?.LEFT_EYE;
25
+ const noseRaw = lm?.NOSE_BASE;
26
+ if (!rightEyeRaw || !leftEyeRaw || !noseRaw)
27
+ continue;
28
+ const b = face.bounds;
29
+ out.push({
30
+ boundingBox: {
31
+ originX: b.x / frameWidth,
32
+ originY: b.y / frameHeight,
33
+ width: b.width / frameWidth,
34
+ height: b.height / frameHeight,
35
+ },
36
+ keypoints: [
37
+ { x: rightEyeRaw.x / frameWidth, y: rightEyeRaw.y / frameHeight },
38
+ { x: leftEyeRaw.x / frameWidth, y: leftEyeRaw.y / frameHeight },
39
+ { x: noseRaw.x / frameWidth, y: noseRaw.y / frameHeight },
40
+ ],
41
+ score: 1,
42
+ });
43
+ }
44
+ return out;
45
+ }
46
+ //# sourceMappingURL=vision-camera-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vision-camera-detector.js","sourceRoot":"","sources":["../../src/detectors/vision-camera-detector.ts"],"names":[],"mappings":";;AA8BA,8CA+BC;AA9CD;;;;;;;;;;;;;;GAcG;AACH,SAAgB,iBAAiB,CAC/B,KAAyB,EACzB,UAAkB,EAClB,WAAmB;IAEnB,MAAM,GAAG,GAAgB,EAAE,CAAC;IAC5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAC1B,MAAM,WAAW,GAAG,EAAE,EAAE,SAAS,CAAC;QAClC,MAAM,UAAU,GAAI,EAAE,EAAE,QAAQ,CAAC;QACjC,MAAM,OAAO,GAAO,EAAE,EAAE,SAAS,CAAC;QAElC,IAAI,CAAC,WAAW,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO;YAAE,SAAS;QAEtD,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,GAAG,CAAC,IAAI,CAAC;YACP,WAAW,EAAE;gBACX,OAAO,EAAE,CAAC,CAAC,CAAC,GAAQ,UAAU;gBAC9B,OAAO,EAAE,CAAC,CAAC,CAAC,GAAQ,WAAW;gBAC/B,KAAK,EAAI,CAAC,CAAC,KAAK,GAAI,UAAU;gBAC9B,MAAM,EAAG,CAAC,CAAC,MAAM,GAAG,WAAW;aAChC;YACD,SAAS,EAAE;gBACT,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,WAAW,EAAE;gBACjE,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,GAAI,UAAU,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,GAAI,WAAW,EAAE;gBACjE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,GAAO,UAAU,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,GAAO,WAAW,EAAE;aAClE;YACD,KAAK,EAAE,CAAC;SACT,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { FrameBuffer } from "@meeeetup/camera-core";
2
+ /**
3
+ * React Native FrameBuffer backed by a base64 JPEG string already captured
4
+ * from a Vision Camera snapshot or frame processor output.
5
+ *
6
+ * Vision Camera v4 exposes `frame.toArrayBuffer()` in frame processors.
7
+ * For simplicity this implementation wraps a pre-captured JPEG base64 string.
8
+ * See RNFrameProcessor for the frame-processor variant.
9
+ */
10
+ export declare class RNFrameBuffer implements FrameBuffer {
11
+ private readonly jpegBase64;
12
+ readonly width: number;
13
+ readonly height: number;
14
+ constructor(jpegBase64: string, width: number, height: number);
15
+ toJpegBase64(_quality?: number): string;
16
+ /**
17
+ * On React Native we return the full frame as the crop — actual pixel-level
18
+ * cropping happens server-side via AWS Rekognition's bounding-box analysis.
19
+ * For higher accuracy, wire up react-native-skia to perform the crop natively.
20
+ */
21
+ cropFaceJpeg(_cx: number, _cy: number, _bw: number, _bh: number, _quality?: number): string | null;
22
+ }
23
+ //# sourceMappingURL=frame-buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame-buffer.d.ts","sourceRoot":"","sources":["../src/frame-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;GAOG;AACH,qBAAa,aAAc,YAAW,WAAW;IAE7C,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAFN,UAAU,EAAE,MAAM,EAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM;IAGzB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAIvC;;;;OAIG;IACH,YAAY,CACV,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI;CAKjB"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RNFrameBuffer = void 0;
4
+ /**
5
+ * React Native FrameBuffer backed by a base64 JPEG string already captured
6
+ * from a Vision Camera snapshot or frame processor output.
7
+ *
8
+ * Vision Camera v4 exposes `frame.toArrayBuffer()` in frame processors.
9
+ * For simplicity this implementation wraps a pre-captured JPEG base64 string.
10
+ * See RNFrameProcessor for the frame-processor variant.
11
+ */
12
+ class RNFrameBuffer {
13
+ constructor(jpegBase64, width, height) {
14
+ this.jpegBase64 = jpegBase64;
15
+ this.width = width;
16
+ this.height = height;
17
+ }
18
+ toJpegBase64(_quality) {
19
+ return this.jpegBase64;
20
+ }
21
+ /**
22
+ * On React Native we return the full frame as the crop — actual pixel-level
23
+ * cropping happens server-side via AWS Rekognition's bounding-box analysis.
24
+ * For higher accuracy, wire up react-native-skia to perform the crop natively.
25
+ */
26
+ cropFaceJpeg(_cx, _cy, _bw, _bh, _quality) {
27
+ // TODO: use react-native-skia for pixel-accurate crop
28
+ // For now return the full frame — Rekognition will handle the crop server-side
29
+ return this.jpegBase64;
30
+ }
31
+ }
32
+ exports.RNFrameBuffer = RNFrameBuffer;
33
+ //# sourceMappingURL=frame-buffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame-buffer.js","sourceRoot":"","sources":["../src/frame-buffer.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACH,MAAa,aAAa;IACxB,YACmB,UAAkB,EAC1B,KAAa,EACb,MAAc;QAFN,eAAU,GAAV,UAAU,CAAQ;QAC1B,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAQ;IACtB,CAAC;IAEJ,YAAY,CAAC,QAAiB;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,YAAY,CACV,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW,EACX,QAAiB;QAEjB,sDAAsD;QACtD,+EAA+E;QAC/E,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AA3BD,sCA2BC"}
@@ -0,0 +1,6 @@
1
+ export type { Detection, FrameBuffer, SelectedFace, NoseLandmark } from "@meeeetup/camera-core";
2
+ export { FaceCaptureSession } from "@meeeetup/camera-core";
3
+ export { RNFrameBuffer } from "./frame-buffer";
4
+ export { facesToDetections, type VisionCameraFace } from "./detectors/vision-camera-detector";
5
+ export { useFaceCaptureSession, type UseFaceCaptureSessionOptions, type UseFaceCaptureSessionReturn, type CameraLike, } from "./useFaceCaptureSession";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EACL,qBAAqB,EACrB,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,UAAU,GAChB,MAAM,yBAAyB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFaceCaptureSession = exports.facesToDetections = exports.RNFrameBuffer = exports.FaceCaptureSession = void 0;
4
+ var camera_core_1 = require("@meeeetup/camera-core");
5
+ Object.defineProperty(exports, "FaceCaptureSession", { enumerable: true, get: function () { return camera_core_1.FaceCaptureSession; } });
6
+ // React Native
7
+ var frame_buffer_1 = require("./frame-buffer");
8
+ Object.defineProperty(exports, "RNFrameBuffer", { enumerable: true, get: function () { return frame_buffer_1.RNFrameBuffer; } });
9
+ var vision_camera_detector_1 = require("./detectors/vision-camera-detector");
10
+ Object.defineProperty(exports, "facesToDetections", { enumerable: true, get: function () { return vision_camera_detector_1.facesToDetections; } });
11
+ var useFaceCaptureSession_1 = require("./useFaceCaptureSession");
12
+ Object.defineProperty(exports, "useFaceCaptureSession", { enumerable: true, get: function () { return useFaceCaptureSession_1.useFaceCaptureSession; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,qDAA2D;AAAlD,iHAAA,kBAAkB,OAAA;AAE3B,eAAe;AACf,+CAA+C;AAAtC,6GAAA,aAAa,OAAA;AACtB,6EAA8F;AAArF,2HAAA,iBAAiB,OAAA;AAC1B,iEAKiC;AAJ/B,8HAAA,qBAAqB,OAAA"}
@@ -0,0 +1,139 @@
1
+ import { type Detection, type FaceCaptureSessionOptions } from "@meeeetup/camera-core";
2
+ import { type ReadonlyFrameProcessor } from "react-native-vision-camera";
3
+ import { type Face } from "react-native-vision-camera-face-detector";
4
+ /**
5
+ * Minimal shape of the Vision Camera `Camera` methods we call. Keeping the SDK
6
+ * decoupled from the concrete class lets consumers pass their own ref type.
7
+ */
8
+ export interface CameraLike {
9
+ takePhoto(options?: {
10
+ flash?: "off" | "auto" | "on";
11
+ enableShutterSound?: boolean;
12
+ }): Promise<{
13
+ path: string;
14
+ width: number;
15
+ height: number;
16
+ }>;
17
+ /**
18
+ * GPU screenshot of the preview view (Vision Camera v4). Much cheaper and
19
+ * smaller than `takePhoto()` — preferred when available.
20
+ */
21
+ takeSnapshot?(options?: {
22
+ quality?: number;
23
+ }): Promise<{
24
+ path: string;
25
+ width: number;
26
+ height: number;
27
+ }>;
28
+ }
29
+ export interface UseFaceCaptureSessionOptions extends Omit<FaceCaptureSessionOptions, "noseLandmark"> {
30
+ /**
31
+ * Ref to the Vision Camera `<Camera>` component. Used to snapshot a
32
+ * high-quality JPEG in the background so tracker commits carry a
33
+ * fresh crop without paying `takePhoto()` cost per frame.
34
+ */
35
+ cameraRef: React.RefObject<CameraLike | null>;
36
+ /**
37
+ * Detection cadence — the frame processor is throttled to this rate.
38
+ * Detection latency is native, so 15 fps is smooth on mid-range devices.
39
+ * Default: 15.
40
+ */
41
+ detectionFps?: number;
42
+ /**
43
+ * How often to refresh the cached photo JPEG (ms). Fresher means committed
44
+ * faces are more likely to match the peak frame. Uses `takeSnapshot()` when
45
+ * the camera exposes it (cheap GPU screenshot), else `takePhoto()`.
46
+ * Default: 1000ms (fresh enough given the 10s batch cadence).
47
+ */
48
+ photoCadenceMs?: number;
49
+ /**
50
+ * JPEG quality (0–100) for the cached snapshot. Only applies when the
51
+ * camera supports `takeSnapshot`. Default: 60 — keeps batch payloads small.
52
+ */
53
+ snapshotQuality?: number;
54
+ /**
55
+ * Preview view size in px. When provided, the native detector runs in
56
+ * `autoMode`: bounds and landmarks are rotated, mirrored (front camera),
57
+ * and scaled to window coordinates on the native side, and `lastDetections`
58
+ * are normalised against the window — so overlays map 1:1 onto the preview.
59
+ * Strongly recommended; without it, coordinates are raw sensor-space.
60
+ */
61
+ windowWidth?: number;
62
+ windowHeight?: number;
63
+ /**
64
+ * Which camera the preview is using — required for correct mirroring in
65
+ * `autoMode`. Default: "front".
66
+ */
67
+ cameraFacing?: "front" | "back" | "external";
68
+ }
69
+ export interface SnapshotInfo {
70
+ /** `file://` URI of the latest cached preview snapshot. */
71
+ uri: string;
72
+ /** Snapshot pixel dimensions. */
73
+ width: number;
74
+ height: number;
75
+ /** Unix ms when the snapshot was taken. */
76
+ takenAt: number;
77
+ }
78
+ export interface UseFaceCaptureSessionReturn {
79
+ /** True once the session has been constructed and the first frame processor is live. */
80
+ ready: boolean;
81
+ /** Last error from either photo capture or detection. */
82
+ error: string | null;
83
+ /** Number of currently active face tracks. */
84
+ trackedCount: number;
85
+ /** Latest detections in normalised coordinates — for UI overlays. */
86
+ lastDetections: Detection[];
87
+ /**
88
+ * Latest cached snapshot the tracker crops from. On Android `takeSnapshot`
89
+ * screenshots the preview view, so its pixels align 1:1 with the same
90
+ * window coordinates `lastDetections` are normalised against — useful for
91
+ * debug crop views.
92
+ */
93
+ lastSnapshot: SnapshotInfo | null;
94
+ /**
95
+ * Per-stage latency of the last processed detection frame — for debugging
96
+ * where the detect→render gap comes from.
97
+ */
98
+ lastTimings: PipelineTimings | null;
99
+ /** Attach this to the `<Camera />` `frameProcessor` prop. */
100
+ frameProcessor: ReadonlyFrameProcessor;
101
+ /** Flush any settled faces to `onBatchCapture` immediately. */
102
+ flushBatch: () => Promise<void>;
103
+ }
104
+ export interface PipelineTimings {
105
+ /** ML Kit inference duration inside the worklet (ms). */
106
+ detectMs: number;
107
+ /** Worklet → JS thread hop + queue wait (ms). */
108
+ bridgeMs: number;
109
+ /** Frame dimensions the detector actually ran on. */
110
+ frameWidth: number;
111
+ frameHeight: number;
112
+ }
113
+ /**
114
+ * React Native SDK hook — native face detection via Vision Camera frame processor.
115
+ *
116
+ * Pipeline per frame (runs on the native worklet thread):
117
+ * 1. `detectFaces(frame)` — ML Kit face detection, ~5–10ms native
118
+ * 2. Faces marshal to JS via `runOnJS`
119
+ * 3. Convert to normalised `Detection[]`
120
+ * 4. Feed `session.processDetections()` with the latest cached JPEG
121
+ *
122
+ * A background loop calls `camera.takePhoto()` every `photoCadenceMs` to keep
123
+ * a recent JPEG cached — that JPEG is what the tracker attaches to committed
124
+ * faces. No per-frame disk write, no per-frame base64 encode.
125
+ *
126
+ * @example
127
+ * ```tsx
128
+ * const camera = useRef<Camera>(null);
129
+ * const { frameProcessor, trackedCount } = useFaceCaptureSession({
130
+ * cameraRef: camera,
131
+ * sessionType: "passive",
132
+ * onBatchCapture: async (faces) => { await sendBatch(faces); },
133
+ * });
134
+ * <Camera ref={camera} device={device} isActive photo frameProcessor={frameProcessor} />
135
+ * ```
136
+ */
137
+ export declare function useFaceCaptureSession(opts: UseFaceCaptureSessionOptions): UseFaceCaptureSessionReturn;
138
+ export type { Face };
139
+ //# sourceMappingURL=useFaceCaptureSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFaceCaptureSession.d.ts","sourceRoot":"","sources":["../src/useFaceCaptureSession.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,yBAAyB,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAqC,KAAK,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC5G,OAAO,EAAmB,KAAK,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAYtF;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,OAAO,CAAC,EAAE;QAClB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;QAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG,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SAAS,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC;;;OAGG;IACH,WAAW,EAAE,eAAe,GAAG,IAAI,CAAC;IACpC,6DAA6D;IAC7D,cAAc,EAAE,sBAAsB,CAAC;IACvC,+DAA+D;IAC/D,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,4BAA4B,GACjC,2BAA2B,CA8M7B;AAID,YAAY,EAAE,IAAI,EAAE,CAAC"}
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFaceCaptureSession = useFaceCaptureSession;
4
+ const react_1 = require("react");
5
+ const camera_core_1 = require("@meeeetup/camera-core");
6
+ const react_native_vision_camera_1 = require("react-native-vision-camera");
7
+ const react_native_vision_camera_face_detector_1 = require("react-native-vision-camera-face-detector");
8
+ const react_native_worklets_core_1 = require("react-native-worklets-core");
9
+ const react_native_1 = require("react-native");
10
+ const frame_buffer_1 = require("./frame-buffer");
11
+ const vision_camera_detector_1 = require("./detectors/vision-camera-detector");
12
+ const RNFS = react_native_1.NativeModules.RNFSManager
13
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
14
+ ? require("react-native-fs")
15
+ : null;
16
+ /**
17
+ * React Native SDK hook — native face detection via Vision Camera frame processor.
18
+ *
19
+ * Pipeline per frame (runs on the native worklet thread):
20
+ * 1. `detectFaces(frame)` — ML Kit face detection, ~5–10ms native
21
+ * 2. Faces marshal to JS via `runOnJS`
22
+ * 3. Convert to normalised `Detection[]`
23
+ * 4. Feed `session.processDetections()` with the latest cached JPEG
24
+ *
25
+ * A background loop calls `camera.takePhoto()` every `photoCadenceMs` to keep
26
+ * a recent JPEG cached — that JPEG is what the tracker attaches to committed
27
+ * faces. No per-frame disk write, no per-frame base64 encode.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * const camera = useRef<Camera>(null);
32
+ * const { frameProcessor, trackedCount } = useFaceCaptureSession({
33
+ * cameraRef: camera,
34
+ * sessionType: "passive",
35
+ * onBatchCapture: async (faces) => { await sendBatch(faces); },
36
+ * });
37
+ * <Camera ref={camera} device={device} isActive photo frameProcessor={frameProcessor} />
38
+ * ```
39
+ */
40
+ function useFaceCaptureSession(opts) {
41
+ const [ready, setReady] = (0, react_1.useState)(false);
42
+ const [error, setError] = (0, react_1.useState)(null);
43
+ const [trackedCount, setTrackedCount] = (0, react_1.useState)(0);
44
+ const [lastDetections, setLastDetections] = (0, react_1.useState)([]);
45
+ const [lastSnapshot, setLastSnapshot] = (0, react_1.useState)(null);
46
+ const [lastTimings, setLastTimings] = (0, react_1.useState)(null);
47
+ // Latest opts + refs used inside callbacks
48
+ const optsRef = (0, react_1.useRef)(opts);
49
+ (0, react_1.useEffect)(() => { optsRef.current = opts; }, [opts]);
50
+ const sessionRef = (0, react_1.useRef)(null);
51
+ const photoCacheRef = (0, react_1.useRef)(null);
52
+ // ── Session lifecycle ─────────────────────────────────────────────────────
53
+ (0, react_1.useEffect)(() => {
54
+ const session = new camera_core_1.FaceCaptureSession({
55
+ sessionType: opts.sessionType,
56
+ batchIntervalMs: opts.batchIntervalMs,
57
+ maxBufferedFaces: opts.maxBufferedFaces,
58
+ maxFacesPerRequest: opts.maxFacesPerRequest,
59
+ cooldownMs: opts.cooldownMs,
60
+ // ML Kit gives noseBase, not noseTip — compensate.
61
+ noseLandmark: "noseBase",
62
+ onSelect: (face) => optsRef.current.onSelect?.(face),
63
+ onTrackRemoved: (id) => optsRef.current.onTrackRemoved?.(id),
64
+ onBatchSent: (n) => optsRef.current.onBatchSent?.(n),
65
+ onBatchError: (e) => optsRef.current.onBatchError?.(e),
66
+ onBatchCapture: (fs) => optsRef.current.onBatchCapture?.(fs),
67
+ });
68
+ sessionRef.current = session;
69
+ setReady(true);
70
+ const tickInterval = setInterval(() => {
71
+ session.tick();
72
+ setTrackedCount(session.trackedCount);
73
+ }, 100);
74
+ return () => {
75
+ clearInterval(tickInterval);
76
+ session.dispose();
77
+ sessionRef.current = null;
78
+ photoCacheRef.current = null;
79
+ setReady(false);
80
+ setTrackedCount(0);
81
+ };
82
+ // eslint-disable-next-line react-hooks/exhaustive-deps
83
+ }, []);
84
+ // ── Background photo capture loop ─────────────────────────────────────────
85
+ // Fresh JPEG feeds the tracker's `pendingJpeg` slot; each face committed
86
+ // during the ~1s window since the last refresh carries this crop.
87
+ (0, react_1.useEffect)(() => {
88
+ if (!ready)
89
+ return;
90
+ if (!RNFS) {
91
+ setError("react-native-fs is required as a peer dependency");
92
+ return;
93
+ }
94
+ let alive = true;
95
+ let capturing = false;
96
+ const cadence = opts.photoCadenceMs ?? 1000;
97
+ // Ring of recent snapshot files. Keep the last 2 so the file a consumer's
98
+ // <Image> is currently displaying is never deleted under it.
99
+ const recentPaths = [];
100
+ async function refresh() {
101
+ const cam = optsRef.current.cameraRef.current;
102
+ if (!cam || capturing)
103
+ return;
104
+ capturing = true;
105
+ try {
106
+ const photo = cam.takeSnapshot
107
+ ? await cam.takeSnapshot({ quality: optsRef.current.snapshotQuality ?? 60 })
108
+ : await cam.takePhoto({ flash: "off", enableShutterSound: false });
109
+ const base64 = await RNFS.readFile(photo.path, "base64");
110
+ if (!alive)
111
+ return;
112
+ photoCacheRef.current = {
113
+ jpeg: `data:image/jpeg;base64,${base64}`,
114
+ width: photo.width,
115
+ height: photo.height,
116
+ };
117
+ // Expose the file URI, not the base64 blob — consumers pass it to
118
+ // <Image>, and a file URI avoids marshalling 100s of KB per update.
119
+ setLastSnapshot({
120
+ uri: photo.path.startsWith("file://") ? photo.path : `file://${photo.path}`,
121
+ width: photo.width,
122
+ height: photo.height,
123
+ takenAt: Date.now(),
124
+ });
125
+ recentPaths.push(photo.path);
126
+ // Keep ~2s of files: a consumer's <Image> may still be decoding or
127
+ // displaying an older snapshot — deleting it mid-display blanks the
128
+ // view (visible blink).
129
+ while (recentPaths.length > 6) {
130
+ const stale = recentPaths.shift();
131
+ RNFS.unlink(stale).catch(() => { }); // best-effort temp cleanup
132
+ }
133
+ }
134
+ catch (err) {
135
+ if (alive)
136
+ setError(err instanceof Error ? err.message : "Photo capture failed");
137
+ }
138
+ finally {
139
+ capturing = false;
140
+ }
141
+ }
142
+ const interval = setInterval(() => { void refresh(); }, cadence);
143
+ void refresh(); // seed the cache
144
+ return () => {
145
+ alive = false;
146
+ clearInterval(interval);
147
+ for (const p of recentPaths)
148
+ RNFS.unlink(p).catch(() => { });
149
+ };
150
+ }, [ready, opts.photoCadenceMs]);
151
+ // ── Frame processor ────────────────────────────────────────────────────────
152
+ // `autoMode` rotates, mirrors (front camera) and scales bounds + landmarks to
153
+ // window coordinates on the native side. Without window dims we fall back to
154
+ // raw sensor-space coordinates (overlays will NOT line up with the preview).
155
+ const { windowWidth, windowHeight, cameraFacing } = opts;
156
+ const autoMode = windowWidth != null && windowHeight != null;
157
+ const detectorConfig = (0, react_1.useMemo)(() => ({
158
+ performanceMode: "fast",
159
+ landmarkMode: "all",
160
+ contourMode: "none",
161
+ classificationMode: "none",
162
+ // 0.3 = face must span ≥30% of frame width. Larger minimum → ML Kit
163
+ // scans far fewer pyramid levels → substantially faster inference.
164
+ // Capture use cases have subjects near the camera, so this is safe.
165
+ minFaceSize: 0.3,
166
+ autoMode,
167
+ windowWidth: windowWidth ?? 1.0,
168
+ windowHeight: windowHeight ?? 1.0,
169
+ cameraFacing: cameraFacing ?? "front",
170
+ }), [autoMode, windowWidth, windowHeight, cameraFacing]);
171
+ const { detectFaces } = (0, react_native_vision_camera_face_detector_1.useFaceDetector)(detectorConfig);
172
+ // Stable identity — everything it touches is a ref or a stable setter.
173
+ // Recreating this per render would recreate (and re-register) the frame
174
+ // processor worklet at render rate, which is pathologically slow.
175
+ const handleFaces = (0, react_1.useMemo)(() => react_native_worklets_core_1.Worklets.createRunOnJS((faces, frameWidth, frameHeight, detectMs, sentAt) => {
176
+ setLastTimings({
177
+ detectMs: Math.round(detectMs),
178
+ bridgeMs: Math.round(Date.now() - sentAt),
179
+ frameWidth,
180
+ frameHeight,
181
+ });
182
+ // In autoMode the plugin emits window-space pixels — normalise against
183
+ // the window so overlays map 1:1. Otherwise fall back to frame dims.
184
+ const { windowWidth: ww, windowHeight: wh } = optsRef.current;
185
+ const detections = ww != null && wh != null
186
+ ? (0, vision_camera_detector_1.facesToDetections)(faces, ww, wh)
187
+ : (0, vision_camera_detector_1.facesToDetections)(faces, frameWidth, frameHeight);
188
+ // Skip no-op empty→empty updates so an idle camera doesn't re-render.
189
+ setLastDetections((prev) => prev.length === 0 && detections.length === 0 ? prev : detections);
190
+ const session = sessionRef.current;
191
+ const cache = photoCacheRef.current;
192
+ if (!session || !cache)
193
+ return; // no JPEG yet — wait for first refresh
194
+ if (detections.length === 0)
195
+ return;
196
+ const frame = new frame_buffer_1.RNFrameBuffer(cache.jpeg, cache.width, cache.height);
197
+ session.processDetections(detections, frame);
198
+ }), []);
199
+ // Vision Camera v4 removed the `frameProcessorFps` prop — throttling is done
200
+ // inside the worklet. Without this, ML Kit runs at full camera fps and
201
+ // detection latency compounds into multi-second lag.
202
+ const detectionFps = opts.detectionFps ?? 15;
203
+ const frameProcessor = (0, react_native_vision_camera_1.useFrameProcessor)((frame) => {
204
+ "worklet";
205
+ (0, react_native_vision_camera_1.runAtTargetFps)(detectionFps, () => {
206
+ "worklet";
207
+ const t0 = Date.now();
208
+ const faces = detectFaces(frame);
209
+ const t1 = Date.now();
210
+ handleFaces(faces, frame.width, frame.height, t1 - t0, t1);
211
+ });
212
+ }, [handleFaces, detectFaces, detectionFps]);
213
+ const flushBatch = (0, react_1.useCallback)(() => sessionRef.current?.flushBatch() ?? Promise.resolve(), []);
214
+ return { ready, error, trackedCount, lastDetections, lastSnapshot, lastTimings, frameProcessor, flushBatch };
215
+ }
216
+ //# sourceMappingURL=useFaceCaptureSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFaceCaptureSession.js","sourceRoot":"","sources":["../src/useFaceCaptureSession.ts"],"names":[],"mappings":";;AA2JA,sDAgNC;AA3WD,iCAA0E;AAC1E,uDAI+B;AAC/B,2EAA4G;AAC5G,uGAAsF;AACtF,2EAAsD;AACtD,+CAA6C;AAE7C,iDAA+C;AAC/C,+EAA8F;AAE9F,MAAM,IAAI,GAAG,4BAAa,CAAC,WAAW;IACpC,iEAAiE;IACjE,CAAC,CAAE,OAAO,CAAC,iBAAiB,CAAsC;IAClE,CAAC,CAAC,IAAI,CAAC;AAkHT;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,qBAAqB,CACnC,IAAkC;IAElC,MAAM,CAAC,KAAK,EAAW,QAAQ,CAAC,GAAY,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAC5D,MAAM,CAAC,KAAK,EAAW,QAAQ,CAAC,GAAY,IAAA,gBAAQ,EAAgB,IAAI,CAAC,CAAC;IAC1E,MAAM,CAAC,YAAY,EAAI,eAAe,CAAC,GAAK,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IACxD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAc,EAAE,CAAC,CAAC;IACtE,MAAM,CAAC,YAAY,EAAI,eAAe,CAAC,GAAK,IAAA,gBAAQ,EAAsB,IAAI,CAAC,CAAC;IAChF,MAAM,CAAC,WAAW,EAAK,cAAc,CAAC,GAAM,IAAA,gBAAQ,EAAyB,IAAI,CAAC,CAAC;IAEnF,2CAA2C;IAC3C,MAAM,OAAO,GAAI,IAAA,cAAM,EAAC,IAAI,CAAC,CAAC;IAC9B,IAA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4
+ "description": "React Native SDK for meeeetup-cam — Vision Camera + native ML Kit frame processor",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md",
10
+ "LICENSE"
11
+ ],
12
+ "publishConfig": {
13
+ "registry": "https://registry.npmjs.org",
14
+ "access": "public"
15
+ },
16
+ "dependencies": {
17
+ "@meeeetup/camera-core": "0.4.0"
18
+ },
19
+ "peerDependencies": {
20
+ "react": "^18 || ^19",
21
+ "react-native": ">=0.73.0",
22
+ "react-native-vision-camera": ">=4.0.0",
23
+ "react-native-vision-camera-face-detector": ">=1.10.0",
24
+ "react-native-worklets-core": ">=1.5.0",
25
+ "react-native-fs": ">=2.20.0"
26
+ },
27
+ "devDependencies": {
28
+ "@types/react": "^19.0.0",
29
+ "react": "^19.0.0",
30
+ "react-native": "^0.86.0",
31
+ "react-native-vision-camera": "^4.0.0",
32
+ "react-native-vision-camera-face-detector": "^1.10.2",
33
+ "react-native-worklets-core": "^1.6.3",
34
+ "react-native-fs": "^2.20.0",
35
+ "typescript": "^5.7.2"
36
+ },
37
+ "license": "SEE LICENSE IN LICENSE",
38
+ "homepage": "https://id.meeeetup.com",
39
+ "scripts": {
40
+ "build": "tsc -p tsconfig.json",
41
+ "typecheck": "tsc --noEmit"
42
+ }
43
+ }