React Native package that provides a camera with optional species recognition.
The ios
subfolder contains the source code for the iOS library project. You should need to just npm install inaturalist/react-native-inat-camera
and then perhaps react-native link react-native-inat-camera
and you should be good to go. You'll need to provide the model and taxonomy files.
The android
sub folder contains the source code for the Android library project. This project needs to be included in React Native projects that use the library.
The example
folder contains a React Native app that shows the different integration points (run it using npm install
+ react-native run-android
).
- Open your RN project's
android
sub folder and edit the settings.gradle file:
include ':app', ':inatcamera'
project(':inatcamera').projectDir = new File(rootProject.projectDir, '../../android')
- Make sure you have the
<uses-permission android:name="android.permission.CAMERA" />
permission, in yourAndroidManifest.xml
file. - Make sure your RN code asks the user for that permission as well.
- Add the following to
MainApplication.java
:
import org.inaturalist.inatcamera.nativecamera.INatCameraViewPackage;
...
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new INatCameraViewPackage() // <-- Add this line
);
}
- Open your RN app's
build.gradle
file and add the following (android/app/build.gradle
): Under thedependencies
section:
implementation project(":inatcamera")
- Can't load React Native screen: Once React Native screen is open - shake phone to open dev menu -> Dev Settings -> Debug server & port for device -> write IP address and port of your computer. Make sure your computer and phone are on the same wifi network.
- Remember to download the .tflite and .json files into the device (e.g.
/sdcard/Download
folder) and initialize theINatCamera
component with the correct paths.