GithubHelp home page GithubHelp logo

teslamotors / react-native-camera-kit Goto Github PK

View Code? Open in Web Editor NEW
2.4K 209.0 578.0 12.59 MB

A high performance, easy to use, rock solid camera library for React Native apps.

License: MIT License

Objective-C 3.33% Java 4.41% JavaScript 2.33% Ruby 1.78% TypeScript 14.01% Kotlin 23.46% Objective-C++ 0.67% Swift 49.81% C 0.09% Shell 0.11%
react-native ios android camera

react-native-camera-kit's Introduction

🎈 React Native Camera Kit

A high performance, easy to use, rock solid
camera library for React Native apps.

React Native Camera Kit is released under the MIT license. Current npm package version.

  • Cross Platform (iOS and Android)

  • Optimized for performance and high photo capture rate

  • QR / Barcode scanning support

  • Camera preview support in iOS simulator

Installation (RN > 0.60)

yarn add react-native-camera-kit
cd ios && pod install && cd ..

Android: Add Kotlin to your project

Permissions

You must use a separate library for prompting the user for permissions before rendering the <Camera .../> component.
We recommend zoontek's library, react-native-permissions: https://github.com/zoontek/react-native-permissions#ios-flow

If you fail to prompt for permission, the camera will appear blank / black.

Why no permissions API?

Conceptually, permissions are simple: Granted / Denied.
However, in reality it's not that simple due to privacy enhancements on iOS and Android.

Here's an example diagram from react-native-permissions's README, which illustrates the complexity of the user-experience, which we don't want to duplicate in a camera library:

   ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
   ┃ check(PERMISSIONS.IOS.CAMERA) ┃
   ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
                   β”‚
       Is the feature available
           on this deviceΒ ?
                   β”‚           ╔════╗
                   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•‘ NO ║──────────────┐
                   β”‚           β•šβ•β•β•β•β•              β”‚
                ╔═════╗                            β–Ό
                β•‘ YES β•‘                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β•šβ•β•β•β•β•β•                 β”‚ RESULTS.UNAVAILABLE β”‚
                   β”‚                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           Is the permission
             requestableΒ ?
                   β”‚           ╔════╗
                   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•‘ NO ║──────────────┐
                   β”‚           β•šβ•β•β•β•β•              β”‚
                ╔═════╗                            β–Ό
                β•‘ YES β•‘                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β•šβ•β•β•β•β•β•                  β”‚ RESULTS.BLOCKED / β”‚
                   β”‚                     β”‚ RESULTS.LIMITED / β”‚
                   β”‚                     β”‚  RESULTS.GRANTED  β”‚
                   β–Ό                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚ RESULTS.DENIED β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
  ┃ request(PERMISSIONS.IOS.CAMERA) ┃
  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
                   β”‚
         Does the user accept
            the requestΒ ?
                   β”‚           ╔════╗
                   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•‘ NO ║──────────────┐
                   β”‚           β•šβ•β•β•β•β•              β”‚
                ╔═════╗                            β–Ό
                β•‘ YES β•‘                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β•šβ•β•β•β•β•β•                   β”‚ RESULTS.BLOCKED β”‚
                   β”‚                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚ RESULTS.GRANTED β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

In earlier versions of react-native-camera-kit, permissions were provided with an API, but for the above reasons, these APIs will be removed.

Android

Add the following uses-permission to your AndroidManifest.xml (usually found at: android/src/main/)

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

iOS

Add the following usage descriptions to your Info.plist (usually found at: ios/PROJECT_NAME/)

<key>NSCameraUsageDescription</key>
<string>For taking photos</string>

<key>NSPhotoLibraryUsageDescription</key>
<string>For saving photos</string>

Running the example project

  • yarn bootstrap
  • yarn example ios or yarn example android

Components

Camera

Barebones camera component if you need advanced/customized interface

import { Camera, CameraType } from 'react-native-camera-kit';
<Camera
  ref={(ref) => (this.camera = ref)}
  cameraType={CameraType.Back} // front/back(default)
  flashMode="auto"
