GithubHelp home page GithubHelp logo

mrousavy / react-native-vision-camera Goto Github PK

View Code? Open in Web Editor NEW
6.5K 45.0 964.0 102.29 MB

๐Ÿ“ธ A powerful, high-performance React Native Camera library.

Home Page: https://react-native-vision-camera.com

License: MIT License

Kotlin 25.34% JavaScript 0.78% Java 2.69% TypeScript 22.84% Swift 26.62% Ruby 1.16% Objective-C 1.79% Shell 0.55% C++ 10.95% Objective-C++ 6.80% CMake 0.45% C 0.02%
react-native camera library javascript react jsi worklet ai qrcode typescript

react-native-vision-camera's Introduction

VisionCamera

Features

VisionCamera is a powerful, high-performance Camera library for React Native. It features:

  • ๐Ÿ“ธ Photo and Video capture
  • ๐Ÿ‘๏ธ QR/Barcode scanner
  • ๐Ÿ“ฑ Customizable devices and multi-cameras ("fish-eye" zoom)
  • ๐ŸŽž๏ธ Customizable resolutions and aspect-ratios (4k/8k images)
  • โฑ๏ธ Customizable FPS (30..240 FPS)
  • ๐Ÿงฉ Frame Processors (JS worklets to run facial recognition, AI object detection, realtime video chats, ...)
  • ๐Ÿ” Smooth zooming (Reanimated)
  • โฏ๏ธ Fast pause and resume
  • ๐ŸŒ“ HDR & Night modes
  • โšก Custom C++/GPU accelerated video pipeline (OpenGL)

Install VisionCamera from npm:

npm i react-native-vision-camera
cd ios && pod install

..and get started by setting up permissions!

Documentation

ShadowLens

To see VisionCamera in action, check out ShadowLens!

Example

function App() {
  const device = useCameraDevice('back')

  if (device == null) return <NoCameraErrorView />
  return (
    <Camera
      style={StyleSheet.absoluteFill}
      device={device}
      isActive={true}
    />
  )
}

See the example app

Adopting at scale

This library helped you? Consider sponsoring!

VisionCamera is provided as is, I work on it in my free time.

If you're integrating VisionCamera in a production app, consider funding this project and contact me to receive premium enterprise support, help with issues, prioritize bugfixes, request features, help at integrating VisionCamera and/or Frame Processors, and more.

Socials

react-native-vision-camera's People

Contributors

bear-junior avatar dependabot[bot] avatar developerantoniosousa avatar didithilmy avatar erwanlpfr avatar g0retz avatar hirbod avatar hrupesh avatar janicduplessis avatar manuelbieh avatar mateusz1913 avatar menardi avatar mrousavy avatar nilskrause avatar nonam4 avatar ntkrieger avatar parlet avatar paulrostorp avatar philparzer avatar rbarman avatar rhysjosmin avatar rocket13011 avatar rodgomesc avatar romick2005 avatar rutvik24 avatar simek avatar thomas-coldwell avatar titozzz avatar vonovak avatar xulihang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-vision-camera's Issues

โ“ How to use `frameProcessorFps`?

What

I've created a frame processor using ImageLabeler as template.
It completes in 200ms per frame
So I tried frameProcessorFps={2} and the default one, but anyway Frames got dropped.
Should it throttle frames before FrameProcessor gets into play or am I missing something?

Logs

2021-06-08 12:38:17.886942+0300  Warning: Frame Processor function took 192 ms to execute. This blocks the video queue from recording, optimize your frame processor!
2021-06-08 12:38:17.887228+0300  [native] VisionCamera.captureOutput(_:didDrop:from:): Dropped a Frame. This might indicate that your Frame Processor is doing too much work. Either throttle the frame processor's frame rate, or optimize your frame processor's execution speed. Frame drop reason: FrameWasLate
2021-06-08 12:38:17.888389+0300  [javascript] [native] VisionCamera.captureOutput(_:didDrop:from:): Dropped a Frame. This might indicate that your Frame Processor is doing too much work. Either throttle the frame processor's frame rate, or optimize your frame processor's execution speed. Frame drop reason: FrameWasLate

Reproducable sample

The frame processor itself

//
//  VisionCameraQRScanner.m
//
//  Created by Sergei Mitrofanov on 07.06.21.
//

#import <VisionCamera/FrameProcessorPlugin.h>
#import <UIKit/UIKit.h>
#import <React/RCTLog.h>
#import <React/RCTUtils.h>

@interface QRCodeFrameProcessorPlugin : NSObject

+ (CIDetector*) detector;

@end

@implementation QRCodeFrameProcessorPlugin

+ (CIDetector*) detector {
  static CIDetector* detector = nil;
  if (detector == nil) {
    NSDictionary *detectorOptions = @{@"CIDetectorAccuracy": @"CIDetectorAccuracyHigh"};
    detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:detectorOptions];
  }
  return detector;
}

static inline id scanQRCodes(CMSampleBufferRef buffer, NSArray* arguments) {
  CVImageBufferRef cvImage = CMSampleBufferGetImageBuffer(buffer);
  CIImage *ciImage = [[CIImage alloc] initWithCVPixelBuffer:cvImage];

  NSArray* features = [[QRCodeFrameProcessorPlugin detector] featuresInImage:ciImage];
  NSMutableArray* results = [NSMutableArray arrayWithCapacity:features.count];
  for (CIQRCodeFeature* feature in features) {
    [results addObject:feature.messageString];
  }

  return results;
}

VISION_EXPORT_FRAME_PROCESSOR(scanQRCodes)

@end

Environment

  • Platform(s):
    • iOS
    • Android
  • react-native version: 0.64.1
  • react-native-vision-camera version: 2.2.0
  • react-native-reanimated version: 2.2.0

โ“

can we play hls live streaming through this library.

โœจ Event for Interruptions

Interruptions such as incoming phone calls, alarms, etc are handled automatically and remove the audio input so the camera is still functional.

It would be great to know about those interruptions, to e.g. display an alert to the user. Example:

image

Also, other interruptions such as AVCaptureSession or AVAudioSession interruptions could be propagated to the React JS land via events (begin and end events).

There would probably be four new events added to the Camera component:

  • onCameraInterrupted
  • onCameraInterruptionEnded
  • onAudioInterrupted
  • onAudioInterruptionEnded

โ“ Is it possible to use it with react-native-webrtc?

Hi,
Thank you for this library, it's a very good job !

I'm working on video chat app with webrtc with react-native-webrtc.
In your documentation you say that we can use Frame Processor to build realtime video chat app. Have you more informations about it ?

react-native-webrc use it own "getUserMedia" implementation. Do you think it's possible to use your library too with webrtc ? and how ?

thx
Jeremie.

โœจ Events for onFormatChanged, onDeviceChanged, onBeginInitialize

Hi,
If we don't want to specify a format the Camera automatically chooses the best matching format for the current camera device.

I would like to know if there is a way to know which format has been automatically choosen in order to have all information concerning this format (field of view, ...).

Many thanks !

๐Ÿ› Camera start and stop issues

Looks like camera device is struggled to start and stop immediately

What

We are building an app with React Navigation.
So each screen is actually a view, that is manipulated by the library on navigation.

I have found that if I "open a screen" with the CameraView being active by default, there are problems:

  • the frame processor doesn't get called on iOS
  • on some Android devices turning on flashlight leads to crash.

If I add a delay before making CameraView active like so:

  useEffect(() => {
    if (!visible) {
      setTrueVisible(false);
      return () => {};
    }
    const timeout = setTimeout(() => setTrueVisible(true), 20);
    return () => clearTimeout(timeout);
  }, [visible, setTrueVisible]);

And the same applies to the CameraView destroying.
When I navigate back, the camera stays active (can be seen by green dot indicator in iPhone).

But if I first make it inactive and then navigate back after a small delay - all is fine.

Tried to update the library to the lates version (2.4.1) - same result.

Is this delay mandatory or smith else is the source of the issue?

Logs

The problem was found by lack of logs.
Actually there are no errors in the logs. Just actual misbehavior...
ยฏ_(ใƒ„)_/ยฏ

Reproducable sample

Try to add this view and alter visible prop. Mb by button.

import React, { useEffect, useMemo, useRef } from 'react';
import { StyleSheet, NativeModules, NativeEventEmitter } from 'react-native';
import {
  Camera,
  useCameraDevices,
  useFrameProcessor,
} from 'react-native-vision-camera';

import useAppState from '../../../hooks/useAppState';
import { useCameraPermissions } from '../hooks';
import { PermissionStatus } from '../types';
import scanQRCodes from '../../../util/vision-camera-qr-scanner';

export default ({ visible, flash, onScannedCodes }: Props) => {
  const camera = useRef<Camera>(null);
  const { status } = useCameraPermissions();
  const devices = useCameraDevices();
  const appState = useAppState();
  const device = useMemo(
    () => (status === PermissionStatus.allowed ? devices.back : undefined),
    [devices, status]
  );
  const isForeground = useMemo(() => visible && appState === 'active', [
    visible,
    appState,
  ]);

  useEffect(() => {
    const subscription = eventEmitter?.addListener(
      'onQRCodesScanned',
      (result) => onScannedCodes?.(result.codes)
    );
    return () => subscription?.remove();
  }, []);

  const frameProcessor = useFrameProcessor(
    (frame) => {
      'worklet';

      scanQRCodes(frame);
    },
    [scanQRCodes]
  );

  return device ? (
    <Camera
      ref={camera}
      style={StyleSheet.absoluteFill}
      device={device}
      torch={visible && flash ? 'on' : 'off'}
      isActive={isForeground}
      frameProcessor={frameProcessor}
      frameProcessorFps={2}
      photo
      video
    />
  ) : null;
};

