Skip to content

react-native-opencv3 wraps functionality from OpenCV Java SDK 3.4.5 + face landmarks and iOS OpenCV 3.4.5 for use in React-Native apps. Please enjoy!

License

Notifications You must be signed in to change notification settings

casio/react-native-opencv3

 
 

Repository files navigation

react-native-opencv3

Getting started

$ npm install react-native-opencv3 --save

Mostly automatic installation Android

$ react-native link react-native-opencv3

Mostly automatic installation iOS

Add to Podfile ->

pod 'RNOpencv3', :podspec => '../node_modules/react-native-opencv3/ios/RNOpencv3.podspec'

$ pod install

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-opencv3 and add RNOpencv3.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNOpencv3.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import org.opencvport.RNOpencv3Package; to the imports at the top of the file
  • Add new RNOpencv3Package() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-opencv3'
    project(':react-native-opencv3').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-opencv3/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-opencv3')
    

Usage

import {RNCv} from 'react-native-opencv3';

// Basic convert input jpg or png to grayscale
RNCv.cvtColorGray(inFile, outFile)
.then((image) => {
  const { width, height, uri } = image
  console.log('width is: ' + width + 'height is: ' + height + ' uri is: ' + uri)
})
.error((err) => {
  console.error(err)
})

CvCamera Usage

import React, {Component} from 'react';
import {StyleSheet, View} from 'react-native';
import {CvCamera} from 'react-native-opencv3';

type Props = {};
export default class App extends Component<Props> {
  render() {
    const { type } = 'back';
    return (
      <View
        style={styles.preview}
      >
        <CvCamera
          style={styles.preview}
          type={type}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  preview: {
    flex: 1
  },
});

About

react-native-opencv3 wraps functionality from OpenCV Java SDK 3.4.5 + face landmarks and iOS OpenCV 3.4.5 for use in React-Native apps. Please enjoy!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 39.3%
  • Objective-C++ 32.2%
  • JavaScript 22.7%
  • Objective-C 5.1%
  • Other 0.7%