/>

Barcode / QR Code Scanning

Additionally, the Camera can be used for barcode scanning

<Camera
  ...
  // Barcode props
  scanBarcode={true}
  onReadCode={(event) => Alert.alert('QR code found')} // optional
  showFrame={true} // (default false) optional, show frame with transparent layer (qr code or barcode will be read on this area ONLY), start animation for scanner, that stops when a code has been found. Frame always at center of the screen
  laserColor='red' // (default red) optional, color of laser in scanner frame
  frameColor='white' // (default white) optional, color of border of scanner frame
/>

Camera Props (Optional)

Props Type Description
ref Ref Reference on the camera view
style StyleProp<ViewStyle> Style to apply on the camera view
flashMode 'on'/'off'/'auto' Camera flash mode. Default: auto
focusMode 'on'/'off' Camera focus mode. Default: on
zoomMode 'on'/'off' Enable the pinch to zoom gesture. Default: on
zoom number Control the zoom. Default: 1.0
maxZoom number Maximum zoom allowed (but not beyond what camera allows). Default: undefined (camera default max)
onZoom Function Callback when user makes a pinch gesture, regardless of what the zoom prop was set to. Returned event contains zoom. Ex: onZoom={(e) => console.log(e.nativeEvent.zoom)}.
torchMode 'on'/'off' Toggle flash light when camera is active. Default: off
cameraType CameraType.Back/CameraType.Front Choose what camera to use. Default: CameraType.Back
onOrientationChange Function Callback when physical device orientation changes. Returned event contains orientation. Ex: onOrientationChange={(event) => console.log(event.nativeEvent.orientation)}. Use import { Orientation } from 'react-native-camera-kit'; if (event.nativeEvent.orientation === Orientation.PORTRAIT) { ... } to understand the new value
Android only
onError Function Android only. Callback when camera fails to initialize. Ex: onError={(e) => console.log(e.nativeEvent.errorMessage)}.
shutterPhotoSound boolean Android only. Enable or disable the shutter sound when capturing a photo. Default: true
iOS only
ratioOverlay 'int:int' Show a guiding overlay in the camera preview for the selected ratio. Does not crop image as of v9.0. Example: '16:9'
ratioOverlayColor Color Any color with alpha. Default: '#ffffff77'
resetFocusTimeout number Dismiss tap to focus after this many milliseconds. Default 0 (disabled). Example: 5000 is 5 seconds.
resetFocusWhenMotionDetected Boolean Dismiss tap to focus when focus area content changes. Native iOS feature, see documentation: https://developer.apple.com/documentation/avfoundation/avcapturedevice/1624644-subjectareachangemonitoringenabl?language=objc). Default true.
resizeMode 'cover' / 'contain' Determines the scaling and cropping behavior of content within the view. cover (resizeAspectFill on iOS) scales the content to fill the view completely, potentially cropping content if its aspect ratio differs from the view. contain (resizeAspect on iOS) scales the content to fit within the view's bounds without cropping, ensuring all content is visible but may introduce letterboxing. Default behavior depends on the specific use case.
scanThrottleDelay number Duration between scan detection in milliseconds. Default 2000 (2s)
Barcode only
scanBarcode boolean Enable barcode scanner. Default: false
showFrame boolean Show frame in barcode scanner. Default: false
laserColor Color Color of barcode scanner laser visualization. Default: red
frameColor Color Color of barcode scanner frame visualization. Default: yellow
onReadCode Function Callback when scanner successfully reads barcode. Returned event contains codeStringValue. Default: null. Ex: onReadCode={(event) => console.log(event.nativeEvent.codeStringValue)}

Imperative API

Note: Must be called on a valid camera ref

capture()

Capture image as JPEG.

A temporary file is created. You must move this file to a permanent location (e.g. the app's 'Documents' folder) if you need it beyond the current session of the app as it may be deleted when the user leaves the app. You can move files by using a file system library such as react-native-fs or expo-filesystem. (On Android we currently have an unsupported outputPath prop but it's subject to change at any time).