Environment

  • Platform(s):
    • [V] iOS
    • [V] Android
  • react-native version: 0.64.1
  • react-native-vision-camera version: 2.2.0
  • react-native-reanimated version: 2.2.0

๐Ÿ›Command Libtool failed with a nonzero exit code

Type

  • [ X] I'm experiencing a full app crash
  • A feature is not working correctly

What

Installation fail

Error

Libtool /Users/truongnguyen/Library/Developer/Xcode/DerivedData/X-dyftosiimfwvyygvyuvlazscpsak/Build/Products/Debug-iphonesimulator/react-native-vision-camera/libreact-native-vision-camera.a normal (in target 'react-native-vision-camera' from project 'Pods')
cd /Volumes/Untitled/Documents/current_desktop/X/ios/Pods
export IPHONEOS_DEPLOYMENT_TARGET=11.0
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only x86_64 -D -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk -L/Users/truongnguyen/Library/Developer/Xcode/DerivedData/X-dyftosiimfwvyygvyuvlazscpsak/Build/Products/Debug-iphonesimulator/react-native-vision-camera -filelist /Users/truongnguyen/Library/Developer/Xcode/DerivedData/X-dyftosiimfwvyygvyuvlazscpsak/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-vision-camera.build/Objects-normal/x86_64/react-native-vision-camera.LinkFileList -dependency_info /Users/truongnguyen/Library/Developer/Xcode/DerivedData/X-dyftosiimfwvyygvyuvlazscpsak/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-vision-camera.build/Objects-normal/x86_64/react-native-vision-camera_libtool_dependency_info.dat -o /Users/truongnguyen/Library/Developer/Xcode/DerivedData/X-dyftosiimfwvyygvyuvlazscpsak/Build/Products/Debug-iphonesimulator/react-native-vision-camera/libreact-native-vision-camera.a

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Users/truongnguyen/Library/Developer/Xcode/DerivedData/X-dyftosiimfwvyygvyuvlazscpsak/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-vision-camera.build/Objects-normal/x86_64/CameraViewManager-e5b2f19a5a2dc9ad5de82588b81358ee07c213da12b16015a11a8df253e24b68.o is not an object file (not allowed in a library)

Environment

  • Platform(s):
    • iOS
    • Android
  • react-native version: 0.64.0
  • react-native-vision-camera version: latest
  • react-native-reanimated version: 2.0.1

๐Ÿ› The Swift pod `VisionCamera` depends upon `React-Core`, which does not define modules.

What

Hi!

After installing the library on a react native project version: 0.63.2 I get the error below in Logs when running npx pod-install .

If I add use_modular_headers I get this issue at build time for glog pod. -> Import of module 'glog.glog.log_severity' appears within namespace 'google'

Any guidance on how to get past this issue is much appreciated.

Logs

The Swift pod `VisionCamera` depends upon `React-Core`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

Reproducable sample

// code here

Environment

  • Platform(s):
    • iOS
    • Android
  • react-native version: 0.63.3
  • react-native-vision-camera version: 2.0.0
  • react-native-reanimated version: 2.1.0

๐Ÿ› Android unknown crash

device id of undefined

Camera.tsx

  static getDerivedStateFromProps(props: CameraProps, state: CameraState): CameraState | null {
    const newCameraId = props.device.id;
    if (state.cameraId !== newCameraId) return { ...state, cameraId: newCameraId };
    return null;
  }

my code check

if(device && device.id) {
    console.log(device.id)
  }

crash app

android 10
xiaomi note 7

A Dumb Questionโ“

How does the Camera api work in the example app if it does not have "react-native-vision-camera" in its package.json

Just to confirm I even checked inside node_modules and yarn.lock but nope, its not installed in the example app.

Maybe thats why I'm unable to run the Camera api?

โ“ Disable default "wide-angle-camera" as a default

First of all, thank you for such brilliant library ๐Ÿ‘ ๐Ÿฅ‡

Just wanted to know how to set the default zoom value of camera to normal for both platforms? ๐Ÿ™‚But still have an ability to zoom out if ["wide-angle-camera"] exists on the device

P.s. I read your documentation page and looked to the example project but still can't figure out how to disable ["wide-angle-camera"] as a default zoom once the camera is open.

Thank you in advance!

How can i install type definitions? โ“

How to use the module without type definitions?

Hi, i saw your post about the Camera library on Reddit and directly wanted to try it out in my Typescript project. I also can see that you use Typescript in the Project. But my project is complaining, that there are no type definitions. How can i install them or use your module now? :)

๐Ÿ› 'folly/Optional.h' file not found on Xcode version 12.5

What

Can't run on Xcode v12.5, it shows 'folly/Optional.h' file not found.
Not sure if it's related to facebook/flipper#2215

Logs

Screen Shot 2021-06-11 at 12 00 33 AM

Reproducable sample

  1. Create a new react native project
  2. Install react-native-vision-camera
  3. Build and run on Xcode v12.5

Environment

  • Platform(s):
    • [V] iOS
    • Android
  • react-native version: 0.63.4
  • react-native-vision-camera version: 2.3.0
  • react-native-reanimated version: N/A

โ“ API docs?

I was hoping to explore some API docs for the camera. Do you have those available somewhere or should I just rely on the example app for now?

โœจ Android: Return Video size and duration

On Android the video duration and size are not set correctly because CameraX doesn't provide that information in the Callback.

https://github.com/cuvent/react-native-vision-camera/blob/dff8fc71788311c324e6eb80976a6ec50596d3e5/android/src/main/java/com/mrousavy/camera/CameraView%2BRecordVideo.kt#L32-L36

The only workaround for this would be reading the Video's Metadata, but that's an extra overhead I don't want to introduce.

With frame processors I'm going to have to create a custom Video recorder and encoder anyways, I can manually use a stopwatch for this then. So #2 probably fixes this issue.

๐Ÿ› An unknown camera error occured on Samsung Galaxy Note10+

What

The camera preview will not initialise on Samsung Galaxy Note10+. const devices = useCameraDevices(); remains undefined.

Logs

 LOG  re-rendering camera page without active camera
 WARN  Possible Unhandled Promise Rejection (id: 0):
unknown/unknown: [unknown/unknown] An unknown camera error occured.
[unknown/unknown]: [unknown/unknown] An unknown camera error occured.
    at construct (native)
    at apply (native)
    at _construct (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:118386:28)
    at Wrapper (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:118339:64)
    at construct (native)
    at _createSuperInternal (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:118135:322)
    at call (native)
    at CameraError (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:118148:26)
    at construct (native)
    at _createSuperInternal (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:118135:322)
    at apply (native)
    at CameraRuntimeError (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:118203:27)
    at tryParseNativeCameraError (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:118226:38)
    at getAvailableCameraDevices$ (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:117201:102)
    at call (native)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:117446:23)
    at invoke (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:117619:32)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:117489:30)
    at call (native)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:117446:23)
    at invoke (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:117519:30)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:117531:21)
    at tryCallOne (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:30482:16)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:30583:27)
    at apply (native)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:31111:26)
    at _callTimer (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:30999:17)
    at _callImmediatesPass (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:31038:17)
    at callImmediates (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:31256:33)
    at __callImmediates (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:8072:35)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:7850:34)
    at __guard (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:8055:15)
    at flushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:7849:21)
    at invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mrousavy.camera.example&modulesOnly=false&runModule=true:7842:33)
 LOG  re-rendering camera page without active camera

Reproducable sample

react-native-vision-camera example code.

๐Ÿ’จ Make image flipping faster

Type

  • Enhancement for an existing feature
  • An entirely new feature

What

