Commit Graph

77 Commits

Author SHA1 Message Date
Marc Rousavy
83b852acd0
chore: Use CameraRuntimeError if device is null 2024-02-23 10:43:50 +01:00
Marc Rousavy
bda43d3984
fix: Fix nullable props (#2573)
* fix: Fix nullable props

* Update CameraView.kt

* Pass error to JS
2024-02-16 13:46:13 +01:00
Marc Rousavy
4168d8f752
feat: Allow focus calls to be cancelable (#2567)
* feat: Allow focus calls to be cancelable

* Cancelable
2024-02-15 17:33:19 +01:00
Marc Rousavy
37398cc909
feat: Flash with AE Pre-capture trigger for Android (#2558)
### Flash (`flash`)

Adds `flash` functionality with a fully custom pre-capture AE/AF/AWB trigger sequence for Android. 🎉 

```ts
camera.current.takePhoto({
  flash: 'on' // or 'auto'
})
```

### Better photos (`qualityPrioritization`)

We now also run the AE/AF/AWB precapture sequence on every photo (unless `qualityPrioritization` is `speed`), meaning photos are now less blurry, properly exposed, and properly white-balanced - so in short: **photo quality is now better!**.

The fast path still exists when using `qualityPrioritization: speed`, as that will skip the precapture sequence and metering actions and just grab an Image from the Camera as quickly as possible.

Additionally, `qualityPrioritization` now controls these options:

- [COLOR_CORRECTION_MODE](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest#COLOR_CORRECTION_MODE)
- [EDGE_MODE](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest#EDGE_MODE)
- [COLOR_CORRECTION_ABERRATION_MODE](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest#COLOR_CORRECTION_ABERRATION_MODE)
- [HOT_PIXEL_MODE](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest#HOT_PIXEL_MODE)
- [DISTORTION_CORRECTION_MODE](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest#DISTORTION_CORRECTION_MODE)
- [NOISE_REDUCTION_MODE](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest#NOISE_REDUCTION_MODE)
- [SHADING_MODE](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest#SHADING_MODE)
- [TONEMAP_MODE](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest#TONEMAP_MODE)

..by setting them to `_FAST` or `_HIGH_QUALITY`, which was previously left untouched. 

This now means:
- `takePhoto({ qualityPrioritization: 'speed' })` got FASTER 🚀 
- `takePhoto({ qualityPrioritization: 'quality' })` got BETTER QUALITY 📸 
- `takePhoto({ qualityPrioritization: 'balanced' })` is left unchanged 
2024-02-14 16:43:30 +01:00
Marc Rousavy
61b2f7dd4a
chore: Improve enableGpuBuffers docs 2024-02-14 13:52:02 +01:00
Marc Rousavy
1a0bd8f7c2
feat: Add enableGpuBuffers property (#2557)
* Revert "fix: Fix VideoPipeline crash on Samsung (Disable `USAGE_GPU_SAMPLED_IMAGE` ImageReader) (#2555)"

This reverts commit ad33dd91b1.

* feat: Add `enableGpuBuffers` prop

* Create ImageWriter separately
2024-02-14 12:47:40 +01:00
Marc Rousavy
5acc64e031
feat: Create persistent CaptureSession to avoid any blackscreen issues or errors (#2494)
* feat: Create custom `CaptureSession` wrapper

* Create `PersistentCameraCaptureSession`

* Update VideoStabilizationMode.kt

* Create RepeatingRequest.kt

* Update CaptureSession.kt

* Delete CaptureSession.kt

* Update PersistentCameraCaptureSession.kt

* Update PersistentCameraCaptureSession.kt

* fix: Add `isRepeating`

* Update CameraSession.kt

* Make `SurfaceOutput` not `Closable` anymore

* Update PersistentCameraCaptureSession.kt

* Stub out the rest

* Format

* Set `isRunning` properly

* Close previous outputs

* onError callback

* Format

* Started/Stopped

* Update CameraPage.tsx

* Add `isValid`

* Log `isActive`

* Add `tryAbortCaptures`

* Configure()

* Try?

* Add `didDestroyFromOutside`

* Disable FP for testing

* fix: Call `super.onAttachedToWindow` first

* Hm

* Update CameraSession.kt

* Update PersistentCameraCaptureSession.kt

* Try catch `didDestroyFromOutside`

* Update PersistentCameraCaptureSession.kt

* Session can only be active with a preview

* Update PersistentCameraCaptureSession.kt

* Throw `no-outputs` if needed

* Update logs

* fix: Check for CAMERA permission

* fix: Close session when opening a new device

* perf: Make everything `by lazy` in CameraDeviceDetails

* Update CameraDeviceDetails.kt

* Update PersistentCameraCaptureSession.kt

* Update PersistentCameraCaptureSession.kt

* Move

* Update Podfile.lock

* Implement `capture()`

* Format

* fix: Fix orientation not being applied

* fix: Fix `isMirrored`

* fix: Fix getting size

* fix: Close `Surface` in `VideoPipeline`

* Format

* fix: Fix `VideoPipeline` not properly destroying itself

* Use FP again

* Update CameraConfiguration.kt

* Rename

* Clean up

* Format

* Update CameraConfiguration.kt

* fix: Don't stop repeating request when capturing
2024-02-06 14:19:25 +01:00
Lucas Garcez
cd5fdd4924
fix: Properly type Format Templates (#2499)
add PredefinedTemplates type
2024-02-05 12:37:42 +01:00
Marc Rousavy
d8c95c901f
feat: Synchronize Frame properly (#2501)
* feat: Synchronize `Frame` properly

* Update CameraError.ts

* Image is not valid if `refCount` < 0
2024-02-05 12:34:32 +01:00
Marc Rousavy
d9a301100f
fix: Fix priority being ignored in some Format filters (#2456)
* fix: Expose auto-focus system for Android

* Add `autoFocusSystem` to filter

* Update CameraDeviceDetails.kt

* Update getCameraFormat.ts

* fix: Fix `priority` being ignored in some Format filters

* Update getCameraFormat.ts
2024-01-30 10:52:34 +01:00
Marc Rousavy
b5eb01bac8
fix: Expose auto-focus system for Android (#2455)
* fix: Expose auto-focus system for Android

* Add `autoFocusSystem` to filter

* Update CameraDeviceDetails.kt

* Update getCameraFormat.ts
2024-01-30 10:49:28 +01:00
Marc Rousavy
d64fc08e16
fix: Fix pixelFormat being native when FP is set (#2450) 2024-01-29 13:39:16 +01:00
Marc Rousavy
11eb1f68e4
feat: Use yuv by default if no pixelFormat is set (#2441) 2024-01-26 10:07:16 +01:00
Marc Rousavy
b1fa06514f
fix: Catch insufficient-storage errors (#2422)
* fix: Catch `insufficient-storage` errors

* feat: Implement `insufficient-storage` error for Android

* fix: Catch insufficient storage error also on takePhoto android
2024-01-24 11:48:38 +01:00
Marc Rousavy
97684af851
fix: Refresh Permissions on AppState change (#2420) 2024-01-19 12:17:04 +01:00
Marc Rousavy
ba1d7eec9c
feat: Use JSI's ArrayBuffer instead of TypedArray (#2408)
* feat: Use JSI's `ArrayBuffer` instead of `TypedArray`

* fix: Fix move memory

* feat: Implement iOS

* Format

* Update JSIJNIConversion.cpp

* fix: Fix Android `toArrayBuffer` and other

* Catch FP call errors

* Update return type

* Use `CPU_READ_OFTEN` flag as well

* CPU flag

* Run destructors under `jni::ThreadScope`

* Update FrameProcessorPluginHostObject.cpp

* fix: Fix `toArrayBuffer()` crash

* Update Frame.ts
2024-01-17 20:18:46 +01:00
Marc Rousavy
03ee0a2099
feat: Expose FrameProcessorPlugin TS type 2024-01-17 11:58:32 +01:00
Marc Rousavy
e825e21e1d
fix: Make Frame properties readonly in Types (#2397) 2024-01-16 18:00:13 +01:00
Marc Rousavy
58ef21ebfd
feat: Add minFocusDistance prop to CameraDevice (#2392)
* docs: Link `videoHdr`

* Update PERFORMANCE.mdx

* docs: Add isActive to perf

* docs: Update errors

* feat: Add `minFocusDistance` prop

* Format

* Update Podfile.lock

* fix: To Double

* fix: Import AVFoundation

* fix: Move from format -> device

* fix: Use centi-meters (cm) instead of meters

* Fix deadloop

* fix: Avoid -1 values
2024-01-15 19:30:20 +01:00
Marc Rousavy
9ecc09cfe4
docs: Add platform: iOS annotation to regionOfInterest prop 2024-01-13 19:35:30 +01:00
Marc Rousavy
34c5b11927
feat: Re-throw error on JS side instead of just logging on native side (#2366)
* feat: Re-throw error on JS side instead of just logging on native side

* fix: Fix proxy

* fix: Fix app crash by only logging error

* fix: Use `global.ErrorUtils` (from reanimated)
2024-01-11 17:23:38 +01:00
Marc Rousavy
5c99728561
feat: Add new enableCodeScanner prop to build.gradle to make sure CodeScanner always works (#2355)
* feat: Always download model instead of relying on Google Play Services

* feat: Use `VisionCamera_enableCodeScanner` flag instead of unsafely replacing

* Update CODE_SCANNING.mdx
2024-01-08 13:14:47 +01:00
Erwan LE PRADO
a8c16e31d6
feat: Make enableCodeScanner expo config-plugin install the native dependency (#2348)
* feat: with gradle implementation

* chore: remove unused vars

* chore: eslint

* chore: eslint
2024-01-08 12:54:01 +01:00
Marc Rousavy
cc60ad296a
fix: Validate input props (fps, hdr, torch, ...) instead of silently crashing (#2354)
* fix: Fix Blackscreen by deterministically destroying session if `isActive=false`

* Re-open Camera if session died

* Simplify Camera

* Disconnect is optional, block when resetting state

* fix: Log in `configure { ... }`

* fix: Make concurrent configure safe

* fix: Don't resize preview

* fix: Use current `CameraConfiguration`

* Don't start if no outputs are available

* Only mount with preview outputs

* Update CameraSession.kt

* Update PreviewView.kt

* Better logging

* Update CameraSession.kt

* Extract

* fix: Rebuild entire session if `isActive` changed

* isActive safe

* Start session at 1

* Create ActiveCameraDevice.kt

* interrupts

* chore: Freeze `frame` in `useFrameProcessor`

* Revert "chore: Freeze `frame` in `useFrameProcessor`"

This reverts commit dff93d506e29a791d8dea8842b880ab5c892211e.

* chore: Better logging

* fix: Move HDR to `video`/`photo` config

* fix: Fix hdr usage

* fix: Ignore any updates after destroying Camera

* fix: Fix video HDR

* chore: Format code

* fix: Check Camera permission

* Remove unneeded error

* Update CameraSession.kt

* Update CameraPage.tsx

* Delete OutputConfiguration.toDebugString.kt

* Update CameraSession.kt

* fix: Perform sanity checks to make sure props are valid

* format
2024-01-08 12:13:05 +01:00
Marc Rousavy
e4393cd83a
chore: Import type only from CodeScanner 2023-12-28 11:56:40 +01:00
Marc Rousavy
591cf30a06
perf: Make getCameraPermission and getMicrophonePermission synchronous (#2302) 2023-12-19 14:22:04 +01:00
Marc Rousavy
9a187c6d19
feat: Add width and height to VideoFile output (#2281)
* feat: Add `width` and `height` to `VideoFile` output

* Format
2023-12-12 16:43:57 +01:00
Marc Rousavy
52f78a119b
feat: Add format filter for iso (#2234) 2023-12-12 11:16:08 +01:00
Marc Rousavy
4ee52d6211
feat: Add onStarted and onStopped events (#2273)
* feat: Add `onStarted` and `onStopped` events

* Implement `onStart` for Android

* Update CameraSession.kt

* Update CameraSessionDelegate.swift
2023-12-09 19:09:55 +01:00
Marc Rousavy
a5e10a8606
fix: Fix torch not staying on while recording (#2249)
* fix: Fix `zoom` on native gesture

* fix: Control `torch` from JS side

* Update CameraView+RecordVideo.kt

* Update CameraView+Zoom.swift
2023-12-04 11:43:17 +01:00
Marc Rousavy
a28135da20
feat: Add extra-low and extra-high bit-rate options (#2225) 2023-11-27 17:29:25 +01:00
Marc Rousavy
d7f7095d1a
fix: Use bitRate multiplier instead of setting it to an absolute value (#2216)
* fix: Use `bitRate` multiplier instead of setting it to an absolute value

* Pass override

* Format

* Rename

* feat: Also implement Android

* fix: Log Mbps properly

* fix: Up-/Down-scale bit-rate if different options

* fix: Parse in Manager

* Update RecordingSession+getRecommendedBitRate.kt
2023-11-27 17:20:26 +01:00
Marc Rousavy
cad5240420
fix: Move minExposure/maxExposure from format into device (#2211)
* fix: Move `minExposure`/`maxExposure` into `device`

* Update docs

* chore: Remove unneeded dependency

* chore: Update code
2023-11-24 18:20:56 +01:00
Marc Rousavy
49d58d0d0c
perf: Use lossy compressed YUV buffers if available (#2195) 2023-11-22 16:19:29 +01:00
Marc Rousavy
ef58d13b87
feat: Implement exposure (#2173)
* feat: Implement `exposure` (iOS)

* Update Podfile.lock

* Format

* Expose exposure in format

* Set exposure in Camera2

* fix: Fix exposure calculation

* Add exposure docs
2023-11-19 15:26:43 +01:00
Marc Rousavy
98a641702c
fix: Log errors to console if no onError handler is passed 2023-11-18 12:16:52 +01:00
Marc Rousavy
c5dfb6c247
feat: Split videoHdr and photoHdr into two settings (#2161)
* feat: Split `videoHdr` and `photoHdr` into two settings

* fix: Rename all `hdr`

* fix: Fix HDR on Android

* Update CameraDeviceDetails.kt

* Update CameraDeviceDetails.kt

* fix: Correctly configure `pixelFormat` AFTER `format`

* Update CameraSession+Configuration.swift

* fix: Also after format changed
2023-11-15 18:33:12 +01:00
Marc Rousavy
e8ebc6ee9f
chore: Move code 2023-11-15 15:44:19 +01:00
Metrix Hungary Kft
e649aba8e1
feat: Implement cornerPoints and frame for scanned codes (#2117)
* Android & TypeScript part of scanned code corner points. Scanned frame dimensions also included in callback. #2076

* TS fix. #2076

* Implement iOS parts of code scanner corner points with additional scanned frame data.

* Add example page for code scanning

* Use Point type from Point.ts

* Update package/src/CodeScanner.ts

Add parameters description to CodeScanner callback.

Co-authored-by: Marc Rousavy <marcrousavy@hotmail.com>

* Update package/src/CodeScanner.ts

More expressive description for CodeScannerFrame.

Co-authored-by: Marc Rousavy <marcrousavy@hotmail.com>

* Update package/src/CodeScanner.ts

Co-authored-by: Marc Rousavy <marcrousavy@hotmail.com>

* Update package/src/CodeScanner.ts

Co-authored-by: Marc Rousavy <marcrousavy@hotmail.com>

* Update package/ios/Core/CameraSession+CodeScanner.swift

Co-authored-by: Marc Rousavy <marcrousavy@hotmail.com>

* Update package/ios/Core/CameraSession+CodeScanner.swift

Co-authored-by: Marc Rousavy <marcrousavy@hotmail.com>

* Remove default values from CodeSCannerFrame

* Linting

* Multiply code corner points in swift

---------

Co-authored-by: stemy <balazs.stemler@metrix.co.hu>
Co-authored-by: Zoli <iamzozo@metrix.co.hu>
Co-authored-by: Marc Rousavy <marcrousavy@hotmail.com>
2023-11-09 11:57:05 +01:00
Marc Rousavy
40268c4a05
fix: Fix getting triple devices with useCameraDevice (#2074) 2023-10-24 15:48:39 +02:00
Marc Rousavy
8a5dfd6ac6
fix: Fix physicalDevices DeviceType computation on Android (#2072)
* fix: Fix device type calculation on Android

* fix: Type safety for deviceTypes

* fix: Update docs
2023-10-24 14:27:47 +02:00
Marc Rousavy
f91adb13be
fix: Use same error message 2023-10-24 13:44:03 +02:00
Marc Rousavy
da25aa1c1f
fix: Add getFrameProcessorPlugin for backwards compatibility (#2040) 2023-10-19 11:35:02 +02:00
Marc Rousavy
07027d8010
fix: Rename getFrameProcessorPlugin to initFrameProcessorPlugin (#2038)
* fix: Rename `getFrameProcessorPlugin` to `initFrameProcessorPlugin`

* fix: Make nullable, add comments

* Format

* Update FrameProcessorPlugin.java

* Update FrameProcessorPlugin.h

* fix: Fix dead links

* Call super constructor

* Update ExampleFrameProcessorPlugin.java

* fix: Init calls
2023-10-19 11:19:47 +02:00
Mateusz Mędrek
a291642c53
feat: Reintroduce Macros for Frame Processor Plugin registration (#2027)
in VisionCamera v1 & v2 there were two ObjC macros that were helping
in creation/registration of Frame Processors, but these were removed with
v3

This PR reintroduces such macros, which will not only make FP development
easier, but also it will also fix issues people had with registration of
Swift Frame Processors (+load vs +initialize issues)

Docs were also updated to reflect that the macros should be used to
correctly initialize and register ObjC/Swift Frame Processors
2023-10-19 10:35:14 +02:00
Marc Rousavy
e8bb5cfec0
docs: Remove some links that just didn't work for some reason 2023-10-12 10:14:48 +02:00
Marc Rousavy
1e7059ca8f
Revert "fix: Remove Frame Processor when Camera unmounts (#1960)"
This reverts commit d51ac1529b.
2023-10-10 18:58:47 +02:00
Tuan Luong
d51ac1529b
fix: Remove Frame Processor when Camera unmounts (#1960)
* unsetFrameProcessor when camera view is removed

* Use `this.lastFrameProcessor` instead

---------

Co-authored-by: Marc Rousavy <marcrousavy@hotmail.com>
2023-10-10 18:55:08 +02:00
Marc Rousavy
a2e5cef37e
chore: Fix docs links 2023-10-10 18:40:15 +02:00
Marc Rousavy
b33174399e
docs: Fix broken links 2023-10-10 18:21:39 +02:00