From 8bafd96c2422a4e38c15b14334f4c498caa57c46 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Mon, 18 Jul 2022 11:40:56 +0300 Subject: [PATCH] feat: Allow returning of ImageProxy in a Frame Processor (#1149) * feat: Allow returning of ImageProxy in a Frame Processor * chore: Clean up * fix: Missing space * Update useFrameProcessor.ts * Revert "Update useFrameProcessor.ts" This reverts commit 9c645489cdfdf2079972669756a2cd20cc81e25e. --- android/src/main/cpp/JSIJNIConversion.cpp | 9 +++++++++ example/src/PermissionsPage.tsx | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/android/src/main/cpp/JSIJNIConversion.cpp b/android/src/main/cpp/JSIJNIConversion.cpp index 4fcb7e6..a3a0d70 100644 --- a/android/src/main/cpp/JSIJNIConversion.cpp +++ b/android/src/main/cpp/JSIJNIConversion.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -179,6 +180,14 @@ jsi::Value JSIJNIConversion::convertJNIObjectToJSIValue(jsi::Runtime &runtime, c auto hashMap = toHashMapFunc(object.get()); return convertJNIObjectToJSIValue(runtime, hashMap); + } else if (object->isInstanceOf(JImageProxy::javaClassStatic())) { + // ImageProxy + + auto frame = static_ref_cast(object); + + // box into HostObject + auto hostObject = std::make_shared(frame); + return jsi::Object::createFromHostObject(runtime, hostObject); } auto type = object->getClass()->toString(); diff --git a/example/src/PermissionsPage.tsx b/example/src/PermissionsPage.tsx index 78ee320..b2e7af6 100644 --- a/example/src/PermissionsPage.tsx +++ b/example/src/PermissionsPage.tsx @@ -44,7 +44,7 @@ export function PermissionsPage({ navigation }: Props): React.ReactElement { {cameraPermissionStatus !== 'authorized' && ( - Vision Camera needs Camera permission. + Vision Camera needs Camera permission.{' '} Grant @@ -52,7 +52,7 @@ export function PermissionsPage({ navigation }: Props): React.ReactElement { )} {microphonePermissionStatus !== 'authorized' && ( - Vision Camera needs Microphone permission. + Vision Camera needs Microphone permission.{' '} Grant