Images from the front camera (selfie) are automatically mirrored (flipped horizontally). The flip function (introduced in #129) works by converting the byte[] to a Bitmap to perform a matrix transformation, then compresses it back into the byte[].

https://github.com/cuvent/react-native-vision-camera/blob/f57714747a2587916c4e7c47bfe2586b1e8966ff/android/src/main/java/com/mrousavy/camera/utils/ImageProxy.save.kt#L44-L52

This byte[] -> Bitmap -> byte[] conversion is a bit of an overhead I'd like to eliminate, even if it only takes 24ms to execute on my Huawai P10. Here are the full benchmarks:

Back camera (no flipping):

2021-05-03 18:57:54.478 31448-31448/com.mrousavy.camera.example I/CameraView.performance: Session configured in 200 ms! Camera: androidx.camera.lifecycle.LifecycleCamera@c475d4
2021-05-03 18:58:17.609 31448-31729/com.mrousavy.camera.example I/CameraView.performance: Finished creating temp file in 1ms
2021-05-03 18:58:18.028 31448-31448/com.mrousavy.camera.example I/CameraView.performance: Finished image capture in 413ms
2021-05-03 18:58:18.033 31448-31729/com.mrousavy.camera.example I/CameraView.performance: Finished image saving in 3ms
2021-05-03 18:58:18.035 31448-31448/com.mrousavy.camera.example I/CameraView.performance: Finished function execution in 444ms

Front camera (flipping):

2021-05-03 18:58:50.155 31448-31448/com.mrousavy.camera.example I/CameraView.performance: Session configured in 129 ms! Camera: androidx.camera.lifecycle.LifecycleCamera@4e5ccc6
2021-05-03 18:58:52.032 31448-31729/com.mrousavy.camera.example I/CameraView.performance: Finished creating temp file in 2ms
2021-05-03 18:58:52.345 31448-31448/com.mrousavy.camera.example I/CameraView.performance: Finished image capture in 314ms
2021-05-03 18:58:52.379 31448-31729/com.mrousavy.camera.example I/CameraView.performance: Flipping Image took 31 ms.
2021-05-03 18:58:52.380 31448-31729/com.mrousavy.camera.example I/CameraView.performance: Finished image saving in 33ms
2021-05-03 18:58:52.381 31448-31448/com.mrousavy.camera.example I/CameraView.performance: Finished function execution in 353ms

Alternatives/Workarounds

I have tried to toggle some flags in the byte[] in-memory, hoping I could flip the relevant Exif flag. I have discovered that the AndroidX ExifInterface does not support writing to in-memory files (why??), so I tried to roll my own approach:

https://github.com/cuvent/react-native-vision-camera/blob/f57714747a2587916c4e7c47bfe2586b1e8966ff/android/src/main/java/com/mrousavy/camera/utils/ImageProxy.save.kt#L19-L41

that unfortunately doesn't work and returns a black image. Maybe this can be of help?

On iOS this can be achieved with no overhead at all by directly mirroring the output connection inside the Camera pipeline, unfortunately CameraX does not provide this functionality.

โœจ Use lossless compressed Video formats

What

At the WWDC 2021, iOS 15 was introduced alongside with losslessly compressed video formats. Those formats offer greater efficiency by reducing the amount of memory bandwidth used internally for the video queue/pipeline.

Until right now, formats such as 420v (video range) or 420f (full range) were used. With the possibility of providing lossless compressed formats, video recordings would be more efficient while nothing changes for the API.

Lossless compressed video formats are enabled for AVCaptureMovieFile per default, but since we're not using the movie capture helper class but rather a custom AVCaptureVideoDataOutput delegate, we have to manually make use of the losslessly compressed format.

I am also pretty sure that this only works when no frame processor is used, as I don't know how some algorithms are going to react when they receive a compressed buffer.

WWDC source: https://developer.apple.com/videos/play/wwdc2021/10047/

โ“Android Frame processor

Question

Do you have any estimation on Frame processor for Android?
Or mb you need some help with it?
Desperately need that :-)

๐Ÿ› iOS release build error

What

Doesn't build on release mode but builds on debug mode.

Logs

<unknown>:0: error: module map file โ€˜/Users/davidangulo/Library/Developer/Xcode/DerivedData/project_mobile-erivebwhxgzkcgcenpcxgkdgfiqi/Build/Intermediates.noindex/ArchiveIntermediates/project_mobile/BuildProductsPath/Release-iphoneos/VisionCamera/VisionCamera.modulemapโ€™ not found
1 error generated.
<unknown>:0: error: failed to emit precompiled header โ€˜/Users/davidangulo/Library/Developer/Xcode/DerivedData/project_mobile-erivebwhxgzkcgcenpcxgkdgfiqi/Build/Intermediates.noindex/ArchiveIntermediates/project_mobile/PrecompiledHeaders/project_mobile-Bridging-Header-swift_2G0UQ3CJSS46M-clang_2YKEVN7TTCF9E.pchโ€™ for bridging header โ€˜/Users/davidangulo/Documents/projects/project_mobile/ios/project_mobile-Bridging-Header.hโ€™
3 errors generated.

Reproducable sample

// code here

Environment

  • Platform(s):
    • iOS
    • Android
  • react-native version: 0.64.1
  • react-native-vision-camera version: 2.1.0
  • react-native-reanimated version: 1.13.2

Solution

What worked for me is this answer: https://stackoverflow.com/a/46523347/9375533

Aside from setting platform :ios to 11.0, I also need to update iOS Deployment Target to 11.0

Screen Shot 2021-06-04 at 11 21 11 PM

Maybe we should add it to the docs? Specifically https://github.com/cuvent/react-native-vision-camera/blob/main/docs/docs/guides/TROUBLESHOOTING.mdx

โ“ How to stop camera usage

Question

Currently I have and app utilizing react navigation.
When I start the app all is fine.
When I navigate to the screen with the Camera view, all is also fine.
And there is a green dot above network state on iPhone, signaling that camera is in use.

But when I navigate back to the main screen (CameraView is gone) the green dot stays.
Which means the camera is still in use.

When I leave the app the indicator dot disappears.

But when I return to the app, the dot appears again. Despite there is no more CameraView on the screen.

And looks like isActive, photo and video has no effect on the green dot...

So how to stop camera usage when CameraView is not on the screen?

My current usage code:

  const isForeground = visible && appState === 'active';
...
      {device ? (
        <Camera
          ref={camera}
          style={StyleSheet.absoluteFill}
          device={device}
          torch={visible && flash ? 'on' : 'off'}
          isActive={isForeground}
          frameProcessor={Platform.select({
            ios: frameProcessor,
            default: undefined,
          })}
          frameProcessorFps={2}
          photo={isForeground}       // <--- added flag here to check if this hash effect - no effect
          video={isForeground}       // <--- added flag here to check if this hash effect - no effect
        />
      ) : null}
...

โœจ Android: Support takePhoto(...) options

The following takePhoto(...) options are not yet implemented on Android:

๐Ÿ› Selfie on Android Pixel 2 XL (OS version 11) is rotated

What

Platform: Android
Tested OS version: Android 11
Devices tested: Pixel 2 XL and Pixel 3a
library version: 1.0.11

I notice using both my app and your example is that Selfie images are rotated 90 degrees counterclockwise. I checked the metadata on my app and I can see Orientation is 0 (I believe this is 0 degrees?).

at the moment I cannot move up to 2.0 as reanimaed 2,0 has debugging issues due to TurboModules.

Reproducable sample

  1. Open the example app
  2. switch to selfie camera
  3. capture an image

The preview of the captured image appears rotated 90 degrees counter clockwise

Environment

  • Platform(s):
    • iOS
    • [ X] Android
  • react-native version: _0.64
  • react-native-vision-camera version: 1.0.11_
  • react-native-reanimated version: N/A

โœจ Return mime (content type) from video recordings

What

I noticed that the Video File object does not include the mime type. Including it in the VideFile would benefit those using the video to send over networks.

Alternatives/Workarounds

I am going to use https://www.npmjs.com/package/react-native-mime-types in order to get the mime from the file

import * as mime from "react-native-mime-types";

camera.current.startRecording({
    flash: flash,
    onRecordingError: (error) => {
        onStoppedRecording();
    },
    onRecordingFinished: (video) => {
        const videoSource = {
            path: video.path,
            mimeType: mime.lookup(video.path),
        };
        onMediaCaptured(video, "video");
        onStoppedRecording();
    },
});

๐Ÿ› [Android] Unmounting CameraView throw react-native-reanimated issue

What

When unmounting the Camera component (wrapped in another one), throws an Error: Frame Processors are not enabled. Make sure you install react-native-reanimated 2.1.0 or above!.

Capture+_2021-05-25-16-05-34

On iOS everything works fine...

Btw, react-native-reanimated is installed because others libs depends on it and they works fine.

Logs

