Marc Rousavy
4a73cb96c1
fix: Fix view-not-found
race condition in C++ code ( #511 )
...
* Add custom `onViewReady` event to get layout
`componentDidMount` is async, so the native view _might_ not exist yet causing a race condition in the `setFrameProcessor` code.
This PR fixes this by calling `setFrameProcessor` only after the native view has actually mounted, and to ensure that I created a custom event that fires at that point.
* Update CameraView.swift
2021-10-11 18:27:23 +02:00
Marc Rousavy
42e791b4bd
perf: Remove FrameProcessorPlugin
HybridClass ( #467 )
...
* Rename `JImageProxyHostObject` -> `FrameHostObject`
* `FrameProcessorPlugin` -> `JFrameProcessorPlugin` 1/2
* `FrameProcessorPlugin` -> `JFrameProcessorPlugin` 2/2
* Make `const`
* Make `getName()` instance based
* Update JFrameProcessorPlugin.h
* Update JImageProxy.h
* `T`
* T
* Remove default ctor
* Use `TSelf` again
* Return `local_ref<CameraView*>` instead of `CameraView*`
* Make `findCameraViewById` return a raw pointer again...
* Extract `setFrameProcessor` and `unsetFrameProcessor`
* Use `global_ref`
* Use `static_cast` for `FrameHostObject`
* Update FrameProcessorRuntimeManager.cpp
* Fix reference lint error
* linelength
* Fix `unsetFrameProcessor` call
2021-09-29 12:30:50 +02:00
Marc Rousavy
60ea779ffe
fix: De-allocate frame
HybridClass with JNI class loader if using Hermes ( #455 )
...
* De-allocate `frame` HybridClass with JNI class loader if using Hermes
See 1b3a0c2612
* Don't wrap in `#if FOR_HERMES`, other `jsi::Runtime`s might also run GC on another Thread.
* Use `jni::local_ref` for `FrameHostObject`
* Update JImageProxyHostObject.cpp
* Only run with JNI `ClassLoader` if ctor Thread ID != dtor Thread ID
* Upgrade reanimated to 2.3.0-beta.1 to fix JNI crash
* Remove `this_thread::get_id()`
* Update Podfile.lock
2021-09-24 16:57:12 +02:00
Andrés Guerrero
98f58367d3
fix: Correctly set video size/aspect ratio for Image Analysis (Frame Processor) ( #453 )
2021-09-24 12:01:45 +02:00
Marc Rousavy
99fff446e5
fix: Fix calling multiple Plugins in a single Frame Processor ( #435 )
...
* fix: Fix JNI <-> JSI conversion for Integers
* Create another plugin and call them both serially
* Use inline formatter for `__android_log_write`
* Update FrameProcessorRuntimeManager.cpp
* Log plugin class type
* Use `pluginGlobal->cthis()`
* Log class name
* fix dumb error
* C++: Dynamically get JNI `javaPart_` class & method
* clean up PR
2021-09-24 10:19:30 +02:00
Marc Rousavy
83524c0541
fix: Fix Android Stabilization Modes ( #449 )
2021-09-23 14:02:46 +02:00
Marc Rousavy
c3cf75eb5f
fix: Fix JNI <-> JSI conversion for Integers
2021-09-15 10:14:52 +02:00
Marc Rousavy
ad5e131f6a
feat: frameProcessorFps="auto"
and automatic performance suggestions (throttle or increase FPS) ( #393 )
...
* Add `onFrameProcessorPerformanceSuggestionAvailable` and make `frameProcessorFps` support `auto`
* Implement performance suggestion and auto-adjusting
* Fix FPS setting, evaluate correctly
* Floor suggested FPS
* Remove `console.log` for frame drop warnings.
* Swift format
* Use `30` magic number
* only call if FPS is different
* Update CameraView.swift
* Implement Android 1/2
* Cleanup
* Update `frameProcessorFps` if available
* Optimize `FrameProcessorPerformanceDataCollector` initialization
* Cache call
* Set frameProcessorFps directly (Kotlin setter)
* Don't suggest if same value
* Call suggestion every second
* reset time on set
* Always store 15 last samples
* reset counter too
* Update FrameProcessorPerformanceDataCollector.swift
* Update CameraView+RecordVideo.swift
* Update CameraView.kt
* iOS: Redesign evaluation
* Update CameraView+RecordVideo.swift
* Android: Redesign evaluation
* Update CameraView.kt
* Update REA to latest alpha and install RNScreens
* Fix frameProcessorFps updating
2021-09-06 16:27:16 +02:00
Marc Rousavy
98128471cc
fix: Fix Proguard annotation for mHybridData
( #406 )
...
* fix: Fix Proguard annotation for `mHybridData`
* rebuild lockfiles
2021-09-05 11:24:33 +02:00
Marc Rousavy
ff5a8b8900
fix: Improve Android resource efficiency/cleanup (use class members for CoroutineScope
and FrameProcessorThread
) ( #335 )
...
* fix: Use custom CoroutineScope
* fix: Use custom `CoroutineScope`
* Make `frameProcessorThread` and `coroutineScope` instance variables
* Update VisionCameraScheduler.java
* Remove `HybridData::resetNative()` calls
they're called by a Java GC destructor anyways.
* Update CameraViewManager.kt
* Update CameraView.kt
2021-08-25 11:33:57 +02:00
Marc Rousavy
c7fb89170e
fix: Apply correct initial rotation on Android ( #368 )
...
* fix: Apply correct initial rotation
* Make `rotation` a property getter
* Update CameraView.kt
2021-08-25 11:16:07 +02:00
Marc Rousavy
c657bf8718
Revert "fix: Fix Frame Processor null-dereference error (use ref-counted JNI local_ref
) ( #351 )"
...
This reverts commit d06bcf648c
.
2021-08-20 16:05:09 +02:00
Marc Rousavy
90f2a1ef7d
fix: Fix close
being called on a collected reference (enforce alias_ref
) ( #379 )
...
* fix: Fix `close` being called on a collected reference (enforce `alias_ref`)
* Remove `~FrameHostObject` on iOS too
2021-08-20 16:05:02 +02:00
Marc Rousavy
0d3f2cbd9d
fix: Fix crash when accessing planesCount
or bytesPerRow
( #380 )
...
* fix: Fix `bytesPerRow` and `planeCount` crashing
* use direct call
* Call `getPlanesCount` and `getBytesPerRow` through java
* revert camerapage changes
* remove removed header import
* Update CameraPage.tsx
2021-08-20 16:02:34 +02:00
Marc Rousavy
d06bcf648c
fix: Fix Frame Processor null-dereference error (use ref-counted JNI local_ref
) ( #351 )
2021-08-20 15:57:31 +02:00
Marc Rousavy
494925c96e
fix: Always return authorized
for requestPermission on SDK 22 and below ( #344 )
2021-08-09 11:43:56 +02:00
Marc Rousavy
37db643f71
fix: Fix format
Preview and Video Capture resolution setting ( #325 )
...
* fix: Actually use a format's `videoSize` for Preview/Video Capture
* `setDefaultResolution` -> `setTargetResolution`
2021-08-05 15:54:01 +02:00
Marc Rousavy
1c32726ef6
fix: Throw JS errors if JSI <-> JNI conversion failed ( #324 )
2021-08-05 10:10:49 +02:00
Marc Rousavy
b493576373
fix: Fix java.lang.NoSuchMethodError
error for .toArrayList()
( #322 )
...
* fix: Fix `java.lang.NoSuchMethodError` error for `.toArrayList()`
* Fix `HashMap<K, V>` conversion to `jsi::Object`
* Update FRAME_PROCESSORS_CREATE_OVERVIEW.mdx
2021-08-04 16:07:08 +02:00
Marc Rousavy
aaecb90937
fix: Fix dead link in parallel-video-processing-not-supported
error
2021-08-02 11:21:23 +02:00
Marc Rousavy
0f7ee51333
feat: Add console
logging support for Frame Processors ( #297 )
...
* Try to log to console via runOnJS
* Call `console.log`
* Create custom `VisionCameraScheduler`
* Fix scheduler call
* Call with this
* Fix console setting
* Move J---- to `java-bindings`
* c++ style
* Android: 1/2 Create custom Scheduler
* Android: 2/2 Use custom Scheduler
* Don't use `runOnJS`, use `__callAsync` directly
2021-07-30 10:27:45 +02:00
Marc Rousavy
123d0d9e9c
chore(deps): Upgrade react-native-reanimated to alpha.2 ( #309 )
...
* Upgrade react-native-reanimated to alpha.2
* fix Android header search path
* Make `const`
2021-07-30 09:50:09 +02:00
Marc Rousavy
445af943c3
feat: BREAKING CHANGE: Express zoom
factor always in actual factor value (1, 2, 128, ...) instead of 0.0-1.0 scale ( #306 )
...
* Make `zoom` go on "factor" scale
* Clean up `zoom` code
* fix float conversion
* fix zoom interpretation
* Update docs for new zoom scale
* fix float conversion
2021-07-29 11:44:22 +02:00
Marc Rousavy
ef455df865
feat: Support rotation ( #301 )
...
* feat: Android: Listen to rotation changes
* Only change rotation on configuration change
* feat: iOS: Support Rotation
* Swift lint
2021-07-26 11:32:58 +02:00
Marc Rousavy
4b4ea0ff33
fix: Fix UI Thread race condition in setFrameProcessor(...)
( #265 )
...
* fix: Fix UI Thread race condition in `setFrameProcessor(...)`
* Revert "fix: Fix UI Thread race condition in `setFrameProcessor(...)`"
This reverts commit 9c524e123cff6843d7d11db602a5027d1bb06b4b.
* Use `setImmediate` to call `setFrameProcessor(...)`
* Fix frame processor order of applying
* Add `enableFrameProcessor` prop that defines if a FP is added
* rename constant
* Implement `enableFrameProcessor` prop for Android and make `frameProcessorFps` faster
* link to troubleshooting guide
* Update TROUBLESHOOTING.mdx
* Add logs for use-cases
* fix log
* set initial frame processor in `onLayout` instead of `componentDidMount`
2021-07-12 15:16:03 +02:00
Marc Rousavy
2f889f5855
fix: Fix hot-reload crash caused by Frame Processor Runtime being initialized twice ( #258 )
...
* Fix Frame Processor Runtime being initialized twice causing a hot-reload to crash
* Remove unnecessary `HasRegisteredPlugins` singleton
* make non-optional
* `REACT_CLASS` -> `TAG`
* fix nullable
2021-07-07 15:00:32 +02:00
Marc Rousavy
3007cd9430
fix: Add @Keep
annotation to prevent minifier from deleting java funcs
2021-07-07 13:18:38 +02:00
Marc Rousavy
7a5e879b92
fix: Fix lint error for missing JNI func (3)
2021-07-07 13:17:41 +02:00
Marc Rousavy
91e81d7594
fix: Fix lint error for missing JNI func (2)
2021-07-07 13:16:19 +02:00
Marc Rousavy
1730ce8980
fix: Fix lint error for missing JNI func
2021-07-07 13:15:32 +02:00
Marc Rousavy
339b470ca5
fix: Fix wrong HDR error being thrown on LowLight mode
2021-07-07 13:14:36 +02:00
Marc Rousavy
1e64215d37
chore(deps): upgrade camerax ( #257 )
...
* Upgrade CameraX to alpha6
* Upgrade CameraX extensions to alpha26
* `init` -> `getInstance`
* Use new Extensions API
* Update CameraView.kt
* use new ExtensionsManager API in `getAvailableCameraDevices()`
* fix cpplint errors
2021-07-07 12:57:28 +02:00
Marc Rousavy
2fa0f8fd46
chore: Clean up root directory ( #236 )
...
* Clean up root
* remove unused REA patches
* Remove `cpp/` and create headers per platform
* fix `#import`
* fix `VISION_CAMERA_DISABLE_FRAME_PROCESSORS`
2021-07-06 16:42:58 +02:00
Marc Rousavy
fa5f5c0cab
feat: Implement Frame.close()
( #229 )
...
* Implement `Frame.close()`
* close frame in dtor
* Update JImageProxyHostObject.cpp
* fix close
* Check if closed
* remove a few logs
* r
* fix `isValid` and `isReady`
* Add JImage
* Release JNI frame ref on destroy
* fix pod setup
* Fix isValid call
* Fix `close` not returning a function
* throw error if closed twice
* iOS: Schedule `console.error` call on JS thread
* Android: Log Frame Processor Error to JS
* fix syntax
* Check if valid `toString()`
* Update Frame.ts
* Remove `isReady`
* Fix JImage accessors
* remove `JImage` C++ sources
* Throw error if accessing props on closed Frame
* Delete `JImage.h`
2021-07-06 10:08:44 +02:00
Marc Rousavy
bfb1b67c2f
Update FrameProcessorRuntimeManager.cpp
2021-06-29 10:38:35 +02:00
Marc Rousavy
5ab1a72e01
chore: Fix C++ indents
2021-06-29 10:38:13 +02:00
Marc Rousavy
45fad5ab19
fix: Add more logs
2021-06-29 10:36:39 +02:00
Marc Rousavy
359fd00c73
fix: print stacktrace on error
2021-06-29 10:34:48 +02:00
Marc Rousavy
f1a5ee7ee1
fix: Log errors in update
and configureSession
2021-06-29 10:18:39 +02:00
Marc Rousavy
f07f4a8770
fix: Correctly propagate Errors in configureSession()
2021-06-29 10:16:38 +02:00
Marc Rousavy
f80e606c6d
fix: Report all errors to JS in configureSession
2021-06-29 10:14:33 +02:00
Marc Rousavy
da84a0fd42
perf: Avoid error message copying
2021-06-28 20:45:08 +02:00
Marc Rousavy
4bacee796a
feat: Print Frame Processor errors to Metro console
2021-06-28 20:44:50 +02:00
Marc Rousavy
26d19d5152
perf: Remove a few unnecessary log statements
2021-06-28 18:30:42 +02:00
Marc Rousavy
e13bef7d17
fix: Host Object error
2021-06-28 10:19:19 +02:00
Marc Rousavy
87e6bb710e
feat: Frame Processors for Android ( #196 )
...
* Create android gradle build setup
* Fix `prefab` config
* Add `pickFirst **/*.so` to example build.gradle
* fix REA path
* cache gradle builds
* Update validate-android.yml
* Create Native Proxy
* Copy REA header
* implement ctor
* Rename CameraViewModule -> FrameProcessorRuntimeManager
* init FrameProcessorRuntimeManager
* fix name
* Update FrameProcessorRuntimeManager.h
* format
* Create AndroidErrorHandler.h
* Initialize runtime and install JSI funcs
* Update FrameProcessorRuntimeManager.cpp
* Update CameraViewModule.kt
* Make CameraView hybrid C++ class to find view & set frame processor
* Update FrameProcessorRuntimeManager.cpp
* pass function by rvalue
* pass by const &&
* extract hermes and JSC REA
* pass `FOR_HERMES`
* correctly prepare JSC and Hermes
* Update CMakeLists.txt
* add missing hermes include
* clean up imports
* Create JImageProxy.h
* pass ImageProxy to JNI as `jobject`
* try use `JImageProxy` C++ wrapper type
* Use `local_ref<JImageProxy>`
* Create `JImageProxyHostObject` for JSI interop
* debug call to frame processor
* Unset frame processor
* Fix CameraView native part not being registered
* close image
* use `jobject` instead of `JImageProxy` for now :(
* fix hermes build error
* Set enable FP callback
* fix JNI call
* Update CameraView.cpp
* Get Format
* Create plugin abstract
* Make `FrameProcessorPlugin` a hybrid object
* Register plugin CXX
* Call `registerPlugin`
* Catch
* remove JSI
* Create sample QR code plugin
* register plugins
* Fix missing JNI binding
* Add `mHybridData`
* prefix name with two underscores (`__`)
* Update CameraPage.tsx
* wrap `ImageProxy` in host object
* Use `jobject` for HO box
* Update JImageProxy.h
* reinterpret jobject
* Try using `JImageProxy` instead of `jobject`
* Update JImageProxy.h
* get bytes per row and plane count
* Update CameraView.cpp
* Return base
* add some docs and JNI JSI conversion
* indent
* Convert JSI value to JNI jobject
* using namespace facebook
* Try using class
* Use plain old Object[]
* Try convert JNI -> JSI
* fix decl
* fix bool init
* Correctly link folly
* Update CMakeLists.txt
* Convert Map to Object
* Use folly for Map and Array
* Return `alias_ref<jobject>` instead of raw `jobject`
* fix JNI <-> JSI conversion
* Update JSIJNIConversion.cpp
* Log parameters
* fix params index offset
* add more test cases
* Update FRAME_PROCESSORS_CREATE_OVERVIEW.mdx
* fix types
* Rename to example plugin
* remove support for hashmap
* Try use HashMap iterable fbjni binding
* try using JReadableArray/JReadableMap
* Fix list return values
* Update JSIJNIConversion.cpp
* Update JSIJNIConversion.cpp
* (iOS) Rename ObjC QR Code Plugin to Example Plugin
* Rename Swift plugin QR -> Example
* Update ExamplePluginSwift.swift
* Fix Map/Dictionary logging format
* Update ExampleFrameProcessorPlugin.m
* Reconfigure session if frame processor changed
* Handle use-cases via `maxUseCasesCount`
* Don't crash app on `configureSession` error
* Document "use-cases"
* Update DEVICES.mdx
* fix merge
* Make `const &`
* iOS: Automatically enable `video` if a `frameProcessor` is set
* Update CameraView.cpp
* fix docs
* Automatically fallback to snapshot capture if `supportsParallelVideoProcessing` is false.
* Fix lookup
* Update CameraView.kt
* Implement `frameProcessorFps`
* Finalize Frame Processor Plugin Hybrid
* Update CameraViewModule.kt
* Support `flash` on `takeSnapshot()`
* Update docs
* Add docs
* Update CameraPage.tsx
* Attribute NonNull
* remove unused imports
* Add Android docs for Frame Processors
* Make JNI HashMap <-> JSI Object conversion faster
directly access `toHashMap` instead of going through java
* add todo
* Always run `prepareJSC` and `prepareHermes`
* switch jsc and hermes
* Specify ndkVersion `21.4.7075529`
* Update gradle.properties
* Update gradle.properties
* Create .aar
* Correctly prepare android package
* Update package.json
* Update package.json
* remove `prefab` build feature
* split
* Add docs for registering the FP plugin
* Add step for dep
* Update CaptureButton.tsx
* Move to `reanimated-headers/`
* Exclude reanimated-headers from cpplint
* disable `build/include_order` rule
* cpplint fixes
* perf: Make `JSIJNIConversion` a `namespace` instead of `class`
* Ignore runtime/references for `convert` funcs
* Build Android .aar in CI
* Run android build script only on `prepack`
* Update package.json
* Update package.json
* Update build-android-npm-package.sh
* Move to `yarn build`
* Also install node_modules in example step
* Update validate-android.yml
* sort imports
* fix torch
* Run ImageAnalysis on `FrameProcessorThread`
* Update Errors.kt
* Add clean android script
* Upgrade reanimated to 2.3.0-alpha.1
* Revert "Upgrade reanimated to 2.3.0-alpha.1"
This reverts commit c1d3bed5e03728d0b5e335a359524ff4f56f5035.
* ⚠️ TEMP FIX: hotfix reanimated build.gradle
* Update CameraView+TakeSnapshot.kt
* ⚠️ TEMP FIX: Disable ktlint action for now
* Update clean.sh
* Set max heap size to 4g
* rebuild lockfiles
* Update Podfile.lock
* rename
* Build lib .aar before example/
2021-06-27 12:37:54 +02:00
Marc Rousavy
9ea158ad8f
chore: Move to /mrousavy/ ( #224 )
...
* rename 1/n
* 2
* 3
* fix indent
2021-06-21 22:42:46 +02:00
Marc Rousavy
0e606affce
feat: High quality mode (enableHighQualityPhotos
) ( #194 )
...
* feat: High Quality photo capture
* prepare photo output for re-used settings
* use high quality captures
* Remove `enableVirtualDeviceFusion` as that is enabled by default
* Clean up configuration, remove default
* format
* Update CameraViewManager.kt
* rename
* Update CameraProps.ts
* Fix overriding `photoSettings`
* Update CameraView+TakePhoto.swift
* Update CameraView+TakePhoto.swift
2021-06-10 13:49:34 +02:00
Marc Rousavy
72a1fad78e
feat: Separate usecases (decouple microphone, video, photo) ( #168 )
...
* Add props
* add props (iOS)
* Add use-cases conditionally
* Update CameraView+RecordVideo.swift
* Update RecordingSession.swift
* reconfigure on change
* Throw correct errors
* Check for audio permission
* Move `#if` outward
* Throw appropriate errors
* Update CameraView+RecordVideo.swift
* fix Splashscreen
* Dynamic filePath
* Fix video extension
* add `avci` and `m4v` file types
* Fix RecordVideo errors
* Fix audio setup
* Enable `photo`, `video` and `audio`
* Check for `video={true}` in frameProcessor
* format
* Remove unused DispatchQueue
* Update docs
* Add `supportsPhotoAndVideoCapture`
* Fix view manager
* Fix error not being propagated
* Catch normal errors too
* Update DEVICES.mdx
* Update CAPTURING.mdx
* Update classdocs
2021-06-07 13:08:40 +02:00
Marc Rousavy
555474be7d
fix: Represent neutralZoom in factor instead of percentage ( #179 )
...
* Use factor instead of percent for `neutralZoom`
* fix zoom calculation
* Update CameraPage.tsx
2021-06-07 10:46:53 +02:00