Skip to content

demo: Face blur example #2743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 241 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
241 commits
Select commit Hold shift + click to select a range
dd4c8fb
feat: Give V4 🫴
mrousavy Feb 23, 2024
3618fa0
Update to compile SDK 34
mrousavy Feb 23, 2024
295d914
fix kotlin error
mrousavy Feb 23, 2024
bf0e411
fix ui thread
mrousavy Feb 23, 2024
1031be3
Run all on Main Thread
mrousavy Feb 23, 2024
d87c8b5
Update lifecycle
mrousavy Feb 23, 2024
afae30d
Take Photo?
mrousavy Feb 23, 2024
045162f
Type Camera Errors
mrousavy Feb 23, 2024
23a334d
Unbind before starting bind
mrousavy Feb 23, 2024
5b60fc4
Create Recording base?
mrousavy Feb 23, 2024
532837d
Add `photoQualityBalance` to iOS
mrousavy Feb 26, 2024
e17eb50
feat: Add `takeSnapshot()` to `PreviewView`
mrousavy Feb 26, 2024
f0fb942
Add new API
mrousavy Feb 26, 2024
a89f72b
Low Light Boost throttles
mrousavy Feb 26, 2024
08d86d4
feat: Add CodeScanner pipeline (`ImageAnalysis`)
mrousavy Feb 26, 2024
e889192
Format
mrousavy Feb 26, 2024
49e2620
Remove outputs
mrousavy Feb 26, 2024
b57ac46
Update CameraSession.kt
mrousavy Feb 26, 2024
5b63ac4
Call back with Video result
mrousavy Feb 26, 2024
2db5c99
Delete `RecordingSession`
mrousavy Feb 26, 2024
00d4479
Configure zoom and torch
mrousavy Feb 26, 2024
a880ab0
Only update torch, zoom or exposure if needed
mrousavy Feb 26, 2024
d4275ca
Create `takeSnapshot()`
mrousavy Feb 26, 2024
6b33339
Use `compressionQuality`
mrousavy Feb 26, 2024
c5d3688
Format
mrousavy Feb 26, 2024
708d95d
Catch CameraErrors directly
mrousavy Feb 26, 2024
b752e5b
Use new API for Snapshot
mrousavy Feb 26, 2024
0c53379
Throw `.fileError`
mrousavy Feb 26, 2024
fb4628a
fix temp filename
mrousavy Feb 26, 2024
a638b66
fix: Implement `takeSnaphot` on iOS
mrousavy Feb 26, 2024
82a70f0
Update Camera.tsx
mrousavy Feb 26, 2024
f770e11
Don't re-initialize outputs if only inputId changes
mrousavy Feb 26, 2024
e39fc25
Update CameraSession.kt
mrousavy Feb 26, 2024
2a2d2db
Update CameraSession.kt
mrousavy Feb 26, 2024
4404455
Use photo/video size selectors
mrousavy Feb 26, 2024
d8dbd53
fix: Use runOnUiThread only if needed
mrousavy Feb 26, 2024
202e8ec
Code org
mrousavy Feb 26, 2024
e5e4d39
Update CameraSession.kt
mrousavy Feb 26, 2024
b9a0434
feat: Use HDR or NIGHT extensions if available
mrousavy Feb 26, 2024
cb2f1c3
fix: Check for ImageAnalysis support
mrousavy Feb 26, 2024
7b46390
feat: Shutter sound and stabilization
mrousavy Feb 26, 2024
372f922
Update CameraSession.kt
mrousavy Feb 26, 2024
71b6de3
restructure Threading a bit
mrousavy Feb 27, 2024
ec8e080
Restructure Threading in CameraSession, configure is UI Thread
mrousavy Feb 27, 2024
fbf843e
Update CameraSession.kt
mrousavy Feb 27, 2024
6a1e146
Update CameraSession.kt
mrousavy Feb 27, 2024
6e22a02
Better `mainExecutor`
mrousavy Feb 27, 2024
6d2952b
Implement `focus()`
mrousavy Feb 27, 2024
adead1c
Use file type
mrousavy Feb 27, 2024
0aeec61
Make `VideoPipeline` a CameraX use-case
mrousavy Feb 27, 2024
310d52b
Update CameraQueues.kt
mrousavy Feb 27, 2024
668dbf4
Update VideoPipeline.kt
mrousavy Feb 27, 2024
00155c9
feat: Implement native HardwareBuffer rendering for `VideoPipeline`
mrousavy Feb 27, 2024
4530f58
Try use VideoPipeline
mrousavy Feb 27, 2024
52fa376
Try extending ImageAnalysis
mrousavy Feb 27, 2024
747c588
Create `FrameProcessorEffect` as camera middleman
mrousavy Feb 28, 2024
62ccd25
Use PREVIEW output
mrousavy Feb 28, 2024
dd895a7
fix not running FP for PREVIEW
mrousavy Feb 28, 2024
8bb8e12
Update FrameProcessorEffect.kt
mrousavy Feb 28, 2024
d0eb702
feat: Allow setting custom format in ImageWriter
mrousavy Feb 28, 2024
9f8ec73
Restructure code a bit
mrousavy Feb 28, 2024
d18e8ee
Make everything synchronized
mrousavy Feb 28, 2024
b923f81
Make `FrameProcessorEffect` closeable
mrousavy Feb 28, 2024
185265b
chore: Clean up Codebase
mrousavy Feb 28, 2024
93527a2
Don't re-create Recorder if actively recording
mrousavy Feb 28, 2024
158de70
docs: Update docs for `qualityBalance`
mrousavy Feb 28, 2024
b64204e
Update CameraProps.ts
mrousavy Feb 28, 2024
b63d9c7
Remove OpenGL VideoPipeline (now CameraX does that)
mrousavy Feb 28, 2024
4f95d20
Properly disable CameraSession when `isActive=false`
mrousavy Feb 28, 2024
15504af
Remove a few Errors
mrousavy Feb 28, 2024
d08c0b0
chore: release 4.0.0-beta.0
mrousavy Feb 29, 2024
f88d8f8
chore: release 4.0.0-beta.1
mrousavy Feb 29, 2024
e135b3b
fix: Rename to `qualityBalance`
mrousavy Feb 29, 2024
b578e52
Update package.json
mrousavy Feb 29, 2024
660ea6d
Small changes
mrousavy Feb 29, 2024
4325d14
Update CameraView.kt
mrousavy Feb 29, 2024
c75494a
Throw focus-canceled
mrousavy Feb 29, 2024
7edd2a2
Implement `onStarted` and `onStopped` for Android again
mrousavy Feb 29, 2024
7e96fec
Always activate Camera lifecycle, ignore `isAttachedToWindow`
mrousavy Feb 29, 2024
dd49365
feat: Add `onShutter` event
mrousavy Feb 29, 2024
e855706
chore: release 4.0.0-beta.2
mrousavy Feb 29, 2024
c6e55ac
fix: Fix optional delegate
mrousavy Feb 29, 2024
ac0f457
Update CameraError.kt
mrousavy Feb 29, 2024
f51921b
feat: Add `cancelRecording`
mrousavy Feb 29, 2024
6be6784
chore: release 4.0.0-beta.3
mrousavy Feb 29, 2024
ec6026e
Add `Preview` docs
mrousavy Feb 29, 2024
dd56925
feat: Add `androidPreviewViewType` prop
mrousavy Feb 29, 2024
54997a2
feat: Use CameraX for device details (#2624)
mrousavy Mar 1, 2024
4016d53
Update CameraDeviceDetails.kt
mrousavy Mar 1, 2024
a4a78e9
feat: Properly get orientation and isMirrored in FP
mrousavy Mar 1, 2024
f36d304
fix: Properly close `ImageWriter`
mrousavy Mar 1, 2024
fd1b118
fix: Fix transform matrix
mrousavy Mar 1, 2024
0a415f3
fix: Use image transformation info from input surface
mrousavy Mar 1, 2024
c741c90
fix: Capture directly in lambda
mrousavy Mar 1, 2024
e4a5fe3
fix: Fix focus not running on UI Thread
mrousavy Mar 1, 2024
28be6c7
chore: release 4.0.0-beta.4
mrousavy Mar 1, 2024
b4a9086
fix: Fix calling `sendAvailableDevicesChangedEvent` before module is …
mrousavy Mar 4, 2024
17feff3
fix: Allow re-creating if session changed from outside
mrousavy Mar 4, 2024
f5c0131
fix: Don't play shutter sound unless explicitly enabled
mrousavy Mar 4, 2024
7ec53f7
fix: Allow catching errors in `.await()`
mrousavy Mar 4, 2024
72c8c1b
feat: Remove `enableAutoStabilization` prop as this was deprecated in…
mrousavy Mar 6, 2024
6be93af
fix: Export `Snapshot.ts`
mrousavy Mar 7, 2024
f721d97
feat: Add `type` to `onShutter` (`photo` or `snapshot`)
mrousavy Mar 7, 2024
50f47c5
fix: Only unbind current outputs, not all
mrousavy Mar 8, 2024
5daf70e
chore: Lint/Fix
mrousavy Mar 8, 2024
9cd9b90
chore: release 4.0.0-beta.5
mrousavy Mar 8, 2024
a57d640
fix: Use dummy metering factory instead of display-oriented
mrousavy Mar 11, 2024
aac2162
fix: Remove unneeded context
mrousavy Mar 11, 2024
a9093cf
fix: Fix rotation getting
mrousavy Mar 11, 2024
43cb8d5
Update Podfile.lock
mrousavy Mar 11, 2024
79d4554
fix: Check format requirements in outputs
mrousavy Mar 12, 2024
8ad08f3
fix: Remove `not-compatible-with-outputs` error on Android since Came…
mrousavy Mar 13, 2024
5119639
fix: Remove `didSessionChangeFromOutside`
mrousavy Mar 13, 2024
c1f274f
fix: Catch Objective-C errors in iOS Frame Processor Plugins
mrousavy Mar 13, 2024
fa21983
feat: Catch Objective-C init errors on plugin init
mrousavy Mar 13, 2024
5283020
fix: Fix `TimeoutException` by using `STARTED` lifecycle
mrousavy Mar 14, 2024
e293605
chore: release 4.0.0-beta.6
mrousavy Mar 14, 2024
462fb6e
add todo about hdr extension bug
mrousavy Mar 18, 2024
2611625
fix: Remove focus listeners after resetting
mrousavy Mar 18, 2024
3d68d74
fix: Fix capture session configuration error by manually layouting Pr…
mrousavy Mar 18, 2024
babed3c
feat: Write proper photo metadata (orientation & isMirrored) (#2660)
mrousavy Mar 18, 2024
ad746d5
fix: Fix Camera not starting because PreviewView isn't laid out
mrousavy Mar 18, 2024
1682bb2
fix: Use `CREATED` as default lifecycle state
mrousavy Mar 18, 2024
19a7b0c
fix: Fix 10-bit HDR in combination with HDR Extension
mrousavy Mar 18, 2024
be251f5
Update CameraSession.kt
mrousavy Mar 18, 2024
5fe7608
fix: Throw correct errors
mrousavy Mar 18, 2024
211783a
fix: Properly check SDR
mrousavy Mar 18, 2024
27a4f85
fix: Update outputs if video stabilization or low-light-boost changes
mrousavy Mar 18, 2024
5525f2b
fix: Also dont enable if other extension is enabled
mrousavy Mar 18, 2024
89aef72
chore: release 4.0.0-beta.7
mrousavy Mar 18, 2024
12d72c9
Update package.json
mrousavy Mar 19, 2024
ca6518f
feat: Basic read-only Frame Processors (`ImageAnalysis` Use-Case) (#2…
mrousavy Mar 19, 2024
7f14f25
fix: Properly set `maxPhotoDimensions` on PhotoOutput (#2659)
mrousavy Mar 19, 2024
6418cdd
chore: release 4.0.0-beta.8
mrousavy Mar 19, 2024
3e8a1b7
Update CameraSession+Photo.swift
mrousavy Mar 19, 2024
f794d48
fix: Fix focus on Android by using PX instead of DP (#2666)
kirillzyusko Mar 20, 2024
7f57a2f
Merge branch 'main' into v4
mrousavy Mar 21, 2024
1e01f43
Optimised images with calibre/image-actions
github-actions[bot] Mar 21, 2024
c8033dd
feat: Add GPS Location EXIF tagging for photos and videos (`enableLoc…
mrousavy Mar 21, 2024
4c0fa92
Optimised images with calibre/image-actions
github-actions[bot] Mar 21, 2024
3f113e8
fix: Remove HardwareBufferUtils
mrousavy Mar 21, 2024
e434696
Merge branch 'v4' of https://github.com/mrousavy/react-native-vision-…
mrousavy Mar 21, 2024
c0e3a14
fix: Fix CodeScanner not working
mrousavy Mar 21, 2024
73e3c44
chore: release 4.0.0-beta.9
mrousavy Mar 21, 2024
a255c24
fix: Fix location permission not resolving on iOS (#2672)
mrousavy Mar 21, 2024
51106d3
chore: Remove RN Fast Image (we dont have web images anyways)
mrousavy Mar 21, 2024
f8a16d6
Update package.json
mrousavy Mar 21, 2024
ce23932
chore: release 4.0.0-beta.10
mrousavy Mar 21, 2024
4c00ffd
fix: Fix wrong orientation enum being send to ImageCapture (#2683)
rodgomesc Mar 25, 2024
ff2005b
perf: Add `@FastNative` flags to critical Frame Processor methods
mrousavy Mar 26, 2024
318f22b
Merge branch 'main' into v4
mrousavy Mar 27, 2024
8a95414
fix: Fix `RCTDeviceEventEmitter` import for RN 0.71.X (#2692)
rodgomesc Mar 27, 2024
7d8d2b7
chore: release 4.0.0-beta.11
mrousavy Mar 27, 2024
86c0f86
feat: Disable shutter sound if in silent
mrousavy Apr 2, 2024
688acd8
fix: Remove `enablePrecapture`
mrousavy Apr 2, 2024
b401ae2
Merge branch 'main' into v4
mrousavy Apr 2, 2024
f7b5428
chore: release 4.0.0-beta.12
mrousavy Apr 2, 2024
a6323cf
fix: Remove `mustPlayShutterSound()` check
mrousavy Apr 3, 2024
6e2e011
Update Podfile.lock
mrousavy Apr 4, 2024
b5bbcad
chore: release 4.0.0-beta.13
mrousavy Apr 4, 2024
065521e
feat: Add Skia support (`toSkImage()`)
mrousavy Apr 5, 2024
cffb5fa
feat: Add `frame.getPlaformBuffer()`
mrousavy Apr 5, 2024
93acf26
Try use getPlatformBuffer
mrousavy Apr 5, 2024
bce81a0
Update Frame.ts
mrousavy Apr 5, 2024
ced1084
fix: Fix `getPlatformBuffer()`
mrousavy Apr 5, 2024
9e60dbf
fix: Fix buffer access
mrousavy Apr 5, 2024
cd9b84d
fix: Always support `rgb` and `yuv`, remove `native`
mrousavy Apr 6, 2024
33d63ae
fix: Always support `rgb` and `yuv`, remove `native`
mrousavy Apr 6, 2024
ded8475
feat: Build Skia example renderer
mrousavy Apr 6, 2024
8691edb
fix: Render a bit better
mrousavy Apr 6, 2024
a12149a
fix: Use atomic updates now
mrousavy Apr 6, 2024
d50a870
fix: Remove SK flags
mrousavy Apr 8, 2024
02a3c9f
fix: Clear and copy Frame
mrousavy Apr 8, 2024
88455b3
fix: Use bigint
mrousavy Apr 8, 2024
8ab7754
fix: Use `ImageProxy` and close it to avoid stalling
mrousavy Apr 8, 2024
3e7042e
Only do copy on iOS
mrousavy Apr 8, 2024
d1f7e08
fix: Add throw method signature
mrousavy Apr 8, 2024
81d1b47
feat: Box into `DrawableFrame`
mrousavy Apr 8, 2024
552ab81
feat: Create `SkiaCameraCanvas`
mrousavy Apr 8, 2024
b9e346b
feat: Allow disabling `preview` use-case
mrousavy Apr 8, 2024
979e0f4
feat: Catch some errors
mrousavy Apr 8, 2024
a2c63ab
Update FrameHostObject.cpp
mrousavy Apr 8, 2024
3a9811e
fix: Use proper layouts
mrousavy Apr 8, 2024
49df0d6
Update useSkiaFrameProcessor.ts
mrousavy Apr 8, 2024
ede9ebf
fix: Use main Coroutine Scope
mrousavy Apr 8, 2024
aac6135
fix: Fix wrong changes because we now properly abort changes
mrousavy Apr 8, 2024
528845a
chore: Format
mrousavy Apr 8, 2024
f4481d8
fix: Upgrade react-native-worklets-core
mrousavy Apr 8, 2024
8e013ae
Merge branch 'v4' into v4-skia
mrousavy Apr 9, 2024
04150be
fix: Add `focusRequiresPreview` error to iOS
mrousavy Apr 9, 2024
2f3610b
chore: Use latest react-native-worklets-core
mrousavy Apr 9, 2024
7aaef18
fix: Fix buffer orientation on iOS (it's currently always `.up`
mrousavy Apr 9, 2024
1fe118c
fix: Only pass function into native, no object
mrousavy Apr 9, 2024
346af67
fix: Format code
mrousavy Apr 9, 2024
d54f84e
fix: Fix styling
mrousavy Apr 9, 2024
b43bad1
fix: Fix pointer-events
mrousavy Apr 9, 2024
d2a92e8
Update Camera.tsx
mrousavy Apr 9, 2024
eefe074
Update useSkiaFrameProcessor.ts
mrousavy Apr 9, 2024
5b3886c
Update Worklets
mrousavy Apr 9, 2024
7859435
Draw radial face blur
mrousavy Apr 9, 2024
4ce9a1f
circle that spins
mrousavy Apr 9, 2024
87140d1
fix: Proxify
mrousavy Apr 9, 2024
be49a74
fix: Also use worklets proxy lazily
mrousavy Apr 9, 2024
dd33d91
fix: Try multiple error handlers
mrousavy Apr 9, 2024
efd00f8
fix: Also use Skia Proxy
mrousavy Apr 9, 2024
664f573
Add docs to the objects
mrousavy Apr 9, 2024
2f80193
fix: Use `createModuleProxy`
mrousavy Apr 9, 2024
88568e0
fix: Also re-create surface if height is different
mrousavy Apr 10, 2024
a3657ee
perf: Remove unneeded mutex locks as Frame only locks refCount
mrousavy Apr 10, 2024
a208724
Update FRAME_PROCESSORS_CREATE_OVERVIEW.mdx
mrousavy Apr 10, 2024
46b9941
fix: Remove unneeded CPU copy
mrousavy Apr 10, 2024
f9e1eba
fix: Catch PixelFormat error and fallback to default format
mrousavy Apr 10, 2024
a813793
fix: Throw proper PixelFormat error with more info
mrousavy Apr 10, 2024
f390315
Update CameraError.swift
mrousavy Apr 10, 2024
ae6cf65
Update Frame.java
mrousavy Apr 10, 2024
af60cbc
fix: Use `jsi::Scope`
mrousavy Apr 10, 2024
49b8d12
chore: Update react-native-worklets-core
mrousavy Apr 10, 2024
8729d1a
fix: Dispose previous Surface
mrousavy Apr 11, 2024
d2e0bb9
Update useSkiaFrameProcessor.ts
mrousavy Apr 11, 2024
8da98a1
fix: Fix surface re-creating each time
mrousavy Apr 11, 2024
739138b
chore: Bump to latest RN Skia with the features we need
mrousavy Apr 11, 2024
fb8f721
feat: Clean everything on unmount
mrousavy Apr 11, 2024
4fe5982
Add CPU copy again. On iOS, we need it.
mrousavy Apr 11, 2024
107850b
fix: Fix Android build
mrousavy Apr 11, 2024
56d457b
fix: Fix Android build again
mrousavy Apr 11, 2024
9a83756
Update ModuleProxy.ts
mrousavy Apr 15, 2024
cbee439
fix: Use type imports if possible
mrousavy Apr 15, 2024
04a0dcb
fix: Add RN Skia patch
mrousavy Apr 15, 2024
264dd4b
Add react-native-fast-tflite
mrousavy Apr 15, 2024
37db0f5
fix: Configure for tflite files as well
mrousavy Apr 15, 2024
be92f5a
Revert "fix: Configure for tflite files as well"
mrousavy Apr 15, 2024
90d16b5
Revert "Add react-native-fast-tflite"
mrousavy Apr 15, 2024
81bbb18
Update @shopify+react-native-skia+1.2.0.patch
mrousavy Apr 15, 2024
abd47e8
patchh
mrousavy Apr 15, 2024
c40d1c4
Update @shopify+react-native-skia+1.2.0.patch
mrousavy Apr 15, 2024
7f85229
Update @shopify+react-native-skia+1.2.0.patch
mrousavy Apr 15, 2024
a96b229
Update .eslintrc.js
mrousavy Apr 15, 2024
6b17b3d
Draw face contours
mrousavy Apr 15, 2024
7e7a87d
optimize blur example
mrousavy Apr 15, 2024
dc59152
Update Podfile.lock
mrousavy Apr 16, 2024
991b89b
fix: Update to latest face detector
mrousavy Apr 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ jobs:
run: yarn install --frozen-lockfile
- name: Install node_modules for example/
run: yarn install --frozen-lockfile --cwd example
- name: Remove react-native-worklets-core
run: yarn remove react-native-worklets-core --cwd example
- name: Remove worklets, skia and reanimated
run: yarn remove react-native-worklets-core @shopify/react-native-skia react-native-reanimated --cwd ..

- name: Restore Gradle cache
uses: actions/cache@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ jobs:
${{ runner.os }}-yarn-
- name: Install node_modules for example/
run: yarn install --frozen-lockfile --cwd ..
- name: Remove react-native-worklets-core
run: yarn remove react-native-worklets-core --cwd ..
- name: Remove worklets, skia and reanimated
run: yarn remove react-native-worklets-core @shopify/react-native-skia react-native-reanimated --cwd ..

- name: Restore buildcache
uses: mikehardy/buildcache-action@v2
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/guides/EXPOSURE.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Values for the `exposure` prop range from [`device.minExposure`](/docs/api/inter

Instead of manually adjusting ISO and Exposure-Duration, this acts as an "exposure compensation bias", meaning the Camera will still continuously automatically adjust exposure as it goes, but premultiplies the given exposure value to it's ISO and Exposure Duration settings.

### Examples

![Exposure Example (-2, 0, 2)](/img/exposure.jpg)
| `exposure={-2}` | `exposure={0}` | `exposure={2}` |
|--------------------------------------------|-------------------------------------------------|--------------------------------------------|
| ![Exposure -2](/img/exposure-negative.jpg) | ![Exposure Neutral](/img/exposure-neutral.jpg) | ![Exposure +2](/img/exposure-plus.jpg) |

### Animating

Expand Down
3 changes: 1 addition & 2 deletions docs/docs/guides/FORMATS.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ To get all available formats, simply use the `CameraDevice`'s [`formats` propert
- [`videoHeight`](/docs/api/interfaces/CameraDeviceFormat#videoheight)/[`videoWidth`](/docs/api/interfaces/CameraDeviceFormat#videoWidth): The resolution that will be used for recording videos and streaming into frame processors. This also affects the preview's aspect ratio. Choose a format with your desired resolution.
- [`minFps`](/docs/api/interfaces/CameraDeviceFormat#minfps)/[`maxFps`](/docs/api/interfaces/CameraDeviceFormat#maxfps): A range of possible values for the `fps` property. For example, if your format has `minFps: 1` and `maxFps: 60`, you can either use `fps={30}`, `fps={60}` or any other value in between for recording videos and streaming into frame processors.
- [`videoStabilizationModes`](/docs/api/interfaces/CameraDeviceFormat#videostabilizationmodes): All supported Video Stabilization Modes, digital and optical. If this specific format contains your desired [`VideoStabilizationMode`](/docs/api/#videostabilizationmode), you can pass it to your `<Camera>` via the [`videoStabilizationMode` property](/docs/api/interfaces/CameraProps#videoStabilizationMode).
- [`pixelFormats`](/docs/api/interfaces/CameraDeviceFormat#pixelformats): All supported Pixel Formats. If this specific format contains your desired [`PixelFormat`](/docs/api/#PixelFormat), you can pass it to your `<Camera>` via the [`pixelFormat` property](/docs/api/interfaces/CameraProps#pixelFormat).
- [`supportsVideoHdr`](/docs/api/interfaces/CameraDeviceFormat#supportsvideohdr): Whether this specific format supports true 10-bit HDR for video capture. If this is `true`, you can enable `videoHdr` on your `<Camera>`.
- [`supportsPhotoHdr`](/docs/api/interfaces/CameraDeviceFormat#supportsphotohdr): Whether this specific format supports HDR for photo capture. It will use multiple captures to fuse over-exposed and under-exposed Images together to form one HDR photo. If this is `true`, you can enable `photoHdr` on your `<Camera>`.
- [`supportsDepthCapture`](/docs/api/interfaces/CameraDeviceFormat#supportsdepthcapture): Whether this specific format supports depth data capture. For devices like the TrueDepth/LiDAR cameras, this will always be true.
Expand Down Expand Up @@ -213,4 +212,4 @@ Other props that depend on the `format`:

<br />

#### 🚀 Next section: [Taking Photos](./taking-photos)
#### 🚀 Next section: [Preview](./preview)
2 changes: 1 addition & 1 deletion docs/docs/guides/FRAME_PROCESSORS.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Check out [Frame Processor community plugins](/docs/guides/frame-processor-plugi
When running frame processors, it is often important to choose an appropriate [format](/docs/guides/formats). Here are some general tips to consider:

* If you are running heavy AI/ML calculations in your frame processor, make sure to [select a format](/docs/guides/formats) that has a lower resolution to optimize it's performance. You can also resize the Frame on-demand.
* Sometimes a frame processor plugin only works with specific [pixel formats](/docs/api/interfaces/CameraDeviceFormat#pixelformats). Some plugins (like Tensorflow Lite Models) don't work with `yuv`, so use a [`pixelFormat`](/docs/api/interfaces/CameraProps#pixelformat) of `rgb` instead.
* Sometimes a frame processor plugin only works with specific [pixel format](/docs/guides/pixel-formats). Some plugins (like Tensorflow Lite Models) don't work with `yuv`, so use a [`pixelFormat`](/docs/api/interfaces/CameraProps#pixelformat) of `rgb` instead.
* Some Frame Processor plugins don't work with HDR formats. In this case you need to disable [`videoHdr`](/docs/api/interfaces/CameraProps#videohdr).

## Benchmarks
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/guides/FRAME_PROCESSORS_CREATE_OVERVIEW.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Return values will automatically be converted to JS values, assuming they are re
```java
@Nullable
@Override
public Object callback(@NonNull Frame frame, @Nullable Map<String, Object> arguments) {
public Object callback(@NonNull Frame frame, @Nullable Map<String, Object> arguments) throws Throwable {
return "cat";
}
```
Expand All @@ -74,7 +74,7 @@ You can also manipulate the buffer and return it (or a copy of it) by returning
```java
@Nullable
@Override
public Object callback(@NonNull Frame frame, @Nullable Map<String, Object> arguments) {
public Object callback(@NonNull Frame frame, @Nullable Map<String, Object> arguments) throws Throwable {
Frame resizedFrame = new Frame(/* ... */);
return resizedFrame;
}
Expand Down Expand Up @@ -112,11 +112,11 @@ To let the user know that something went wrong you can use Exceptions:
```java
@Nullable
@Override
public Object callback(@NonNull Frame frame, @Nullable Map<String, Object> arguments) {
public Object callback(@NonNull Frame frame, @Nullable Map<String, Object> arguments) throws Throwable {
if (arguments != null && arguments.get("codeType") instanceof String) {
// ...
} else {
throw new Exception("codeType property has to be a string!");
throw new RuntimeException("codeType property has to be a string!");
}
}
```
Expand Down Expand Up @@ -149,7 +149,7 @@ For example, a realtime video chat application might use WebRTC to send the fram
```java
@Nullable
@Override
public Object callback(@NonNull Frame frame, @Nullable Map<String, Object> arguments) {
public Object callback(@NonNull Frame frame, @Nullable Map<String, Object> arguments) throws Throwable {
if (arguments == null) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/FRAME_PROCESSOR_CREATE_PLUGIN_ANDROID.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class FaceDetectorFrameProcessorPlugin extends FrameProcessorPlugin {

@Nullable
@Override
public Object callback(@NonNull Frame frame, @Nullable Map<String, Object> arguments) {
public Object callback(@NonNull Frame frame, @Nullable Map<String, Object> arguments) throws Throwable {
// highlight-next-line
// code goes here
return null;
Expand Down
138 changes: 138 additions & 0 deletions docs/docs/guides/LOCATION.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
id: location
title: GPS Location Tags
sidebar_label: GPS Location Tags
---

import useBaseUrl from '@docusaurus/useBaseUrl'
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'

<div class="image-container">
<img width="283" src={useBaseUrl("img/location.png")} />
</div>

## What are GPS Location Tags?

GPS Location Tags are location properties stored in image files (via EXIF tags) or video files (via QuickTime/MP4 tags).

VisionCamera provides an API to easily add such location tags to captured photos or videos.

### Configure Location Permissions

First, you need to add the required permissions to access the user's location:

<Tabs
groupId="environment"
defaultValue="rn"
values={[
{label: 'React Native', value: 'rn'},
{label: 'Expo', value: 'expo'}
]}>
<TabItem value="rn">

### iOS

Open your project's `Info.plist` and add the following lines inside the outermost `<dict>` tag:

```xml
<key>NSLocationWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to your location.</string>
```

### Android

Open your project's `AndroidManifest.xml` and add the following lines inside the `<manifest>` tag:

```xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
```

</TabItem>

<TabItem value="expo">

### Managed Expo

Enable the `enableLocation` property inside your app's Expo config (`app.json`, `app.config.json` or `app.config.js`):

```json
{
"name": "my app",
"plugins": [
[
"react-native-vision-camera",
{
// ...
"enableLocation": true,
"locationPermissionText": "[my app] needs your location."
}
]
]
}
```

Finally, compile the mods:

```bash
npx expo prebuild
```

To apply the changes, build a new binary with EAS:

```bash
eas build
```

</TabItem>
</Tabs>

### Request Location Permissions

After adding the required permissions to your app's manifests, prompt the user to grant location permission at runtime:

<Tabs
groupId="component-style"
defaultValue="hooks"
values={[
{label: 'Hooks API', value: 'hooks'},
{label: 'Imperative API', value: 'imperative'}
]}>
<TabItem value="hooks">

Get or request permissions using the [`useLocationPermission`](/docs/api/#uselocationpermission) hook:

```tsx
const { hasPermission, requestPermission } = useLocationPermission()
```

</TabItem>
<TabItem value="imperative">

Get the current permission status:

```ts
const permissionStatus = Camera.getLocationPermissionStatus()
```

And if it is not `granted`, request permission:

```ts
const newPermissionStatus = await Camera.requestLocationPermission()
```

</TabItem>
</Tabs>

### Enable GPS Location Tags

Use the [`enableLocation`](/docs/api/interfaces/CameraProps#enablelocation) property to start streaming location updates and automatically add GPS Location Tags to images (EXIF tags) and videos:

```tsx
<Camera {...props} enableLocation={true} />
```

Once enabled, all captured photos (see ["Taking Photos"](taking-photos)) and videos (see ["Recording Videos"](recording-videos)) will contain location tags.


#### 🚀 Next section: [Performance](performance)
14 changes: 11 additions & 3 deletions docs/docs/guides/PERFORMANCE.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,19 @@ The [`isActive`](/docs/api/interfaces/CameraProps#isactive) prop controls whethe

### Fast Photos

If you need to take photos as fast as possible, use a [`qualityPrioritization`](/docs/api/interfaces/TakePhotoOptions#qualityprioritization) of `'speed'` to speed up the photo pipeline:
If you need to take photos as fast as possible, use a [`qualityBalance`](/docs/api/interfaces/CameraProps#qualitybalance) of `'speed'` to speed up the photo pipeline:

```jsx
return <Camera {...props} qualityBalance="speed" />
```

### Snapshot Capture

If photo capture is still too slow for your use-case, consider [taking snapshots](/docs/guides/taking-photos#taking-snapshots) instead:

```ts
camera.current.takePhoto({
qualityPrioritization: 'speed'
const snapshot = await camera.current.takeSnapshot({
quality: 85
})
```

Expand Down
35 changes: 10 additions & 25 deletions docs/docs/guides/PIXEL_FORMATS.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl'

A Camera's video pipeline operates in a specific pixel format which specifies how the pixels are laid out in a memory buffer.

If you are simply recording videos (`video={true}`), the most efficient pixel format (`native`) will be automatically chosen for you, and [buffer compression](/docs/guides/performance#buffer-compression) will be enabled if available.
If you are simply recording videos (`video={true}`), the most efficient pixel format will be automatically chosen for you, and [buffer compression](/docs/guides/performance#buffer-compression) will be enabled if available.

If you are using Frame Processors, it is important to understand what pixel format you are using.

Expand All @@ -26,46 +26,31 @@ Cameras however don't operate in RGB, they use YUV instead. Instead of storing a
YYYYUVYYYYUVYYYYUV
```

In VisionCamera, pixel formats are abstracted under a simple [`PixelFormat`](/docs/api/#pixelformat) API with three possible values:
In VisionCamera, pixel formats are abstracted under a simple [`PixelFormat`](/docs/api/#pixelformat) API with two possible values:

- `yuv`: The YUV (often 4:2:0, 8-bit per channel) pixel format.
- `native`: Whatever native format is most efficient, likely the same as YUV on iOS, but some PRIVATE format on Android.
- `rgb`: An RGB (often BGRA, 8-bit per channel) pixel format.

A [`CameraFormat`](/docs/api/interfaces/CameraDeviceFormat) specifies which pixel formats it can use for this specific configuration. For example, let's inspect the 4k Video format on an iPhone:

```json
// ...
"pixelFormats": [
"yuv",
"rgb"
]
```

This Format supports both YUV and RGB streaming, so we can configure the Camera to stream in RGB if we want:
Every Camera device can either stream in `yuv` or `rgb`, but `rgb` comes with an additional overhead and sometimes even needs to be converted from `yuv` first.

```tsx
function App() {
// ...
const format = ...
const pixelFormat = format.pixelFormats.includes("rgb") ? "rgb" : "native"
const frameProcessor = useFrameProcessor((frame) => {
'worklet'
console.log(frame.pixelFormat) // <-- "rgb"
}, [])

return (
<Camera
style={StyleSheet.absoluteFill}
device={device}
format={format}
pixelFormat={pixelFormat}
pixelFormat="rgb"
frameProcessor={frameProcessor}
/>
)
}
```

However this is not recommended, as YUV is much more efficient.

On Android, only YUV and NATIVE (PRIVATE) are supported, as RGB requires explicit conversion.

As a general tip, try to always use YUV, and stay away from RGB. If you have some specific models (e.g. Face Detectors), try converting them to YUV (4:2:0) instead of trying to run your Camera in RGB, as the conversion beforehand will be worth the effort.
As a general tip, try to always use YUV if possible. If you have some specific models (e.g. Face Detectors), try converting them to YUV (4:2:0) instead of trying to run your Camera in RGB, as the conversion beforehand will be worth the effort.

### HDR

Expand Down
53 changes: 53 additions & 0 deletions docs/docs/guides/PREVIEW.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
id: preview
title: Preview
sidebar_label: Preview
---

import useBaseUrl from '@docusaurus/useBaseUrl'

<div class="image-container">
<svg xmlns="http://www.w3.org/2000/svg" width="283" height="535">
<image href={useBaseUrl("img/demo_capture.gif")} x="18" y="33" width="247" height="469" />
<image href={useBaseUrl("img/frame.png")} width="283" height="535" />
</svg>
</div>

## The Preview View

The `<Camera>` React component renders a Preview view for the Camera.

### FPS

The Preview view is running at the same frame rate as the Video stream, configured by the [`fps`](/docs/api/interfaces/CameraProps#fps) prop, or 30 FPS by default.

```tsx
<Camera {...props} fps={60} />
```

### Resolution

On iOS, the Video resolution also determines the Preview resolution, so if you Camera format has a low Video resolution, your Preview will also be in low resolution:

```ts
const lowResolutionFormat = useCameraFormat(device, [
{ videoResolution: { width: 640, height: 480 } },
])
```

On Android, the Preview will always be in full HD, or the Preview View's size, whichever is smaller.

### Overlays and Masks

On Android, the Preview View supports two implementation modes which are controllable through the [`androidPreviewViewType`](/docs/api/interfaces/CameraProps#androidpreviewviewtype) prop:

- `"surface-view"`: Uses a [`SurfaceView`](https://developer.android.com/reference/android/view/SurfaceView) for rendering. This is more efficient and supports HDR rendering, but doesn't support masks, transparency, rotations or clipping.
- `"texture-view"`: Uses a [`TextureView`](https://developer.android.com/reference/android/view/TextureView) for rendering. This is less efficient and doesn't support HDR rendering, but supports masks, transparency, rotations and clipping.

```tsx
<Camera {...props} androidPreviewViewType="texture-view" />
```

<br />

#### 🚀 Next section: [Taking Photos](./taking-photos)
Loading
Loading