2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven: Rejecting re-init on previously-failed class java.lang.Class<androidx.camera.extensions.ExtensionsManager$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/camera/extensions/impl/InitializerImpl$OnExtensionsDeinitializedCallback;
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at com.google.common.util.concurrent.ListenableFuture androidx.camera.extensions.ExtensionsManager.init(android.content.Context) (ExtensionsManager.java:120)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object com.mrousavy.camera.CameraViewModule$getAvailableCameraDevices$1.invokeSuspend(java.lang.Object) (CameraViewModule.kt:102)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(java.lang.Object) (ContinuationImpl.kt:33)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void kotlinx.coroutines.DispatchedTask.run() (DispatchedTask.kt:106)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:873)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Looper.loop() (Looper.java:205)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6991)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:884)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven: Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.camera.extensions.impl.InitializerImpl$OnExtensionsDeinitializedCallback" on path: DexPathList[[zip file "/data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/lib/arm64, /data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64, /system/vendor/lib64]]
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:134)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at com.google.common.util.concurrent.ListenableFuture androidx.camera.extensions.ExtensionsManager.init(android.content.Context) (ExtensionsManager.java:120)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object com.mrousavy.camera.CameraViewModule$getAvailableCameraDevices$1.invokeSuspend(java.lang.Object) (CameraViewModule.kt:102)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(java.lang.Object) (ContinuationImpl.kt:33)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void kotlinx.coroutines.DispatchedTask.run() (DispatchedTask.kt:106)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:873)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Looper.loop() (Looper.java:205)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6991)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
2021-05-25 16:01:12.685 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:884)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven: Rejecting re-init on previously-failed class java.lang.Class<androidx.camera.extensions.ExtensionsManager$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/camera/extensions/impl/InitializerImpl$OnExtensionsDeinitializedCallback;
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at com.google.common.util.concurrent.ListenableFuture androidx.camera.extensions.ExtensionsManager.init(android.content.Context) (ExtensionsManager.java:120)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object com.mrousavy.camera.CameraViewModule$getAvailableCameraDevices$1.invokeSuspend(java.lang.Object) (CameraViewModule.kt:102)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(java.lang.Object) (ContinuationImpl.kt:33)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void kotlinx.coroutines.DispatchedTask.run() (DispatchedTask.kt:106)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:873)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Looper.loop() (Looper.java:205)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6991)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:884)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven: Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.camera.extensions.impl.InitializerImpl$OnExtensionsDeinitializedCallback" on path: DexPathList[[zip file "/data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/lib/arm64, /data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64, /system/vendor/lib64]]
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:134)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at com.google.common.util.concurrent.ListenableFuture androidx.camera.extensions.ExtensionsManager.init(android.content.Context) (ExtensionsManager.java:120)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object com.mrousavy.camera.CameraViewModule$getAvailableCameraDevices$1.invokeSuspend(java.lang.Object) (CameraViewModule.kt:102)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(java.lang.Object) (ContinuationImpl.kt:33)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void kotlinx.coroutines.DispatchedTask.run() (DispatchedTask.kt:106)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:873)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Looper.loop() (Looper.java:205)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6991)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
2021-05-25 16:01:12.686 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:884)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven: Rejecting re-init on previously-failed class java.lang.Class<androidx.camera.extensions.ExtensionsManager$1>: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/camera/extensions/impl/InitializerImpl$OnExtensionsInitializedCallback;
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at com.google.common.util.concurrent.ListenableFuture androidx.camera.extensions.ExtensionsManager.init(android.content.Context) (ExtensionsManager.java:120)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object com.mrousavy.camera.CameraViewModule$getAvailableCameraDevices$1.invokeSuspend(java.lang.Object) (CameraViewModule.kt:102)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(java.lang.Object) (ContinuationImpl.kt:33)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void kotlinx.coroutines.DispatchedTask.run() (DispatchedTask.kt:106)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:873)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Looper.loop() (Looper.java:205)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6991)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:884)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven: Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.camera.extensions.impl.InitializerImpl$OnExtensionsInitializedCallback" on path: DexPathList[[zip file "/data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/lib/arm64, /data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64, /system/vendor/lib64]]
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:134)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at com.google.common.util.concurrent.ListenableFuture androidx.camera.extensions.ExtensionsManager.init(android.content.Context) (ExtensionsManager.java:120)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object com.mrousavy.camera.CameraViewModule$getAvailableCameraDevices$1.invokeSuspend(java.lang.Object) (CameraViewModule.kt:102)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(java.lang.Object) (ContinuationImpl.kt:33)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void kotlinx.coroutines.DispatchedTask.run() (DispatchedTask.kt:106)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:873)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Looper.loop() (Looper.java:205)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6991)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
2021-05-25 16:01:12.687 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:884)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven: Rejecting re-init on previously-failed class java.lang.Class<androidx.camera.extensions.ExtensionsManager$1>: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/camera/extensions/impl/InitializerImpl$OnExtensionsInitializedCallback;
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at com.google.common.util.concurrent.ListenableFuture androidx.camera.extensions.ExtensionsManager.init(android.content.Context) (ExtensionsManager.java:120)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object com.mrousavy.camera.CameraViewModule$getAvailableCameraDevices$1.invokeSuspend(java.lang.Object) (CameraViewModule.kt:102)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(java.lang.Object) (ContinuationImpl.kt:33)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void kotlinx.coroutines.DispatchedTask.run() (DispatchedTask.kt:106)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:873)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Looper.loop() (Looper.java:205)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6991)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:884)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven: Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.camera.extensions.impl.InitializerImpl$OnExtensionsInitializedCallback" on path: DexPathList[[zip file "/data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/lib/arm64, /data/app/com.smarteven-LiELhOZIgGJtrNIBbCJSYw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64, /system/vendor/lib64]]
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:134)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at com.google.common.util.concurrent.ListenableFuture androidx.camera.extensions.ExtensionsManager.init(android.content.Context) (ExtensionsManager.java:120)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object com.mrousavy.camera.CameraViewModule$getAvailableCameraDevices$1.invokeSuspend(java.lang.Object) (CameraViewModule.kt:102)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(java.lang.Object) (ContinuationImpl.kt:33)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void kotlinx.coroutines.DispatchedTask.run() (DispatchedTask.kt:106)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:873)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void android.os.Looper.loop() (Looper.java:205)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6991)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
2021-05-25 16:01:12.688 21551-21551/com.smarteven I/com.smarteven:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:884)
2021-05-25 16:01:12.694 21551-21551/com.smarteven D/ExtenderVersion: No versioning extender found. Falling back to default.
2021-05-25 16:01:12.734 21551-21693/com.smarteven E/CameraManager: /vendor/etc/camera/auxpackagelist.txt
2021-05-25 16:01:12.735 21551-21693/com.smarteven I/CameraManagerGlobal: Connecting to camera service
2021-05-25 16:01:12.741 21551-21693/com.smarteven I/CameraManagerGlobal: List is unavailable
2021-05-25 16:01:12.746 21551-21693/com.smarteven I/chatty: uid=10304(com.smarteven) CameraX-core_ca identical 2 lines
2021-05-25 16:01:12.748 21551-21693/com.smarteven I/CameraManagerGlobal: List is unavailable
2021-05-25 16:01:12.748 21551-21693/com.smarteven W/CameraManagerGlobal: [soar.cts] ignore the status update of camera: 3
2021-05-25 16:01:12.748 21551-21693/com.smarteven E/CameraManagerGlobal: packageList = 
2021-05-25 16:01:12.757 21551-21693/com.smarteven I/CameraManagerGlobal: List is unavailable
2021-05-25 16:01:12.757 21551-21693/com.smarteven E/CameraManagerGlobal:  idCount = 3
2021-05-25 16:01:12.759 21551-21597/com.smarteven I/CameraManagerGlobal: List is unavailable
2021-05-25 16:01:12.761 21551-21597/com.smarteven I/CameraManagerGlobal: List is unavailable
2021-05-25 16:01:12.781 21551-21693/com.smarteven D/CameraRepository: Added camera: 0
2021-05-25 16:01:12.827 21551-21693/com.smarteven I/Camera2CameraInfo: Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_3
2021-05-25 16:01:12.832 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [] for camera: 0
2021-05-25 16:01:12.834 21551-21693/com.smarteven D/CameraRepository: Added camera: 1
2021-05-25 16:01:12.836 21551-21693/com.smarteven I/Camera2CameraInfo: Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED
2021-05-25 16:01:12.836 21551-21693/com.smarteven D/CameraRepository: Added camera: 2
2021-05-25 16:01:12.838 21551-21693/com.smarteven I/Camera2CameraInfo: Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_3
2021-05-25 16:01:12.841 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [] for camera: 1
2021-05-25 16:01:12.842 21551-21551/com.smarteven E/CameraManagerGlobal: packageList = 
2021-05-25 16:01:12.845 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [] for camera: 2
2021-05-25 16:01:12.845 21551-21551/com.smarteven I/CameraManagerGlobal: List is unavailable
2021-05-25 16:01:12.846 21551-21551/com.smarteven E/CameraManagerGlobal:  idCount = 3
2021-05-25 16:01:13.293 21551-21551/com.smarteven W/CameraView: CameraViewModule::getAvailableCameraDevices took: 656 ms
2021-05-25 16:01:13.413 21551-21551/com.smarteven D/CameraView: Lifecycle went from INITIALIZED -> CREATED (isActive: true | isAttachedToWindow: false)
2021-05-25 16:01:13.428 21551-21551/com.smarteven D/CameraView: Lifecycle went from CREATED -> RESUMED (isActive: true | isAttachedToWindow: true)
2021-05-25 16:01:13.432 21551-21551/com.smarteven I/CameraView: onLayout(true, 0, 265, 1440, 2281) was called! (Width: 1440, Height: 2016)
2021-05-25 16:01:13.438 21551-21551/com.smarteven D/CameraView: Lifecycle went from RESUMED -> RESUMED (isActive: true | isAttachedToWindow: true)
2021-05-25 16:01:13.439 21551-21551/com.smarteven I/CameraView: Configuring session...
2021-05-25 16:01:13.442 21551-21551/com.smarteven I/CameraView: Configuring session with Camera ID 0 and default format options...
2021-05-25 16:01:13.456 21551-21551/com.smarteven I/CameraView: No custom format has been set, CameraX will automatically determine best configuration...
2021-05-25 16:01:13.637 21551-21551/com.smarteven D/DeferrableSurface: Surface created[total_surfaces=1, used_surfaces=0](androidx.camera.core.SurfaceRequest$2@f53f315}
2021-05-25 16:01:13.661 21551-21551/com.smarteven D/DeferrableSurface: Surface created[total_surfaces=2, used_surfaces=0](androidx.camera.core.impl.ImmediateSurface@52371b8}
2021-05-25 16:01:13.666 21551-21695/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Use case ImageCapture:androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30 ACTIVE
2021-05-25 16:01:13.667 21551-21695/com.smarteven D/UseCaseAttachState: Active and attached use case: [] for camera: 0
2021-05-25 16:01:13.672 21551-21551/com.smarteven D/MediaCodec: CreateByType mime=video/avc
2021-05-25 16:01:13.675 21551-21551/com.smarteven D/MediaCodec: Mediacodec create pid=21551
2021-05-25 16:01:13.675 21551-21551/com.smarteven D/MediaCodec: init()++ name=OMX.qcom.video.encoder.avc,nameIsType=1
2021-05-25 16:01:13.676 21551-21551/com.smarteven V/LGCodecAdapter: LG Codec Adapter start
2021-05-25 16:01:13.676 21551-21551/com.smarteven V/LGCodecAdapter: load libLGCodecOSAL library
2021-05-25 16:01:13.683 21551-21551/com.smarteven V/LGCodecOSAL: Just Validatation check function
2021-05-25 16:01:13.683 21551-21551/com.smarteven I/ACodec: Now uninitialized
2021-05-25 16:01:13.683 21551-21699/com.smarteven D/MediaCodec: kWhatInit received
2021-05-25 16:01:13.684 21551-21700/com.smarteven I/ACodec: onAllocateComponent
2021-05-25 16:01:13.685 21551-21700/com.smarteven I/OMXClient: IOmx service obtained
2021-05-25 16:01:13.715 21551-21700/com.smarteven D/MediaCodec: onComponentAllocated() componentName=OMX.qcom.video.encoder.avc
2021-05-25 16:01:13.716 21551-21700/com.smarteven I/ACodec: [OMX.qcom.video.encoder.avc] Now Loaded
2021-05-25 16:01:13.716 21551-21699/com.smarteven D/MediaCodec: kWhatComponentAllocated received
2021-05-25 16:01:13.717 21551-21551/com.smarteven D/MediaCodec: init()--
2021-05-25 16:01:13.717 21551-21551/com.smarteven D/MediaCodec: CreateByType mime=audio/mp4a-latm
2021-05-25 16:01:13.718 21551-21551/com.smarteven D/MediaCodec: Mediacodec create pid=21551
2021-05-25 16:01:13.718 21551-21551/com.smarteven D/MediaCodec: init()++ name=OMX.google.aac.encoder,nameIsType=1
2021-05-25 16:01:13.720 21551-21551/com.smarteven V/LGCodecAdapter: LG Codec Adapter start
2021-05-25 16:01:13.720 21551-21551/com.smarteven I/ACodec: Now uninitialized
2021-05-25 16:01:13.720 21551-21705/com.smarteven D/MediaCodec: kWhatInit received
2021-05-25 16:01:13.720 21551-21705/com.smarteven I/ACodec: onAllocateComponent
2021-05-25 16:01:13.721 21551-21705/com.smarteven I/OMXClient: IOmx service obtained
2021-05-25 16:01:13.724 21551-21705/com.smarteven D/MediaCodec: onComponentAllocated() componentName=OMX.google.aac.encoder
2021-05-25 16:01:13.724 21551-21705/com.smarteven I/ACodec: [OMX.google.aac.encoder] Now Loaded
2021-05-25 16:01:13.724 21551-21705/com.smarteven D/MediaCodec: kWhatComponentAllocated received
2021-05-25 16:01:13.724 21551-21551/com.smarteven D/MediaCodec: init()--
2021-05-25 16:01:13.725 21551-21551/com.smarteven D/MediaCodec: reset()
2021-05-25 16:01:13.725 21551-21551/com.smarteven D/MediaCodec: release()
2021-05-25 16:01:13.725 21551-21699/com.smarteven D/MediaCodec: kWhatStop or kWhatRelease received targetState=0 and mState=2
2021-05-25 16:01:13.729 21551-21700/com.smarteven I/ACodec: Now uninitialized
2021-05-25 16:01:13.729 21551-21700/com.smarteven D/MediaCodec: onReleaseCompleted()
2021-05-25 16:01:13.729 21551-21699/com.smarteven D/MediaCodec: kWhatReleaseCompleted received
2021-05-25 16:01:13.730 21551-21551/com.smarteven D/MediaCodec: init()++ name=OMX.qcom.video.encoder.avc,nameIsType=0
2021-05-25 16:01:13.731 21551-21551/com.smarteven V/LGCodecAdapter: LG Codec Adapter start
2021-05-25 16:01:13.731 21551-21551/com.smarteven I/ACodec: Now uninitialized
2021-05-25 16:01:13.731 21551-21699/com.smarteven D/MediaCodec: kWhatInit received
2021-05-25 16:01:13.731 21551-21700/com.smarteven I/ACodec: onAllocateComponent
2021-05-25 16:01:13.733 21551-21700/com.smarteven I/OMXClient: IOmx service obtained
2021-05-25 16:01:13.747 21551-21700/com.smarteven D/MediaCodec: onComponentAllocated() componentName=OMX.qcom.video.encoder.avc
2021-05-25 16:01:13.748 21551-21700/com.smarteven I/ACodec: [OMX.qcom.video.encoder.avc] Now Loaded
2021-05-25 16:01:13.748 21551-21699/com.smarteven D/MediaCodec: kWhatComponentAllocated received
2021-05-25 16:01:13.749 21551-21551/com.smarteven D/MediaCodec: init()--
2021-05-25 16:01:13.751 21551-21699/com.smarteven D/MediaCodec: kWhatConfigure received
2021-05-25 16:01:13.751 21551-21699/com.smarteven V/LGCodecAdapter: called getLGCodecSpecificData
2021-05-25 16:01:13.751 21551-21699/com.smarteven V/LGCodecOSAL: Called LGgetCodecSpecificDataMSG
2021-05-25 16:01:13.753 21551-21700/com.smarteven I/ExtendedACodec: setupVideoEncoder()
2021-05-25 16:01:13.753 21551-21700/com.smarteven W/OMXUtils: do not know color format 0x7fa30c06 = 2141391878
2021-05-25 16:01:13.754 21551-21700/com.smarteven W/OMXUtils: do not know color format 0x7fa30c04 = 2141391876
2021-05-25 16:01:13.755 21551-21700/com.smarteven W/OMXUtils: do not know color format 0x7fa30c08 = 2141391880
2021-05-25 16:01:13.755 21551-21700/com.smarteven W/OMXUtils: do not know color format 0x7fa30c07 = 2141391879
2021-05-25 16:01:13.756 21551-21700/com.smarteven W/OMXUtils: do not know color format 0x7f000789 = 2130708361
2021-05-25 16:01:13.773 21551-21700/com.smarteven I/ACodec: setupAVCEncoderParameters with [profile: Baseline] [level: Level32]
2021-05-25 16:01:13.777 21551-21700/com.smarteven I/ACodec: [OMX.qcom.video.encoder.avc] cannot encode HDR static metadata. Ignoring.
2021-05-25 16:01:13.777 21551-21700/com.smarteven I/ACodec: setupVideoEncoder succeeded
2021-05-25 16:01:13.777 21551-21700/com.smarteven I/ExtendedACodec: [OMX.qcom.video.encoder.avc] configure, AMessage : AMessage(what = 'conf', target = 7) = {
      int32_t color-format = 2130708361
      int32_t i-frame-interval = 1
      string mime = "video/avc"
      int32_t width = 1280
      int32_t bitrate = 8388608
      int32_t frame-rate = 30
      int32_t height = 960
      int32_t encoder = 1
    }