Note that the reason you're getting a URL despite it being a file is because Android 10+ encourages URIs. To keep things consistent regardless of settings or platform we always send back a URI.

const { uri } = await this.camera.capture();
// uri = 'file:///data/user/0/com.myorg.myapp/cache/ckcap123123123123.jpg'

If you want to store it permanently, here's an example using react-native-fs:

import RNFS from 'react-native-fs';
// [...]
let { uri } = await this.camera.capture();
if (uri.startsWith('file://')) {
  // Platform dependent, iOS & Android uses '/'
  const pathSplitter = '/';
  // file:///foo/bar.jpg => /foo/bar.jpg
  const filePath = uri.replace('file://', '');
  // /foo/bar.jpg => [foo, bar.jpg]
  const pathSegments = filePath.split(pathSplitter);
  // [foo, bar.jpg] => bar.jpg
  const fileName = pathSegments[pathSegments.length - 1];

  await RNFS.moveFile(filePath, `${RNFS.DocumentDirectoryPath}/${fileName}`);
  uri = `file://${destFilePath}`;
}

checkDeviceCameraAuthorizationStatus (iOS only)

const isCameraAuthorized = await Camera.checkDeviceCameraAuthorizationStatus();

return values:

AVAuthorizationStatusAuthorized returns true

AVAuthorizationStatusNotDetermined returns -1

otherwise, returns false

requestDeviceCameraAuthorization (iOS only)

const isUserAuthorizedCamera = await Camera.requestDeviceCameraAuthorization();

AVAuthorizationStatusAuthorized returns true

otherwise, returns false

Using with Expo

If you are using Expo Managed Workflow, you can use this library with a third-party plugin expo-react-native-camera-kit.

See more here

Contributing

  • Pull Requests are welcome, if you open a pull request we will do our best to get to it in a timely manner
  • Pull Request Reviews are even more welcome! we need help testing, reviewing, and updating open PRs
  • If you are interested in contributing more actively, please contact us.

License

The MIT License.

See LICENSE

react-native-camera-kit's People

Contributors

aarongrider avatar artald avatar avdept avatar aviswaroop avatar buttershub avatar cool04ek avatar d4vidi avatar danielzlotin avatar davidbertet avatar dependabot[bot] avatar dhiasaadlaui avatar dibyajyotimishra avatar dmitryponomarenko avatar elliottkember avatar evgeni-wix avatar ewouth avatar gran33 avatar guyca avatar kubik369 avatar minasa1 avatar niftylettuce avatar noamco avatar savv avatar scarlac avatar silyevsk avatar stetbern avatar swabbass avatar syar-tech avatar yedidyak avatar yershalom 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  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

react-native-camera-kit's Issues

Alternative image size calculation

Hi there,

First, let me say that when I found react-native-camera-kit I couldn't be happier. It's exactly what I was looking for, thanks for releasing it!

I've integrated the app in a personal project and then I found that the picture being taken was too small. After reading the code a little bit, I found where you calculate the capture size to use, using the common ratio approach.

https://github.com/wix/react-native-camera-kit/blob/83ef7bac2395cde51c6a42c0826a57987056eb65/android/src/main/java/com/wix/RNCameraKit/camera/CameraViewManager.java#L184-L209

I've forked the project and added another method that finds the biggest size within some limits, these are currently hardcoded:

maraujop@d861e7d

If you are interested, I could easily turn those limits into React props and maybe have a property to toggle a different size calculation.

Also, I think it would be nice to have a property for the JPEG quality:
maraujop@ad27341

I can also send a PR, if you are interested.

Thanks, cheers
Miguel

Can't turn off flash on android

Followed the example and set flash to off, but it's still set to auto

        ref={(cam) => {
                            this.camera = cam;
                            }
                }
        style={{flex: 1, backgroundColor:'white'}}
        cameraOptions={{
                    flashMode: 'off',             // on/off/auto(default)
                    focusMode: 'on',               // off/on(default)
                    zoomMode: 'on',                // off/on(default)
                    ratioOverlay:'1:1',            // optional, ratio overlay on the camera and crop the image seamlessly 
                    ratioOverlayColor: '#00000077' // optional
                    }}
