@microblink/camera-manager 7.0.0-next.9 → 7.0.1
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 +75 -5
- package/dist/camera-manager.js +1645 -1024
- package/package.json +6 -6
- package/types/core/Camera.d.ts +40 -2
- package/types/core/Camera.d.ts.map +1 -1
- package/types/core/CameraManager.d.ts +42 -39
- package/types/core/CameraManager.d.ts.map +1 -1
- package/types/core/VideoFrameProcessor.d.ts +61 -0
- package/types/core/VideoFrameProcessor.d.ts.map +1 -0
- package/types/core/cameraManagerStore.d.ts +2 -1
- package/types/core/cameraManagerStore.d.ts.map +1 -1
- package/types/core/cameraNames.d.ts.map +1 -1
- package/types/core/cameraUtils.d.ts +14 -7
- package/types/core/cameraUtils.d.ts.map +1 -1
- package/types/core/utils.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/index.rollup.d.ts +182 -42
- package/types/media-mock/MediaMocker.d.ts +4 -779
- package/types/media-mock/MediaMocker.d.ts.map +1 -1
- package/types/media-mock/createInputDeviceInfo.d.ts.map +1 -1
- package/types/media-mock/fake-devices.d.ts +1 -788
- package/types/media-mock/fake-devices.d.ts.map +1 -1
- package/types/media-mock/fakeDevices/SamsungS21FE.d.ts +6 -0
- package/types/media-mock/fakeDevices/SamsungS21FE.d.ts.map +1 -0
- package/types/media-mock/fakeDevices/iPhone15.d.ts +6 -0
- package/types/media-mock/fakeDevices/iPhone15.d.ts.map +1 -0
- package/types/media-mock/fakeDevices/iPhoneSE.d.ts +9 -0
- package/types/media-mock/fakeDevices/iPhoneSE.d.ts.map +1 -0
- package/types/media-mock/utils.d.ts +4 -0
- package/types/media-mock/utils.d.ts.map +1 -1
- package/types/ui/CameraErrorModal.d.ts +7 -0
- package/types/ui/CameraErrorModal.d.ts.map +1 -0
- package/types/ui/CameraSelector.d.ts.map +1 -1
- package/types/ui/CameraUiStoreContext.d.ts +15 -2
- package/types/ui/CameraUiStoreContext.d.ts.map +1 -1
- package/types/ui/CaptureScreen.d.ts +2 -0
- package/types/ui/CaptureScreen.d.ts.map +1 -1
- package/types/ui/Header.d.ts.map +1 -1
- package/types/ui/RootComponent.d.ts.map +1 -1
- package/types/ui/SolidShadowRoot.d.ts +1 -12
- package/types/ui/SolidShadowRoot.d.ts.map +1 -1
- package/types/ui/createCameraManagerUi.d.ts +16 -8
- package/types/ui/createCameraManagerUi.d.ts.map +1 -1
- package/types/ui/determineFitMode.d.ts +35 -0
- package/types/ui/determineFitMode.d.ts.map +1 -0
- package/types/ui/determineFitMode.test.d.ts +5 -0
- package/types/ui/determineFitMode.test.d.ts.map +1 -0
- package/types/ui/getVisibleVideoArea.d.ts +10 -0
- package/types/ui/getVisibleVideoArea.d.ts.map +1 -0
- package/types/ui/getVisibleVideoArea.test.d.ts +5 -0
- package/types/ui/getVisibleVideoArea.test.d.ts.map +1 -0
- package/types/ui/locales/en.d.ts +7 -1
- package/types/ui/locales/en.d.ts.map +1 -1
- package/types/ui/zustandRefStore.d.ts +2 -0
- package/types/ui/zustandRefStore.d.ts.map +1 -1
- package/types/core/createCustomImageData.d.ts +0 -14
- package/types/core/createCustomImageData.d.ts.map +0 -1
- package/types/core/imageDataUtils.d.ts +0 -6
- package/types/core/imageDataUtils.d.ts.map +0 -1
- package/types/core/videoToImageData.d.ts +0 -5
- package/types/core/videoToImageData.d.ts.map +0 -1
- package/types/ui/ErrorAlert.d.ts +0 -8
- package/types/ui/ErrorAlert.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,78 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @microblink/camera-manager
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
It doesn't do any processing on its own, and isn't dependent on any SDK.
|
|
3
|
+
This package provides camera management for web applications. It handles camera selection, permissions, video stream management, and provides access to video frames for further processing. It is framework-agnostic and can be used with or without a UI.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
## Overview
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
- Handles camera selection, permissions, and video stream lifecycle.
|
|
8
|
+
- Provides access to video frames for downstream processing.
|
|
9
|
+
- Can be used standalone or with the included UI components.
|
|
10
|
+
- Used by [`@microblink/blinkid-ux-manager`](https://www.npmjs.com/package/@microblink/blinkid-ux-manager) and [`@microblink/blinkid`](https://www.npmjs.com/package/@microblink/blinkid).
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Install from npm using your preferred package manager:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @microblink/camera-manager
|
|
18
|
+
# or
|
|
19
|
+
yarn add @microblink/camera-manager
|
|
20
|
+
# or
|
|
21
|
+
pnpm add @microblink/camera-manager
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Basic Example
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { CameraManager } from "@microblink/camera-manager";
|
|
30
|
+
|
|
31
|
+
const cameraManager = new CameraManager();
|
|
32
|
+
|
|
33
|
+
// Start the camera stream (auto-selects the best camera)
|
|
34
|
+
await cameraManager.startCameraStream();
|
|
35
|
+
|
|
36
|
+
// Optionally, attach the video to a DOM element
|
|
37
|
+
const video = document.getElementById("video");
|
|
38
|
+
cameraManager.initVideoElement(video);
|
|
39
|
+
|
|
40
|
+
// Capture frames for processing
|
|
41
|
+
const removeCallback = cameraManager.addFrameCaptureCallback((imageData) => {
|
|
42
|
+
// Process imageData (instance of ImageData)
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Stop the camera when done
|
|
46
|
+
cameraManager.stopStream();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
See the [`camera-manager` example](../../apps/examples/camera-manager/src/App.tsx) for more usage details.
|
|
50
|
+
|
|
51
|
+
## API
|
|
52
|
+
|
|
53
|
+
### `CameraManager` class
|
|
54
|
+
|
|
55
|
+
- `startCameraStream(options?)`: Starts the camera stream. Options allow selecting a specific camera or facing mode.
|
|
56
|
+
- `initVideoElement(videoElement)`: Attaches a video element for preview.
|
|
57
|
+
- `addFrameCaptureCallback(callback)`: Registers a callback to receive frames as `ImageData` during capture. Returns a cleanup function.
|
|
58
|
+
- `startFrameCapture()`: Starts capturing frames for processing.
|
|
59
|
+
- `stopFrameCapture()`: Stops capturing frames but keeps the stream active.
|
|
60
|
+
- `stopStream()`: Stops the camera stream and video playback.
|
|
61
|
+
- `setResolution(resolution)`: Sets the desired video resolution (e.g., `"1080p"`).
|
|
62
|
+
- `setFacingFilter(facingModes)`: Filters available cameras by facing mode (`"front"` or `"back"`).
|
|
63
|
+
- `getCameraDevices()`: Returns available camera devices.
|
|
64
|
+
- `selectCamera(camera)`: Selects a specific camera device.
|
|
65
|
+
- `setCameraMirrorX(mirrorX)`: Mirrors the video horizontally if needed.
|
|
66
|
+
- `reset()`: Resets the camera manager and stops all streams.
|
|
67
|
+
|
|
68
|
+
### UI Integration
|
|
69
|
+
|
|
70
|
+
To use the built-in UI, use:
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
import { createCameraManagerUi } from "@microblink/camera-manager";
|
|
74
|
+
|
|
75
|
+
const cameraUi = await createCameraManagerUi(cameraManager, document.body);
|
|
76
|
+
// Optionally, add cleanup:
|
|
77
|
+
cameraUi.dismount();
|
|
78
|
+
```
|