Commit Graph

62 Commits

Author SHA1 Message Date
Marc Rousavy
587f2b164b
fix: Enable processNestedWorklets to fix runAsync in example (#2449) 2024-01-29 13:39:09 +01:00
Marc Rousavy
7894779094
chore: Remove _log from eslint 2024-01-19 14:33:45 +01:00
Marc Rousavy
b5d039b470
chore: Update Podfile.lock 2024-01-19 12:36:15 +01:00
Marc Rousavy
992934e00e
feat: SharedArray:wrapData:withSize init for iOS (#2410)
* feat: `ArrayBuffer:wrapData:withSize` init for iOS

* Format

* fix build error

* Update ExampleFrameProcessorPlugin.m

* docs: Add class docs for SharedArray
2024-01-18 10:41:26 +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
773f278df8
fix: Use property accessors on Frame (#2400)
* fix: Use property accessors on `Frame`

* Format

* Use `_Nonnull`

* fix: Assume nonnull

* Use `NS_ASSUME_NONNULL_BEGIN` more

* Format C++
2024-01-16 20:02:03 +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
29fe98cc44
feat: Add zero-copy SharedArray type to Frame Processor Plugins (#2383)
* feat: Create `TypedArray` class for Frame Processor Plugins

* Type

* feat: Pass `VisionCameraProxy` along (BREAKING)

* feat: Finish implementation

* Log a bit

* feat: Successfully convert JSI <> JNI buffers

* Wrap buffer

* fix: Fix using wrong Runtime

* feat: Add docs

* add zero copy example

* Format C++

* Create iOS base

* feat: Finish iOS implementation

* chore: Format

* fix: Use `NSData` instead of `NSMutableData`

* Format

* fix: Fix build when Frame Processors are disabled

* chore: Rename `TypedArray` to `SharedArray`

* fix: Fix Swift typings for Array

* Remove a few default inits

* fix: Fix Android build

* fix: Use `NSInteger`

* Update SharedArray.mm

* fix: Expose bytes directly on iOS (NSData was immutable)
2024-01-12 16:00:36 +01:00
Marc Rousavy
322b6fcbd6
fix: Fix Preview stretching on Android (#2377)
* fix: Fix Preview stretching on Android

* fix: Simplify Preview size computation

* fix: Catch `stopRepeating` error

* fix: Fix preview size calculation

* Format code

* Update CameraSession.kt

* Enable CodeScanner in example app

* fix: Also update size on surface change

* Format

* fix: Flip sizes

* Revert that stuff again

* Update PreviewView.kt

* fix: Swap width and height in SurfaceHolder::setFixedSize
2024-01-11 16:33:40 +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
Marc Rousavy
5486be7506
Update Podfile.lock 2024-01-02 12:59:37 +01:00
Marc Rousavy
895f3ec889
feat: Make Frame thread-safe and improve error messages (#2327)
* fix: Fix multi-Thread access on Java

* fix: Thread-lock access on iOS as well

* whoops add missing header impl

* Update Podfile.lock

* fix: Don't use `CFGetRetainCount`

* fix: Lock access on iOS as well

* C++ format

* More detailed error

* chore: Move getters into `Frame`

* Format c++

* Use enum `orientation` again

* format

* fix: Synchronize `isValid` on Java

* Also log pixelformat

* feat: Use Java enums in C++

* Format C++
2023-12-29 14:09:56 +01:00
Marc Rousavy
591cf30a06
perf: Make getCameraPermission and getMicrophonePermission synchronous (#2302) 2023-12-19 14:22:04 +01:00
Marc Rousavy
977bf56c6d
feat: Concurrent/Cancellable configure (#2282)
* feat: Cancellable `configure`

* Android

* Update Podfile.lock

* Configure outside of lock

* Update lockfiles

* Use `bundle` for CI

* Update script

* Update Podfile.lock

* fix: Set config at end

* Lint
2023-12-13 16:38:02 +01:00
Marc Rousavy
7d6c058806
Update Podfile.lock 2023-12-12 16:44:28 +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
c68da4540d
fix: Fix first Frame not being written in Video (#2228)
* fix: Fix first Frame not being written in Video

* Update Podfile.lock
2023-11-28 12:10:21 +01:00
Marc Rousavy
29e649937e
Update Podfile.lock 2023-11-23 15:22:51 +01:00
Marc Rousavy
cf8f3d05e3
fix: Fix Video Recording delay and improve startRecording() performance (#2192)
* fix: Add more logs

* perf: Init audio AVAssetWriter in parallel

* chore: Log Audio Session activation

* perf: Init Audio Session asynchronously

* chore: Log when category changed

* fix: Revert lazy audio initialization

* Update Podfile.lock

* Pass `sourceFormatHint` to video and audio AVAssetWriter

* fix: Remove `sourceFormatHint` from Video Asset Writer

* Use default options for Audio Asset Writer

* Update Podfile.lock

* Revert "Use default options for Audio Asset Writer"

This reverts commit e575a14c5342ddc7f9db557d5e3915328ed9e798.

* Add time logs

* fix: Don't synchronize audio buffers, they are already in sync

* shouldOptimizeForNetworkUse = false

* fix: Only update `latestTimestamp` once video buffer has been written

* perf: Use `AVAssetWriterInput` instead of `AVAssetWriterInputPixelBufferAdaptor`

* fix: Fix Audio not being synchronized with Video

* Remove logs add comments

* Format

* feat: Set `.videoRecording` AVAudioSession mode

* Refactor `startRecording()` a bit

* Format

* chore: Throw error directly instead of double-checking
2023-11-22 17:53:10 +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
1055430cbb
chore: Remove photoCodec from Example App
Fixes https://github.com/mrousavy/react-native-vision-camera/issues/2159
2023-11-15 20:17:16 +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
dc89664be2
chore: Enable zoom gesture in CodeScanner page 2023-11-10 13:25:28 +01:00
Marc Rousavy
ca6760d6ee
feat: Show Alert when a code got scanned 2023-11-10 13:22:35 +01:00
Marc Rousavy
533bc6c291
fix: Fix CodeScanner page 2023-11-10 13:13:06 +01:00
Marc Rousavy
74ecc98cb1
chore: Change dev team to me again 2023-11-10 13:10:51 +01:00
Marc Rousavy
69baacad73
chore: Simplifies Code Scanner Page (#2145)
* chore: Clean up Code Scanner Page

* Update CodeScannerPage.tsx
2023-11-10 12:08:28 +01:00
Marc Rousavy
be1bb419c1
Update Podfile.lock 2023-11-09 12:21: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
Christian Falch
4c9a707866
fix: Use Worklets 0.2.4 to fix FP crash (#2102)
Also changed the namespace in the build gradle to
not be com.mrousavy.camera.example - this would
crash when using dex in release mode on android.
Changed to `com.mrousavy.camera`.
2023-10-31 15:09:05 +01:00
Marc Rousavy
3b7f020566
feat: Basic Flash for Android (#2081)
Implements a semi-working version of flash photo capture for Android.

This isn't properly implemented because a proper implementation requires a fully custom precapture sequence that enables the torch, then waits for AE/AF to adjust, lock AE/AF, then capture with a single torch burst, and then turn the torch off again. This is quite complex, that's why the feature request #1890 is marked at $3,000.

For now, this is a simple flash burst which _sometimes works_, _sometimes not_ - highly depends on the device.

If anyone wants true working flash capture, sponsor in #1890.
2023-10-25 12:41:40 +02:00
Marc Rousavy
de0d6cda5d
feat: Implement atomically single-lock core/ library on Android (#2049)
* feat: Create base for `CameraConfiguration` diff

* Fix

* Write three configure methods

* Build?

* MOre

* Update CameraView+RecordVideo.kt

* Fix errors

* Update CameraDeviceDetails.kt

* Update CameraSession.kt

* Auto-resize Preview View

* More

* Make it work? idk

* Format

* Call `configure` under mutex, and change isActive

* fix: Make Outputs comparable

* fix: Make CodeScanner comparable

* Format

* fix: Update outputs after reconfiguring

* Update CameraPage.tsx

* fix: Close CaptureSession before
2023-10-24 11:19:03 +02:00
Marc Rousavy
3929c0ac46
fix: Initialize Plugins in a static block of ReactPackage (#2039)
* fix: Initialize Plugins in a `static` block of ReactPackage

* fix: Also register FP Plugins in Example
2023-10-19 11:34:09 +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
cd0b413706
feat: New Core/ library (#1975)
Moves everything Camera related into `core/` / `Core/` so that it is better encapsulated from React Native.

Benefits:

1. Code is much better organized. Should be easier for collaborators now, and cleaner codebase for me.
2. Locking is fully atomically as you can now only configure the session through a lock/Mutex which is batch-overridable
    * On iOS, this makes Camera startup time **MUCH** faster, I measured speedups from **1.5 seconds** to only **240 milliseconds** since we only lock/commit once! 🚀 
    * On Android, this fixes a few out-of-sync/concurrency issues like "Capture Request contains unconfigured Input/Output Surface!" since it is now a single lock-operation! 💪 
3. It is easier to integrate VisionCamera outside of React Native (e.g. Native iOS Apps, NativeScript, Flutter, etc)

With this PR, VisionCamera V3 is up to **7x** faster than V2
2023-10-13 18:33:20 +02:00
Marc Rousavy
6e72781500
feat: Use correct photo and video format dimensions on iOS (#1929)
* feat: Use new photo dimensions API

* Update AVCaptureDevice.Format+matchesFilter.swift

* fix: Use Pixels instead of Points for video size

* feat: Set `PhotoOutput`'s maximum photo resolution

* fix: Compare dictionaries instead

* chore: Format code

* fix: Try to use hash.... failing atm

* fix: Use rough comparison again

* fix: Also take video HDR into consideration

* chore: Format

* Use contains

* Update AVCaptureDevice.Format+toDictionary.swift

* docs: Add better docs to Camera props

* Update CameraView+AVCaptureSession.swift

* Update CameraView+AVCaptureSession.swift
2023-10-06 16:11:09 +02:00
Marc Rousavy
1843f7ac3a
feat: Add "Camera Devices" screen to Example (#1927)
* feat: Add "Camera Devices" screen to Example

* feat: Store device in MMKV
2023-10-05 14:52:03 +02:00
Marc Rousavy
cc0256a0fe chore: Fix lockfiles 2023-10-05 13:38:58 +02:00
Marc Rousavy
e4d9764637 chore: Upgrade lockfiles 2023-10-05 13:35:44 +02:00
Marc Rousavy
59699929f4 fix: Use minSdkVersion of 26 again 2023-10-05 10:56:30 +02:00
Marc Rousavy
324e269173
fix: Set minSdkVersion to 23 (#1911)
* fix: Set `minSdkVersion` to 21

* sorry I meant 23
2023-10-03 13:52:42 +02:00
Marc Rousavy
1cdc3d1d9c
fix: Fix +load not available in Xcode 15 error (#1908) 2023-10-03 12:03:29 +02:00
Marc Rousavy
24f77fb224
fix: Use simple wide-angle device if no options are passed (#1909) 2023-10-03 12:03:20 +02:00
Mateusz Mędrek
62e786ad04
docs: Add Kotlin & Swift FP plugins examples (#1902)
* chore(docs): add Kotlin FP example

* chore(docs): add Swift FP plugin
2023-10-03 11:33:48 +02:00
Marc Rousavy
68776f683b chore: Type examplePlugin 2023-09-30 13:35:04 +02:00
Marc Rousavy
b92960a837 chore: Use max zoom of 10 in example 2023-09-30 13:23:17 +02:00
Marc Rousavy
be3d802267 chore: Remove unused ImageWriter 2023-09-30 13:01:56 +02:00
Marc Rousavy
844759e5b1 Update Podfile.lock 2023-09-30 11:17:27 +02:00
Marc Rousavy
016dfa725d Update Podfile.lock 2023-09-29 15:31:35 +02:00