/>```

Can not compile appliaction

:react-native-camera-kit:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/home/github/mobile-app/node_modules/react-native-camera-kit/android/src/main/java/com/wix/RNCameraKit/RNCameraKitPackage.java:54: error: method does not override or implement a method from a supertype
    @Override

react native camera kit v5.3.6
react 16.0.0-alpha.12
react native 0.47.1

Help me fixing this android build issue

Running dex in-process requires build tools 23.0.2.
For faster builds update this project to use the latest build tools.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)

:app:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

Camera is not correctly rotated

1 - Open camera
2 - Rotate mobile device
3 - Image shows cropped with wrong orientation
4 - Rotate mobile device again
5 - Image shows cropped with wrong orientation

[iOS] camera crashes the app

I just installed the lib and pasted the example into our code

<CameraKitCamera
    ref={(cam) => {this.camera = cam}}
    style={{flex: 1, backgroundColor: 'white'}}
    cameraOptions={{
    flashMode: 'auto',
    focusMode: 'on',
    zoomMode: 'on',
    ratioOverlay: '1:1',
    ratioOverlayColor: '#00000077',
  }}
/>

The app crashes immediately after mounting the component.

      libsystem_kernel.dylib`__abort_with_payload:
      0x185705d6c <+0>:  movz   x16, #0x209
      0x185705d70 <+4>:  svc    #0x80