2021-05-25 16:01:13.784 21551-21700/com.smarteven W/OMXUtils: do not know color format 0x7f000789 = 2130708361
2021-05-25 16:01:13.809 21551-21700/com.smarteven W/ExtendedACodec: Failed to get extension for extradata parameter
2021-05-25 16:01:13.809 21551-21700/com.smarteven D/MediaCodec: onComponentConfigured()
2021-05-25 16:01:13.809 21551-21699/com.smarteven D/MediaCodec: kWhatComponentConfigured received
2021-05-25 16:01:13.836 21551-21551/com.smarteven D/DeferrableSurface: Surface created[total_surfaces=3, used_surfaces=0](androidx.camera.core.impl.ImmediateSurface@76eaef7}
2021-05-25 16:01:13.850 21551-21551/com.smarteven D/MediaCodec: reset()
2021-05-25 16:01:13.850 21551-21551/com.smarteven D/MediaCodec: release()
2021-05-25 16:01:13.851 21551-21705/com.smarteven D/MediaCodec: kWhatStop or kWhatRelease received targetState=0 and mState=2
2021-05-25 16:01:13.856 21551-21705/com.smarteven I/ACodec: Now uninitialized
2021-05-25 16:01:13.857 21551-21705/com.smarteven D/MediaCodec: onReleaseCompleted()
2021-05-25 16:01:13.857 21551-21705/com.smarteven D/MediaCodec: kWhatReleaseCompleted received
2021-05-25 16:01:13.859 21551-21551/com.smarteven D/MediaCodec: init()++ name=OMX.google.aac.encoder,nameIsType=0
2021-05-25 16:01:13.861 21551-21551/com.smarteven V/LGCodecAdapter: LG Codec Adapter start
2021-05-25 16:01:13.861 21551-21551/com.smarteven I/ACodec: Now uninitialized
2021-05-25 16:01:13.861 21551-21705/com.smarteven D/MediaCodec: kWhatInit received
2021-05-25 16:01:13.861 21551-21705/com.smarteven I/ACodec: onAllocateComponent
2021-05-25 16:01:13.864 21551-21705/com.smarteven I/OMXClient: IOmx service obtained
2021-05-25 16:01:13.866 21551-21705/com.smarteven D/MediaCodec: onComponentAllocated() componentName=OMX.google.aac.encoder
2021-05-25 16:01:13.866 21551-21705/com.smarteven I/ACodec: [OMX.google.aac.encoder] Now Loaded
2021-05-25 16:01:13.867 21551-21705/com.smarteven D/MediaCodec: kWhatComponentAllocated received
2021-05-25 16:01:13.867 21551-21551/com.smarteven D/MediaCodec: init()--
2021-05-25 16:01:13.869 21551-21705/com.smarteven D/MediaCodec: kWhatConfigure received
2021-05-25 16:01:13.869 21551-21705/com.smarteven V/LGCodecAdapter: called getLGCodecSpecificData
2021-05-25 16:01:13.869 21551-21705/com.smarteven V/LGCodecOSAL: Called LGgetCodecSpecificDataMSG
2021-05-25 16:01:13.872 21551-21705/com.smarteven W/ExtendedACodec: Failed to get extension for extradata parameter
2021-05-25 16:01:13.872 21551-21705/com.smarteven D/MediaCodec: onComponentConfigured()
2021-05-25 16:01:13.872 21551-21705/com.smarteven D/MediaCodec: kWhatComponentConfigured received
2021-05-25 16:01:13.877 21551-21551/com.smarteven D/AudioRecord: getMinFrameCount 320
2021-05-25 16:01:13.877 21551-21567/com.smarteven V/AudioSystem: ioConfigChanged() event 0
2021-05-25 16:01:13.877 21551-21567/com.smarteven V/AudioSystem: ioConfigChanged() event 0
2021-05-25 16:01:13.878 21551-21551/com.smarteven D/AudioRecord: set(): inputSource 1, sampleRate 8000, format 0x1, channelMask 0x10, frameCount 640, notificationFrames 0, sessionId 0, transferType 0, flags 0, opPackageName com.smarteven uid -1, pid -1
2021-05-25 16:01:13.878 21551-21551/com.smarteven V/AudioRecord: Building AudioRecord with attributes: source=1 flags=0x0 tags=[]
2021-05-25 16:01:13.878 21551-21551/com.smarteven D/AudioRecord: set: Create AudioRecordThread
2021-05-25 16:01:13.878 21551-21567/com.smarteven V/AudioSystem: ioConfigChanged() event 0
2021-05-25 16:01:13.887 21551-21597/com.smarteven V/AudioSystem: ioConfigChanged() event 5
2021-05-25 16:01:13.892 21551-21551/com.smarteven I/VideoCapture: source: 1 audioSampleRate: 8000 channelConfig: 16 audioFormat: 2 bufferSize: 640
2021-05-25 16:01:13.896 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Use case Preview:androidx.camera.core.Preview-1f60161e-782e-47ed-aa5e-d34f11bc9b33 INACTIVE
2021-05-25 16:01:13.897 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [] for camera: 0
2021-05-25 16:01:13.899 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Use case ImageCapture:androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30 ACTIVE
2021-05-25 16:01:13.900 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [] for camera: 0
2021-05-25 16:01:13.901 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Use case androidx.camera.core.VideoCapture@a3a6ea0 INACTIVE
2021-05-25 16:01:13.901 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [] for camera: 0
2021-05-25 16:01:13.901 21551-21551/com.smarteven D/CameraOrientationUtil: getRelativeImageRotation: destRotationDegrees=0, sourceRotationDegrees=90, isOppositeFacing=true, result=90
2021-05-25 16:01:13.903 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [] for camera: 0
2021-05-25 16:01:13.903 21551-21551/com.smarteven I/CameraView.performance: Session configured in 464 ms! Camera: androidx.camera.lifecycle.LifecycleCamera@97da22b
2021-05-25 16:01:13.905 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Use cases [Preview:androidx.camera.core.Preview-1f60161e-782e-47ed-aa5e-d34f11bc9b33, ImageCapture:androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30, androidx.camera.core.VideoCapture@a3a6ea0] now ATTACHED
2021-05-25 16:01:13.908 21551-21694/com.smarteven D/UseCaseAttachState: All use case: [androidx.camera.core.Preview-1f60161e-782e-47ed-aa5e-d34f11bc9b3394142162, androidx.camera.core.VideoCapture-1b2ef0d2-ce42-4045-8615-638af38f39fa171601568, androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30179448739] for camera: 0
2021-05-25 16:01:13.909 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30179448739] for camera: 0
2021-05-25 16:01:13.909 21551-21551/com.smarteven D/PreviewView: Surface requested by Preview.
2021-05-25 16:01:13.915 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Resetting Capture Session
2021-05-25 16:01:13.917 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Releasing session in state INITIALIZED
2021-05-25 16:01:13.919 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Attempting to force open the camera.
2021-05-25 16:01:13.920 21551-21694/com.smarteven D/CameraStateRegistry: tryOpenCamera(Camera@39de09[id=0]) [Available Cameras: 1, Already Open: false (Previous state: null)] --> SUCCESS
2021-05-25 16:01:13.922 21551-21694/com.smarteven D/CameraStateRegistry: Recalculating open cameras:
    Camera                                       State                 
    -------------------------------------------------------------------
    Camera@39de09[id=0]                          OPENING               
    Camera@da8a428[id=1]                         UNKNOWN               
    Camera@561d040[id=2]                         UNKNOWN               
    -------------------------------------------------------------------
    Open count: 1 (Max allowed: 1)