->  0x185705d74 <+8>:  b.lo   0x185705d8c               ; <+32> [SIGABRT signal]
      0x185705d78 <+12>: stp    x29, x30, [sp, #-16]!
      0x185705d7c <+16>: mov    x29, sp
      0x185705d80 <+20>: bl     0x1856ea7d0               ; cerror_nocancel
      0x185705d84 <+24>: mov    sp, x29
      0x185705d88 <+28>: ldp    x29, x30, [sp], #16
      0x185705d8c <+32>: ret

Tried both the Simulator and physical iPhone 6.
react-native 0.41.2
react-native-camera-kit 5.2.11

Can't build with android version

im getting error when im run 'react-native run-android' command on 'example'

\react-native-camera-kit\android\src\main\java\com\wix\RNCameraKit\gallery\GalleryView.java:121: error: method init in class Event cannot be applied to given types;
init(0);
^
required: int,long
found: int
reason: actual and formal argument lists differ in length
where T is a type-variable:
T extends Event declared in class Event


React-Native version: 0.40
react-native-camera-kit version: 4.0.6

React-Native 0.47 error: com.wix.RNCameraKit.camera.CameraViewManager cannot be cast to com.facebook.react.uimanager.ViewGroupManager

I'm using the latest version of react-native (0.47) and after removing the depreacted @OverRide from RNCameraKitPackage.java I was able to build the project.

I use the component like this

import { ReactNativeCameraKit } from 'react-native-camera-kit';
import React from 'react';

export default class Camera extends React.Component {
  render() {
    return (
      <CameraKitCamera
        ref={(cam) => this.camera = cam}
      >
        <Button> ... </Button>
        <Button> ... </Button>
        <Button> ... </Button>
      </CameraKitCamera>
    );
  }
}

So im using children inside the CameraKitCamera which will cause the app to crash with error: com.wix.RNCameraKit.camera.CameraViewManager cannot be cast to com.facebook.react.uimanager.ViewGroupManager

Are children unsupported?

Feature Request: camera type option

I would love to specify front or back camera in the camera options. Then calling changeCamera wouldn't be neccesary, just update the props and away you go.

restrict number of selected images ?

hi, is it possible to somehow restrict the number of images a user can select from the gallery ?

we couldn't see any API hooks for this but would appreciate your feedback on how this might be done? many thanks.

Camera appears as blank on Android after following all steps to set up.

I followed the setup instructions for android correctly and I'm trying to run basic code to get this working. Am I doing something wrong?

Here is the code:

'use strict';
import {
  AppRegistry,
  Dimensions,
  StyleSheet,
  Text,
  TouchableHighlight,
  View,
  Alert
} from 'react-native';
import React, { Component } from 'react';
import { CameraKitCamera } from 'react-native-camera-kit';

class TakePhoto extends Component {


  render() {
    return (
      <View style={styles.container}>
        <CameraKitCamera
          ref={cam => this.camera = cam}
          style={{
            flex: 1,
            height: 300,
          }}
          cameraOptions={{
            flashMode: 'on',             // on/off/auto(default)
            focusMode: 'on',               // off/on(default)
            zoomMode: 'on',                // off/on(default)
            ratioOverlay:'1:1',            // optional, ratio overlay on the camera and crop the image seamlessly
            ratioOverlayColor: '#00000077' // optional
          }}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flexDirection: 'row',
  },
  preview: {
    flex: 1,
    justifyContent: 'flex-end',
    alignItems: 'center'
  },
  capture: {
    flex: 0,
    backgroundColor: '#fff',
    borderRadius: 5,
    color: '#000',
    padding: 10,
    margin: 40
  }
});

export { TakePhoto };

And it's just coming up with an empty box. I'm also getting these warnings when I run yarn android:

2:18:29 PM: Warning: Native component for "CameraView" does not exist

2:18:29 PM: Warning: Native component for "GalleryView" does not exist

Can someone please help me out?

EDIT: I'm running this with Expo. Should that pose a problem?

requestDevicePhotosAuthorization is not resolved with first call

When I call CameraKitGallery.requestDevicePhotosAuthorization() It will show me the permission alert window on Android. But after choosing my permission the promise is not resolved. If I press for a second time the promise returns the value.

onPress = _ => {
    CameraKitGallery.requestDevicePhotosAuthorization()
      .then(succes => console.log('succes:', succes))
      .catch(reason => console.log('error:', reason))
}

There is no difference in the outcome if i use .then or await
Also there is nearly no Javascript involved with this call, it's directly mapped to a native function. Maybe can see whats wrong there? Or is my implementation wrong?

This was tested on several Android devices.

Deselect SelectedImages

Hya,
I was wondering if the selectedImages prop is maybe broken at the moment.
I'ver tried to set the selectedImages prop on a - reference but it does not have any effect.

how can we store a camera roll reference to selected images in CameraKitGalleryView?

Currently a user can select (say) 4 images from the CameraKitGalleryView.

We want to be able to store a record/reference of the 4 selected images, so that if the user deletes the app off their phone, then adds it back later --> we can retrieve those previously (4) selected images (assuming the user didn't delete them off the phone). Please note that we DONT want to store the images themselves in cloud storage (at this stage). We just want to be able to retrieve them from the users camera roll on device.

At the moment we feel the only way to do this is to retain a reference to the (4) images in the assets library. For example here is an assets library path for a single image:

'assets-library://asset/asset.JPG?id=96D9EFE8-A72F-477C-85CA-C6C428B1D238&ext=JPG

Are we approaching this the wrong way and/or is there a way to do this via this Wix camera kit component?

Landscape Orientation View Finder

Is there any plans to support a landscape device orientation? I am building a tablet app that is primary a landscape use case and the view finder orientation is off as well as the aspect ratio overlay.

v5.3.11 doesn't work

Hi there,
Please see message below...
I'm using firebase tools and this is the message I received from firebase crash reporting

SelectableImage.java
Exception message
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference at com.wix.RNCameraKit.gallery.SelectableImage$1.orient(SelectableImage.java:128)

Error during build. Conflicted support v4 module

Version

Platform : android
"react": "16.0.0-alpha.12"
"react-native": "0.46.4"
"react-native-camera-kit": : "^5.3.3"
"sdk tools": 23.0.2

What happened

Error during build. The main cause is because some conflicted modules that also being used by react-native-fetch-blob. I think it was 'support-v4' module

Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;

How to replicate

react-native init newProject
yarn add react-native-cached-image
yarn link react-native-cached-image
yarn add react-native-camera-kit
yarn link react-native-camera-kit
react-native run-android

My build.gradle dependencies section

dependencies {
    compile project(':react-native-camera-kit')
    compile project(':react-native-fetch-blob')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

What i've tried

  • Clean project build
  • Clean project using gradlew clean
  • Recreated project and still got error. Even without additional package.

Example Crashes

Hi,
When I run the example project and tap 'Take It!' - the app crashes with:

2016-08-18 14:21:12.816 example[29502:4718108] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:] - inactive/invalid connection passed.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010e5b4d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010d49cdeb objc_exception_throw + 48
    2   AVFoundation                        0x000000010d914df3 -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:] + 312
    3   example                             0x000000010cc4c7ba __35-[CKCamera snapStillImage:success:]_block_invoke + 458
    4   libdispatch.dylib                   0x0000000111b8fd9d _dispatch_call_block_and_release + 12
    5   libdispatch.dylib                   0x0000000111bb03eb _dispatch_client_callout + 8
    6   libdispatch.dylib                   0x0000000111b9682c _dispatch_queue_drain + 2215
    7   libdispatch.dylib                   0x0000000111b95d4d _dispatch_queue_invoke + 601
    8   libdispatch.dylib                   0x0000000111bb03eb _dispatch_client_callout + 8
    9   libdispatch.dylib                   0x0000000111b98b2f _dispatch_root_queue_drain + 1829
    10  libdispatch.dylib                   0x0000000111b98405 _dispatch_worker_thread3 + 111
    11  libsystem_pthread.dylib             0x0000000111eed4de _pthread_wqthread + 1129
    12  libsystem_pthread.dylib             0x0000000111eeb341 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

I cloned this repo, npm install within the directory and pressed run from Xcode.

I've tried following the instructions to install into another project, however receive the following errors. I put this here in case they're related.

ExceptionsManager.js:76 Warning: There is an internal error in the React performance measurement code. Did not expect componentDidMount timer to start while render timer is still in progress for another instance.reactConsoleError @ ExceptionsManager.js:76console.error @ YellowBox.js:60warning @ warning.js:44beginLifeCycleTimer @ ReactDebugTool.js:106onBeginLifeCycleTimer @ ReactDebugTool.js:212invokeComponentDidMountWithTimer @ ReactCompositeComponent.js:52notifyAll @ CallbackQueue.js:67close @ ReactNativeReconcileTransaction.js:38closeAll @ Transaction.js:204perform @ Transaction.js:146perform @ Transaction.js:138perform @ ReactUpdates.js:90flushBatchedUpdates @ ReactUpdates.js:173closeAll @ Transaction.js:204perform @ Transaction.js:151batchedUpdates @ ReactDefaultBatchingStrategy.js:63batchedUpdates @ ReactUpdates.js:98_receiveRootNodeIDEvent @ ReactNativeEventEmitter.js:124receiveTouches @ ReactNativeEventEmitter.js:186__callFunction @ MessageQueue.js:204(anonymous function) @ MessageQueue.js:95guard @ MessageQueue.js:41callFunctionReturnFlushedQueue @ MessageQueue.js:94onmessage @ debuggerWorker.js:39
ExceptionsManager.js:61 _.update is not a functionhandleException @ ExceptionsManager.js:61handleError @ InitializeJavaScriptAppEngine.js:115reportFatalError @ error-guard.js:30guard @ MessageQueue.js:43callFunctionReturnFlushedQueue @ MessageQueue.js:94onmessage @ debuggerWorker.js:39
ExceptionsManager.js:76 Unhandled JS Exception: _.update is not a function

flashMode torch

Issue:

If I initialize the camera with <Camera ... cameraOptions={{ flashMode: 'torch', ... }} />Torch mode doesn't turn on. But I can call setFlashMode('torch') which does work. Just though i'd bring it up as I begin implementing your library into my app. Thanks!

Details:

device: Android Galaxy S7
react-native-camera-kit: 5.2.9
react-native: 0.39.2

Context:

My app has document scanning features and we allow turning on torch mode as well as defaulting to torch mode in some scenarios to help assist in scanning documents (often times outside / in dark rooms).

side note: Great library :)

empty images?

hi

thanks for this project :)

i try the Screen demo now, everythings works fine i see the alert with images details when i take a picture, files are created in the Pictures folder but are 0 bytes :/

something wrong or i have something else to do ?

thanks

camera.capture returns incorrect URI

const images = await this.camera.capture(true)

returns incorrect uri, making the image file not accessible through the returned uri

SaveImageTask.java: look at the following

private WritableMap saveToMediaStore(Bitmap image) {
  .....
  return createImageInfo(filePath, filePath, fileName, fileSize, image.getWidth(), image.getHeight());
}

instead it should be

return createImageInfo(fileUri, filePath, fileName, fileSize, image.getWidth(), image.getHeight());

Wrong uri file depend the Platform (IOS/Android)

  1. Depends of the platform the uri located in other place.
    Platform.OS = 'ios' ? image.uri otherwise image.
  2. for ios there is prefix 'file://' which doest exsit on the android uri
    (Write about that in the documentation or just pick a convention)

Plans to support images stored in iCloud ?

I tested your CameraKitGalleryView and I noticed that you do not support images stored in the iCloud! Since now the majority of iOS users store their photos in iCloud, I think this is a necessity for an advanced camera and/or gallery component.

Are there any plans in this direction?

How to enable zoom?

Hello! Thanks you for building a marvelous React Native component. I've been experimenting with it in an android app I'm building and for some reason can't get zoom to work. My implementation is pretty much the same as the example:

<CameraKitCamera
        ref={(cam) => { this.camera = cam; }}
        style={{flex: 1, backgroundColor:'white'}}
        cameraOptions={{
              flashMode: 'auto',       // on/off/auto(default)
              focusMode: 'on',         // off/on(default)
              zoomMode: 'on',         // off/on(default)
        }}/>

Is there something I am missing? I would love some help/guidance. Thanks!

Add the "Privacy - Camera Usage Description" key requirement to the docs

These are required when using this component and the example

<key>NSCameraUsageDescription</key>
<string>Your message to user when the camera is accessed for the first time</string>

<!-- Include this only if you are planning to use the camera roll -->
<key>NSPhotoLibraryUsageDescription</key>
<string>Your message to user when the photo library is accessed for the first time</string>

<!-- Include this only if you are planning to use the microphone for video recording -->
<key>NSMicrophoneUsageDescription</key>
<string>Your message to user when the microsphone is accessed for the first time</string>

ios crashed when switching camera

Steps to reproduce:

  1. Clone the example
  2. Install deps
  3. Run Simulator
  4. Tap to switch camera
  5. App crashes

Debugging output:

Apr 11 18:42:46 MacBook-Pro example[36844] : *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureSession addInput:] Can't add a nil AVCaptureInput'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105d76b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001048bc141 objc_exception_throw + 48
2 AVFoundation 0x0000000104d97770 -[AVCaptureSession addInput:] + 1068
3 example 0x0000000103f1ca72 __25-[CKCamera changeCamera:]_block_invoke + 1202
4 libdispatch.dylib 0x0000000109ec04a6 _dispatch_call_block_and_release + 12
5 libdispatch.dylib 0x0000000109ee905c _dispatch_client_callout + 8
6 libdispatch.dylib 0x0000000109ec794f _dispatch_queue_serial_drain + 221
7 libdispatch.dylib 0x0000000109ec8669 _dispatch_queue_invoke + 1084
8 libdispatch.dylib 0x0000000109ec8b32 _dispatch_queue_override_invoke + 654
9 libdispatch.dylib 0x0000000109ecaec4 _dispatch_root_queue_drain + 634
10 libdispatch.dylib 0x0000000109ecabef _dispatch_worker_thread3 + 123
11 libsystem_pthread.dylib 0x000000010a280616 _pthread_wqthread + 1299
12 libsystem_pthread.dylib 0x000000010a2800f1 start_wqthread + 13
)

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.