2021-05-25 16:01:13.922 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Opening camera.
2021-05-25 16:01:13.923 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Transitioning camera internal state: INITIALIZED --> OPENING
2021-05-25 16:01:13.924 21551-21694/com.smarteven D/CameraStateMachine: New public camera state CameraState{type=OPENING, error=null} from OPENING and null
2021-05-25 16:01:13.924 21551-21694/com.smarteven D/CameraStateMachine: Publishing new public camera state CameraState{type=OPENING, error=null}
2021-05-25 16:01:13.925 21551-21694/com.smarteven D/UseCaseAttachState: All use case: [androidx.camera.core.Preview-1f60161e-782e-47ed-aa5e-d34f11bc9b3394142162, androidx.camera.core.VideoCapture-1b2ef0d2-ce42-4045-8615-638af38f39fa171601568, androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30179448739] for camera: 0
2021-05-25 16:01:13.925 21551-21551/com.smarteven D/PreviewView: Preview transformation info updated. TransformationInfo{cropRect=Rect(0, 0 - 1280, 960), rotationDegrees=90, targetRotation=0}
2021-05-25 16:01:13.926 21551-21551/com.smarteven D/PreviewTransform: Transformation info set: TransformationInfo{cropRect=Rect(0, 0 - 1280, 960), rotationDegrees=90, targetRotation=0} 1280x960 false
2021-05-25 16:01:13.957 21551-21597/com.smarteven I/CameraManagerGlobal: List is unavailable
2021-05-25 16:01:13.962 21551-21597/com.smarteven I/CameraManagerGlobal: List is unavailable
2021-05-25 16:01:13.967 21551-21597/com.smarteven I/CameraManagerGlobal: List is unavailable
2021-05-25 16:01:13.986 21551-21551/com.smarteven D/SurfaceViewImpl: Surface created.
2021-05-25 16:01:13.986 21551-21551/com.smarteven D/SurfaceViewImpl: Surface changed. Size: 1280x960
2021-05-25 16:01:13.989 21551-21551/com.smarteven D/SurfaceViewImpl: Surface set on Preview.
2021-05-25 16:01:14.012 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Use case Preview:androidx.camera.core.Preview-1f60161e-782e-47ed-aa5e-d34f11bc9b33 INACTIVE
2021-05-25 16:01:14.013 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30179448739] for camera: 0
2021-05-25 16:01:14.016 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Use case ImageCapture:androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30 ACTIVE
2021-05-25 16:01:14.016 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30179448739] for camera: 0
2021-05-25 16:01:14.023 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Use case androidx.camera.core.VideoCapture@a3a6ea0 INACTIVE
2021-05-25 16:01:14.023 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30179448739] for camera: 0
2021-05-25 16:01:14.027 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Use case Preview:androidx.camera.core.Preview-1f60161e-782e-47ed-aa5e-d34f11bc9b33 ACTIVE
2021-05-25 16:01:14.028 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.Preview-1f60161e-782e-47ed-aa5e-d34f11bc9b3394142162, androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30179448739] for camera: 0
2021-05-25 16:01:14.036 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.Preview-1f60161e-782e-47ed-aa5e-d34f11bc9b3394142162, androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30179448739] for camera: 0
2021-05-25 16:01:14.041 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Issue capture request
2021-05-25 16:01:14.043 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.Preview-1f60161e-782e-47ed-aa5e-d34f11bc9b3394142162, androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30179448739] for camera: 0
2021-05-25 16:01:14.046 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} CameraDevice.onOpened()
2021-05-25 16:01:14.049 21551-21694/com.smarteven D/Camera2CameraImpl: {Camera@39de09[id=0]} Transitioning camera internal state: OPENING --> OPENED
2021-05-25 16:01:14.050 21551-21694/com.smarteven D/CameraStateRegistry: Recalculating open cameras:
    Camera                                       State                 
    -------------------------------------------------------------------
    Camera@39de09[id=0]                          OPEN                  
    Camera@da8a428[id=1]                         UNKNOWN               
    Camera@561d040[id=2]                         UNKNOWN               
    -------------------------------------------------------------------
    Open count: 1 (Max allowed: 1)
2021-05-25 16:01:14.050 21551-21694/com.smarteven D/CameraStateMachine: New public camera state CameraState{type=OPEN, error=null} from OPEN and null
2021-05-25 16:01:14.050 21551-21694/com.smarteven D/CameraStateMachine: Publishing new public camera state CameraState{type=OPEN, error=null}
2021-05-25 16:01:14.051 21551-21694/com.smarteven D/UseCaseAttachState: All use case: [androidx.camera.core.Preview-1f60161e-782e-47ed-aa5e-d34f11bc9b3394142162, androidx.camera.core.VideoCapture-1b2ef0d2-ce42-4045-8615-638af38f39fa171601568, androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30179448739] for camera: 0
2021-05-25 16:01:14.071 21551-21694/com.smarteven D/UseCaseAttachState: Active and attached use case: [androidx.camera.core.Preview-1f60161e-782e-47ed-aa5e-d34f11bc9b3394142162, androidx.camera.core.ImageCapture-c6b1bfac-9dde-4e9a-ad31-5e9e48885e30179448739] for camera: 0
2021-05-25 16:01:14.074 21551-21694/com.smarteven D/SyncCaptureSessionBase: [androidx.camera.camera2.internal.SynchronizedCaptureSessionBaseImpl@171f1c4] getSurface...done
2021-05-25 16:01:14.075 21551-21694/com.smarteven D/DeferrableSurface: New surface in use[total_surfaces=3, used_surfaces=1](androidx.camera.core.SurfaceRequest$2@f53f315}
2021-05-25 16:01:14.075 21551-21694/com.smarteven D/DeferrableSurface: use count+1, useCount=1 androidx.camera.core.SurfaceRequest$2@f53f315
2021-05-25 16:01:14.075 21551-21694/com.smarteven D/DeferrableSurface: New surface in use[total_surfaces=3, used_surfaces=2](androidx.camera.core.impl.ImmediateSurface@76eaef7}
2021-05-25 16:01:14.075 21551-21694/com.smarteven D/DeferrableSurface: use count+1, useCount=1 androidx.camera.core.impl.ImmediateSurface@76eaef7
2021-05-25 16:01:14.075 21551-21694/com.smarteven D/DeferrableSurface: New surface in use[total_surfaces=3, used_surfaces=3](androidx.camera.core.impl.ImmediateSurface@52371b8}
2021-05-25 16:01:14.075 21551-21694/com.smarteven D/DeferrableSurface: use count+1, useCount=1 androidx.camera.core.impl.ImmediateSurface@52371b8
2021-05-25 16:01:14.076 21551-21694/com.smarteven D/CaptureSession: Opening capture session.
2021-05-25 16:01:14.118 21551-21694/com.smarteven D/CaptureSession: Attempting to send capture request onConfigured
2021-05-25 16:01:14.118 21551-21694/com.smarteven D/CaptureSession: Issuing request for session.
2021-05-25 16:01:14.123 21551-21694/com.smarteven D/CaptureSession: Issuing capture request.
2021-05-25 16:01:14.129 21551-21694/com.smarteven D/CaptureSession: CameraCaptureSession.onConfigured() mState=OPENED
2021-05-25 16:01:14.130 21551-21694/com.smarteven D/CaptureSession: CameraCaptureSession.onReady() OPENED
2021-05-25 16:01:14.307 21551-21693/com.smarteven D/StreamStateObserver: Update Preview stream state to STREAMING
2021-05-25 16:01:15.667 21551-21551/com.smarteven I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
2021-05-25 16:01:15.717 21551-21551/com.smarteven I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
2021-05-25 16:01:16.014 21551-21608/com.smarteven E/ReactNativeJS: Error: Frame Processors are not enabled. Make sure you install react-native-reanimated 2.1.0 or above!
    
    This error is located at:
        in Camera (at Photo.tsx:19)
        in RCTView (at View.js:34)
        in View (at Photo.tsx:15)
        in SEPhotoBS (at Add.tsx:132)
        in RCTView (at View.js:34)
        in View (at Add.tsx:64)
        in SEAddActivityBS (at Activities.tsx:156)

Reproducable sample

  1. Wrap <Camera /> inside a component
  2. Mount it
  3. Unmount it

Environment

  • Platform(s):
    • iOS
    • [x ] Android
  • react-native version: 0.64.1
  • react-native-vision-camera version: 2.0.0
  • react-native-reanimated version: 2.1.0

๐Ÿ› after the installation Execution failed for task ':app:processDebugResources'.

Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade > Android resource linking failed

Type

  • I'm cannot build my project with VisionCamera
  • I'm experiencing a full app crash
  • A feature is not working correctly
  • Other: __________________

What

Reproducable sample

// code here

Environment

  • Platform(s):
    • iOS
    • Android
  • react-native version: ___
  • react-native-vision-camera version: ___
  • react-native-reanimated version: N/A

Not supported - use activeFormat.supportedColorSpaces'

What

React Native Vision Camera crashes on IOS when running through physical device. The crash appears to manifest itself through the xCode debugger and a runtime error. The issue originated when I placed an Animated View outside of the Camera's container (which is a View). It sometimes works, but then randomly stops, within a few minutes of a new build.

Logs

2021-06-11 22:25:26.747003-0400 ReactNativeEhugs[1772:592497] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureDevice setActiveColorSpace:] Not supported - use activeFormat.supportedColorSpaces'
*** First throw call stack:
(0x18def186c 0x1a2f0ac50 0x1a82661dc 0x12266d6c0 0x12267df14 0x1a8266050 0x18f21b890 0x18f1543a0 0x18f216830 0x1a8289090 0x1a8287444 0x1a8280ec0 0x1a8282b20 0x102bf8b34 0x102c10f18 0x102c12160 0x12266bbcc 0x12266d6c0 0x122675354 0x1226760c0 0x122682644 0x1d999d814 0x1d99a476c)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureDevice setActiveColorSpace:] Not supported - use activeFormat.supportedColorSpaces'
terminating with uncaught exception of type NSException

Reproducable sample

This is pointless, but I'll link repo tomorrow.

// code here

Environment

  • Platform(s):
    • iOS
    • Android
  • react-native version: latest
  • react-native-vision-camera version: latest
  • react-native-reanimated version: latest

๐Ÿ› Width and height are swapped of taking photo in the output

What were you trying to do?

I take a picture with const image = await cameraRef.current.takePhoto() which works fine.

What happened instead?

But the output data has something strange.
The width and height are swapped... the height should be the width and visa versa, see output:
{ "height": 2160, "width": 3840, "isRawPhoto": false, "path": "/private/var/mobile/Containers/Data/Application/4C4B43F6-0476-4E97-BECF-4C3CE1E28DAB/tmp/ReactNative/A538B243-30FB-42B1-B31D-E4C5B9E0326F.jpeg", "thumbnail": null, ...more }

From the documentation i read this lib only supports portrait mode for now, so i assume it has not something to do with landscape/portrait mode.

When i test the output with: Image.getSize(image.path, console.log); i get the correct width and height of the image.

Relevant log output

LOG  Camera image output:  3840x2160
 LOG  Measured image with Image.getSize:  2160x3840

Device

iPhone 12 PRO (ios 14.x)

VisionCamera Version

2.4.1

Additional information

๐Ÿ› Android Build Issue

Hi,
Thanks very much for this new library

I am experiencing a build issue on Android just after having installed react-native-vision-camera.
IOS build is working fine.

I am getting the following error message when building with "npx react-native run-android" command.

Configure project :react-native-vision-camera
Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • Where:
    Build file '/Users/nm/Dev/MyApp/node_modules/react-native-vision-camera/android/build.gradle' line: 26

  • What went wrong:
    A problem occurred evaluating project ':react-native-vision-camera'.

Failed to apply plugin [id 'org.jlleitschuh.gradle.ktlint']
Extension of type 'CommonExtension' does not exist. Currently registered extension types: [ExtraPropertiesExtension, DefaultArtifactPublicationSet, ReportingExtension, SourceSetContainer, JavaPluginExtension, JavaInstallationRegistry, NamedDomainObjectContainer, LibraryExtension, KotlinAndroidProjectExtension, KotlinTestsRegistry, AndroidExtensionsExtension, KtlintExtension]

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    ==============================================================================

2: Task failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':react-native-vision-camera'.

compileSdkVersion is not specified.

When opening the project on Android Studio I get the following message:
11:14 AM Gradle sync failed: Could not run phased build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-6.2-all.zip'.
Consult IDE log for more details (Help | Show Log) (1 s 252 ms)

For the first issue I found the following link if it may help:
https://stackoverflow.com/questions/65179275/the-kotlin-android-extensions-gradle-plugin-is-deprecated

Environment

React Native: 0.63.4
Android Studio: 4.0
Gradle Plugin: 3.5.3
Gradle: 6.2

  • Platform(s):

    • Android
  • react-native version: 0.63.4

  • react-native-vision-camera version: 1.0.0

  • react-native-reanimated version: 1.13.1

My gradle-wrapper.properties file:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

My build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
googlePlayServicesVersion = "17.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}

    google()
    jcenter()
    maven { url 'https://www.jitpack.io' }
}

}

Many thanks for your help.

โœจ Android: Correctly implement Format (Resolution, FPS)

Getting Formats with FPS higher than 30 doesn't seem to work.

I feel like something in the getAvailableCameraDevices code is wrong:

https://github.com/cuvent/react-native-vision-camera/blob/dff8fc71788311c324e6eb80976a6ec50596d3e5/android/src/main/java/com/mrousavy/camera/CameraViewModule.kt#L205-L220

Maybe I shouldn't use MediaRecorder::class.java here?:

https://github.com/cuvent/react-native-vision-camera/blob/dff8fc71788311c324e6eb80976a6ec50596d3e5/android/src/main/java/com/mrousavy/camera/CameraViewModule.kt#L201

I think the FPS-setting logic here works, as it also works for e.g. 15 FPS:

https://github.com/cuvent/react-native-vision-camera/blob/d85126d883feffcd6189135042420a8d89b153cf/android/src/main/java/com/mrousavy/camera/CameraView.kt#L280-L292

But CameraX doesn't support "high-speed video capture" yet, so anything high-speed (such as slow-mo, 120FPS, 240FPS) is not yet supported.

Resolution doesn't seem to correctly apply to Preview

I think I had some issues with setting the Resolution from a Format where I wasn't sure which resolution to use for the preview - I'll have to test that though. I think the ImageReader and VideoRecorder had correct resolutions.

Resolution is always the same for Photo and Video

I don't think that the VideoRecorder resolution is always the same as the ImageReader resolution, those actually have to be different.

https://github.com/cuvent/react-native-vision-camera/blob/dff8fc71788311c324e6eb80976a6ec50596d3e5/android/src/main/java/com/mrousavy/camera/CameraViewModule.kt#L236-L239

๐Ÿ› Android Video Recording fails silently when on phone call

Type

  • I'm cannot build my project with VisionCamera
  • I'm experiencing a full app crash
  • A feature is not working correctly
  • Other: __________________

What

When trying to record a video while being on a phone call, there will be no video returned or error thrown - it just fails silently.

This is a CameraX bug and it's being tracked at CameraX#183952600.

Environment

  • Platform(s):
    • iOS
    • Android
  • react-native version: ___
  • react-native-vision-camera version: ___
  • react-native-reanimated version: N/A

๐Ÿ› Expo: Package "react-native-vision-camera" does not contain a valid config plugin

What

In an Expo managed app after updating the permissions in the app.json file, I'm running into an error after running: expo prebuild

Logs

Package "react-native-vision-camera" does not contain a valid config plugin.
Learn more: https://docs.expo.io/guides/config-plugins/#creating-a-plugin
Cannot use import statement outside a module

Reproducable sample

app.json

{
  "expo": {
    "name": "react-native-vision-test",
    "slug": "react-native-vision-test",
    "plugins": [
      [
        "react-native-vision-camera",
        {
          "cameraPermissionText": "App needs access to your Camera."
        }
      ]
    ],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      }
    },
    "web": {
      "favicon": "./assets/favicon.png"
    }
  }
}

Environment

  • Platform(s):
    • expo version: 42.0.1
  • expo-cli: 4.7.3
  • react-native version: 42.0.0
  • react-native-vision-camera version: 2.4.1
  • react-native-reanimated version: 2.2.0

package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "~42.0.1",
    "expo-camera": "~11.2.1",
    "expo-status-bar": "~1.0.4",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
    "react-native-reanimated": "~2.2.0",
    "react-native-vision-camera": "^2.4.1",
    "react-native-web": "~0.13.12"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0"
  },
  "private": true
}

๐Ÿ› Preview stretched out when rotating to landscape (Android)

What

The preview seems to get stretched out if rotated to landscape and auto-rotate is turned on. The problem does not appear if the device is locked on portrait, however the resulting image will be rotated.
Demo here: https://www.youtube.com/watch?v=0Dqsre4a5T4

Reproducable sample

  1. Git clone && run the example on an Android phone
  2. Make sure that auto-rotate is turned on
  3. Rotate the phone to landscape

Environment

  • Device: Samsung Galaxy Note 8
  • Platform(s):
    • iOS
    • Android 9
  • react-native version: 0.64.2
  • react-native-vision-camera version: 2.4.1
  • react-native-reanimated version: N/A

โœจ Android Multi-Camera

What

Currently the library works with IOS wide angle camera but unable to get the available cameras in Android So that would be great since all latest mobiles have built in multiple cameras

Alternatives/Workarounds

Currently there is no alternative for Android to use wide angle camera

โœจ Use Image HostObject for faster image capture

Currently image capture works like this:

-> means bridge call

  • JS -> Native: takePhoto invocation
  • Native takes photo
  • Native writes photo (UIImage/Bitmap) to a file (๐Ÿข slow!)
  • Native -> JS: takePhoto promise resolver with file path, goes over bridge (๐Ÿข slow!)
  • JS uses that path to mount an <Image>/<FastImage>
  • JS -> Native: <Image>/<FastImage> wants to load photo from file again (๐Ÿข slow!)

With the upcoming React Native Re-Architecture this will change. Instead, I want to achieve the following:

=> means direct C++ function invocation, no bridge

  • JS => Native: takePhoto invocation
  • Native takes photo
  • Native creates a thin wrapper jsi::HostObject which contains the UIImage/Bitmap object (๐Ÿ‡ fast!)
  • Native => JS: takePhoto promise resolver with jsi::HostObject ("image") (๐Ÿ‡ fast!)
  • JS keeps that image object in memory and mounts an <Image>/<FastImage>
  • JS => Native: <Image>/<FastImage> simply sets the already in-memory image to display (๐Ÿ‡ fast!)

This will provide huge performance improvements since 1. the entire async Bridge calls are gone, and 2. because the File IO is completely gone.

I'm estimating at least 200ms of faster capture. (measured File I/O quite a while ago)

To display my jsi::HostObject image, I either have to create a custom image component, or maybe React Native's Core Image component will support this out of the box.

We'll see.

โœจ Get rid of `preset`

Type

  • Enhancement for an existing feature
  • An entirely new feature

What

The preset prop is a bit confusing (see misunderstanding in #78) and isn't really explained a lot. Also, it's unnecessary extra code.

I'm thinking about entirely getting rid of it, so the only way to control the format will be through the format prop. By default, the camera chooses the best format, and you can manually adjust that using your own logic in JS. I can write custom "preset-like choosers" functions in JS, which makes this whole thing more customizable.

Alternatives/Workarounds

โœจ Mirror selfie images on Android

Selfie images are correctly mirrored (horizontally flipped) on iOS, but not on Android. This is due to the fact that this is not possible with CameraX without additional overhead.

https://github.com/cuvent/react-native-vision-camera/blob/dff8fc71788311c324e6eb80976a6ec50596d3e5/android/src/main/java/com/mrousavy/camera/CameraView%2BTakePhoto.kt#L59

I have tried to implement this in-memory, but sadly it didn't work:

https://github.com/cuvent/react-native-vision-camera/blob/03b9246afee58828eabb1b87173bdc985478cc4a/android/src/main/java/com/mrousavy/camera/utils/ImageProxy.save.kt#L11-L34

โœจ Support for legacy Camera1 devices

Type

  • I'm cannot build my project with VisionCamera
  • I'm experiencing a full app crash
  • A feature is not working correctly
  • Other: __________________

What

Hi Team,

We are using you library to capture images. When using getAvailableCameraDevices() function from Camera, it returns the length 0 or if we use the 'useCameraDevices' hook, the value returned in undefined, Referring the same code as mentioned from the Sample in the API docs.

  • Platform(s):
    • iOS
    • Android
  • react-native version: 0.64
  • react-native-vision-camera version: latest
  • react-native-reanimated version: 2.0.1

๐Ÿ’ก Replacement for react-native-camera

Question

Hi @mrousavy , what do you think about this library being a continuation of react-native-camera? I'm currently working on a revamped version 4 of react-native-camera and all the changes to the code are very similar to what this library already has.
The underlying API of this library is really clean and although react-native-camera offers some more customization, options and parameters, it does so with a very clumsy API. It is really hard to get to a clean implementation from react-native-camera 3 and the implementation in react-native-vision-camera is already clean and you are having a much faster development pace. Your extension solution looks very promising, and although there might be some use cases frame processing won't be able to cover like live streaming the camera output with native-grade performance, all of the existing use cases (Bar/QR code scanning, AI stuff) can be achieved.

CC: @cristianoccazinsp @MateusAndrade @sibelius

๐Ÿ› Example app error on Android

I am encountering the following error when running the example app on Android.

BUILD SUCCESSFUL in 25s
187 actionable tasks: 2 executed, 185 up-to-date
info Connecting to the development server...
info Starting the app on "03157df32b9ac92d"...
Starting: Intent { cmp=com.mrousavy.camera.example/.MainActivity }
Error type 3
Error: Activity class {com.mrousavy.camera.example/com.mrousavy.camera.example.MainActivity} does not exist.
โœจ  Done in 31.25s.

What worked for me is this answer: https://stackoverflow.com/a/25633115/9375533

I made the following changes in https://github.com/cuvent/react-native-vision-camera/blob/main/example/android/app/build.gradle#L135

- applicationId "com.mrousavy.camera"
+ applicationId "com.mrousavy.camera.example"

Perhaps, we should update it? Or am I using it incorrectly?

๐Ÿ› Camera and Microphone permission errors are confused on Android

What

The library reports wrong permissions error.
I've found the place that needs a change so I guess it's a simple typo
Just swap these 2 lines

https://github.com/cuvent/react-native-vision-camera/blob/b6a67d5cedb762f69a29c02b6f4184892f4d606f/android/src/main/java/com/mrousavy/camera/CameraView.kt#L221
https://github.com/cuvent/react-native-vision-camera/blob/b6a67d5cedb762f69a29c02b6f4184892f4d606f/android/src/main/java/com/mrousavy/camera/CameraView.kt#L224

Should I create a PR or you will do this by yourself?

Logs

Not needed

Reproducable sample

Just give only camera permission and see the error - it will say that camera permission is denied.
Or just give only mic permission and see the error - it will say that mic permission is denied.

Environment

any

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.