├── .circleci
└── config.yml
├── .editorconfig
├── .gitattributes
├── .gitignore
├── .yarnrc
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── android
├── build.gradle
├── gradle.properties
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── visioncameraocr
│ ├── VisionCameraOcrModule.kt
│ └── VisionCameraOcrPackage.kt
├── babel.config.js
├── example
├── android
│ ├── app
│ │ ├── build.gradle
│ │ ├── debug.keystore
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── debug
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── visioncameraocr
│ │ │ │ └── ReactNativeFlipper.java
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── visioncameraocr
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── MainApplication.java
│ │ │ └── res
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ └── values
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── app.json
├── babel.config.js
├── index.tsx
├── ios
│ ├── File.swift
│ ├── Podfile
│ ├── Podfile.lock
│ ├── VisionCameraOcrExample-Bridging-Header.h
│ ├── VisionCameraOcrExample.xcodeproj
│ │ ├── project.pbxproj
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── VisionCameraOcrExample.xcscheme
│ ├── VisionCameraOcrExample.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── VisionCameraOcrExample
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Images.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ │ ├── Info.plist
│ │ ├── LaunchScreen.storyboard
│ │ └── main.m
├── metro.config.js
├── package.json
├── src
│ └── App.tsx
└── yarn.lock
├── ios
├── VisionCameraOcr-Bridging-Header.h
├── VisionCameraOcr.m
├── VisionCameraOcr.swift
└── VisionCameraOcr.xcodeproj
│ └── project.pbxproj
├── package.json
├── scripts
└── bootstrap.js
├── src
├── __tests__
│ └── index.test.tsx
└── index.tsx
├── tsconfig.build.json
├── tsconfig.json
├── vision-camera-ocr.podspec
└── yarn.lock
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2.1
2 |
3 | executors:
4 | default:
5 | docker:
6 | - image: circleci/node:10
7 | working_directory: ~/project
8 |
9 | commands:
10 | attach_project:
11 | steps:
12 | - attach_workspace:
13 | at: ~/project
14 |
15 | jobs:
16 | install-dependencies:
17 | executor: default
18 | steps:
19 | - checkout
20 | - attach_project
21 | - restore_cache:
22 | keys:
23 | - dependencies-{{ checksum "package.json" }}
24 | - dependencies-
25 | - restore_cache:
26 | keys:
27 | - dependencies-example-{{ checksum "example/package.json" }}
28 | - dependencies-example-
29 | - run:
30 | name: Install dependencies
31 | command: |
32 | yarn install --cwd example --frozen-lockfile
33 | yarn install --frozen-lockfile
34 | - save_cache:
35 | key: dependencies-{{ checksum "package.json" }}
36 | paths: node_modules
37 | - save_cache:
38 | key: dependencies-example-{{ checksum "example/package.json" }}
39 | paths: example/node_modules
40 | - persist_to_workspace:
41 | root: .
42 | paths: .
43 |
44 | lint:
45 | executor: default
46 | steps:
47 | - attach_project
48 | - run:
49 | name: Lint files
50 | command: |
51 | yarn lint
52 |
53 | typescript:
54 | executor: default
55 | steps:
56 | - attach_project
57 | - run:
58 | name: Typecheck files
59 | command: |
60 | yarn typescript
61 |
62 | unit-tests:
63 | executor: default
64 | steps:
65 | - attach_project
66 | - run:
67 | name: Run unit tests
68 | command: |
69 | yarn test --coverage
70 | - store_artifacts:
71 | path: coverage
72 | destination: coverage
73 |
74 | build-package:
75 | executor: default
76 | steps:
77 | - attach_project
78 | - run:
79 | name: Build package
80 | command: |
81 | yarn prepare
82 |
83 | workflows:
84 | build-and-test:
85 | jobs:
86 | - install-dependencies
87 | - lint:
88 | requires:
89 | - install-dependencies
90 | - typescript:
91 | requires:
92 | - install-dependencies
93 | - unit-tests:
94 | requires:
95 | - install-dependencies
96 | - build-package:
97 | requires:
98 | - install-dependencies
99 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 | [*]
8 |
9 | indent_style = space
10 | indent_size = 2
11 |
12 | end_of_line = lf
13 | charset = utf-8
14 | trim_trailing_whitespace = true
15 | insert_final_newline = true
16 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 | # specific for windows script files
3 | *.bat text eol=crlf
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # XDE
6 | .expo/
7 |
8 | # VSCode
9 | .vscode/
10 | jsconfig.json
11 |
12 | # Xcode
13 | #
14 | build/
15 | *.pbxuser
16 | !default.pbxuser
17 | *.mode1v3
18 | !default.mode1v3
19 | *.mode2v3
20 | !default.mode2v3
21 | *.perspectivev3
22 | !default.perspectivev3
23 | xcuserdata
24 | *.xccheckout
25 | *.moved-aside
26 | DerivedData
27 | *.hmap
28 | *.ipa
29 | *.xcuserstate
30 | project.xcworkspace
31 |
32 | # Android/IJ
33 | #
34 | .idea
35 | .gradle
36 | local.properties
37 | android.iml
38 |
39 | # Cocoapods
40 | #
41 | example/ios/Pods
42 |
43 | # node.js
44 | #
45 | node_modules/
46 | npm-debug.log
47 | yarn-debug.log
48 | yarn-error.log
49 |
50 | # BUCK
51 | buck-out/
52 | \.buckd/
53 | android/app/libs
54 | android/keystores/debug.keystore
55 |
56 | # Expo
57 | .expo/*
58 |
59 | # generated by bob
60 | lib/
61 |
--------------------------------------------------------------------------------
/.yarnrc:
--------------------------------------------------------------------------------
1 | # Override Yarn command so we can automatically setup the repo on running `yarn`
2 |
3 | yarn-path "scripts/bootstrap.js"
4 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project.
4 |
5 | ## Development workflow
6 |
7 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
8 |
9 | ```sh
10 | yarn
11 | ```
12 |
13 | > While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development.
14 |
15 | While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app.
16 |
17 | To start the packager:
18 |
19 | ```sh
20 | yarn example start
21 | ```
22 |
23 | To run the example app on Android:
24 |
25 | ```sh
26 | yarn example android
27 | ```
28 |
29 | To run the example app on iOS:
30 |
31 | ```sh
32 | yarn example ios
33 | ```
34 |
35 | Make sure your code passes TypeScript and ESLint. Run the following to verify:
36 |
37 | ```sh
38 | yarn typescript
39 | yarn lint
40 | ```
41 |
42 | To fix formatting errors, run the following:
43 |
44 | ```sh
45 | yarn lint --fix
46 | ```
47 |
48 | Remember to add tests for your change if possible. Run the unit tests by:
49 |
50 | ```sh
51 | yarn test
52 | ```
53 |
54 | To edit the Objective-C files, open `example/ios/VisionCameraOcrExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > vision-camera-ocr`.
55 |
56 | To edit the Kotlin files, open `example/android` in Android studio and find the source files at `visioncameraocr` under `Android`.
57 |
58 | ### Commit message convention
59 |
60 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
61 |
62 | - `fix`: bug fixes, e.g. fix crash due to deprecated method.
63 | - `feat`: new features, e.g. add new method to the module.
64 | - `refactor`: code refactor, e.g. migrate from class components to hooks.
65 | - `docs`: changes into documentation, e.g. add usage example for the module..
66 | - `test`: adding or updating tests, e.g. add integration tests using detox.
67 | - `chore`: tooling changes, e.g. change CI config.
68 |
69 | Our pre-commit hooks verify that your commit message matches this format when committing.
70 |
71 | ### Linting and tests
72 |
73 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
74 |
75 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
76 |
77 | Our pre-commit hooks verify that the linter and tests pass when committing.
78 |
79 | ### Publishing to npm
80 |
81 | We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
82 |
83 | To publish new versions, run the following:
84 |
85 | ```sh
86 | yarn release
87 | ```
88 |
89 | ### Scripts
90 |
91 | The `package.json` file contains various scripts for common tasks:
92 |
93 | - `yarn bootstrap`: setup project by installing all dependencies and pods.
94 | - `yarn typescript`: type-check files with TypeScript.
95 | - `yarn lint`: lint files with ESLint.
96 | - `yarn test`: run unit tests with Jest.
97 | - `yarn example start`: start the Metro server for the example app.
98 | - `yarn example android`: run the example app on Android.
99 | - `yarn example ios`: run the example app on iOS.
100 |
101 | ### Sending a pull request
102 |
103 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
104 |
105 | When you're sending a pull request:
106 |
107 | - Prefer small pull requests focused on one change.
108 | - Verify that linters and tests are passing.
109 | - Review the documentation to make sure it looks good.
110 | - Follow the pull request template when opening a pull request.
111 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.
112 |
113 | ## Code of Conduct
114 |
115 | ### Our Pledge
116 |
117 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
118 |
119 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
120 |
121 | ### Our Standards
122 |
123 | Examples of behavior that contributes to a positive environment for our community include:
124 |
125 | - Demonstrating empathy and kindness toward other people
126 | - Being respectful of differing opinions, viewpoints, and experiences
127 | - Giving and gracefully accepting constructive feedback
128 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
129 | - Focusing on what is best not just for us as individuals, but for the overall community
130 |
131 | Examples of unacceptable behavior include:
132 |
133 | - The use of sexualized language or imagery, and sexual attention or
134 | advances of any kind
135 | - Trolling, insulting or derogatory comments, and personal or political attacks
136 | - Public or private harassment
137 | - Publishing others' private information, such as a physical or email
138 | address, without their explicit permission
139 | - Other conduct which could reasonably be considered inappropriate in a
140 | professional setting
141 |
142 | ### Enforcement Responsibilities
143 |
144 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
145 |
146 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
147 |
148 | ### Scope
149 |
150 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
151 |
152 | ### Enforcement
153 |
154 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly.
155 |
156 | All community leaders are obligated to respect the privacy and security of the reporter of any incident.
157 |
158 | ### Enforcement Guidelines
159 |
160 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
161 |
162 | #### 1. Correction
163 |
164 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
165 |
166 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
167 |
168 | #### 2. Warning
169 |
170 | **Community Impact**: A violation through a single incident or series of actions.
171 |
172 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
173 |
174 | #### 3. Temporary Ban
175 |
176 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
177 |
178 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
179 |
180 | #### 4. Permanent Ban
181 |
182 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
183 |
184 | **Consequence**: A permanent ban from any sort of public interaction within the community.
185 |
186 | ### Attribution
187 |
188 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
189 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
190 |
191 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
192 |
193 | [homepage]: https://www.contributor-covenant.org
194 |
195 | For answers to common questions about this code of conduct, see the FAQ at
196 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
197 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 rodrigo gomes
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vision-camera-ocr
2 |
3 | VisionCamera Frame Processor Plugin that uses MLKit Text Recognition API to recognize text in any Latin-based character set
4 |
5 | ## Installation
6 |
7 | ```sh
8 | npm install vision-camera-ocr
9 | ```
10 |
11 | ## Usage
12 |
13 | ```js
14 | import VisionCameraOcr from "vision-camera-ocr";
15 |
16 | // ...
17 |
18 | const result = await VisionCameraOcr.multiply(3, 7);
19 | ```
20 |
21 | ## Contributing
22 |
23 | See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
24 |
25 | ## License
26 |
27 | MIT
28 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3 | def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['VisionCameraOcr_kotlinVersion']
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 |
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.2.1'
12 | // noinspection DifferentKotlinGradleVersion
13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14 | }
15 | }
16 |
17 | apply plugin: 'com.android.library'
18 | apply plugin: 'kotlin-android'
19 |
20 | def getExtOrDefault(name) {
21 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['VisionCameraOcr_' + name]
22 | }
23 |
24 | def getExtOrIntegerDefault(name) {
25 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['VisionCameraOcr_' + name]).toInteger()
26 | }
27 |
28 | android {
29 | compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
30 | buildToolsVersion getExtOrDefault('buildToolsVersion')
31 | defaultConfig {
32 | minSdkVersion 16
33 | targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
34 | versionCode 1
35 | versionName "1.0"
36 |
37 | }
38 |
39 | buildTypes {
40 | release {
41 | minifyEnabled false
42 | }
43 | }
44 | lintOptions {
45 | disable 'GradleCompatible'
46 | }
47 | compileOptions {
48 | sourceCompatibility JavaVersion.VERSION_1_8
49 | targetCompatibility JavaVersion.VERSION_1_8
50 | }
51 | }
52 |
53 | repositories {
54 | mavenCentral()
55 | jcenter()
56 | google()
57 |
58 | def found = false
59 | def defaultDir = null
60 | def androidSourcesName = 'React Native sources'
61 |
62 | if (rootProject.ext.has('reactNativeAndroidRoot')) {
63 | defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
64 | } else {
65 | defaultDir = new File(
66 | projectDir,
67 | '/../../../node_modules/react-native/android'
68 | )
69 | }
70 |
71 | if (defaultDir.exists()) {
72 | maven {
73 | url defaultDir.toString()
74 | name androidSourcesName
75 | }
76 |
77 | logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
78 | found = true
79 | } else {
80 | def parentDir = rootProject.projectDir
81 |
82 | 1.upto(5, {
83 | if (found) return true
84 | parentDir = parentDir.parentFile
85 |
86 | def androidSourcesDir = new File(
87 | parentDir,
88 | 'node_modules/react-native'
89 | )
90 |
91 | def androidPrebuiltBinaryDir = new File(
92 | parentDir,
93 | 'node_modules/react-native/android'
94 | )
95 |
96 | if (androidPrebuiltBinaryDir.exists()) {
97 | maven {
98 | url androidPrebuiltBinaryDir.toString()
99 | name androidSourcesName
100 | }
101 |
102 | logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
103 | found = true
104 | } else if (androidSourcesDir.exists()) {
105 | maven {
106 | url androidSourcesDir.toString()
107 | name androidSourcesName
108 | }
109 |
110 | logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
111 | found = true
112 | }
113 | })
114 | }
115 |
116 | if (!found) {
117 | throw new GradleException(
118 | "${project.name}: unable to locate React Native android sources. " +
119 | "Ensure you have you installed React Native as a dependency in your project and try again."
120 | )
121 | }
122 | }
123 |
124 | def kotlin_version = getExtOrDefault('kotlinVersion')
125 |
126 | dependencies {
127 | // noinspection GradleDynamicVersion
128 | api 'com.facebook.react:react-native:+'
129 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
130 | }
131 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | VisionCameraOcr_kotlinVersion=1.3.50
2 | VisionCameraOcr_compileSdkVersion=29
3 | VisionCameraOcr_buildToolsVersion=29.0.2
4 | VisionCameraOcr_targetSdkVersion=29
5 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/src/main/java/com/visioncameraocr/VisionCameraOcrModule.kt:
--------------------------------------------------------------------------------
1 | package com.visioncameraocr
2 |
3 | import com.facebook.react.bridge.ReactApplicationContext
4 | import com.facebook.react.bridge.ReactContextBaseJavaModule
5 | import com.facebook.react.bridge.ReactMethod
6 | import com.facebook.react.bridge.Promise
7 |
8 | class VisionCameraOcrModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
9 |
10 | override fun getName(): String {
11 | return "VisionCameraOcr"
12 | }
13 |
14 | // Example method
15 | // See https://reactnative.dev/docs/native-modules-android
16 | @ReactMethod
17 | fun multiply(a: Int, b: Int, promise: Promise) {
18 |
19 | promise.resolve(a * b)
20 |
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/android/src/main/java/com/visioncameraocr/VisionCameraOcrPackage.kt:
--------------------------------------------------------------------------------
1 | package com.visioncameraocr
2 |
3 | import com.facebook.react.ReactPackage
4 | import com.facebook.react.bridge.NativeModule
5 | import com.facebook.react.bridge.ReactApplicationContext
6 | import com.facebook.react.uimanager.ViewManager
7 |
8 |
9 | class VisionCameraOcrPackage : ReactPackage {
10 | override fun createNativeModules(reactContext: ReactApplicationContext): List {
11 | return listOf(VisionCameraOcrModule(reactContext))
12 | }
13 |
14 | override fun createViewManagers(reactContext: ReactApplicationContext): List> {
15 | return emptyList()
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:metro-react-native-babel-preset'],
3 | };
4 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 |
3 | import com.android.build.OutputFile
4 |
5 | /**
6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7 | * and bundleReleaseJsAndAssets).
8 | * These basically call `react-native bundle` with the correct arguments during the Android build
9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10 | * bundle directly from the development server. Below you can see all the possible configurations
11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the
12 | * `apply from: "../../node_modules/react-native/react.gradle"` line.
13 | *
14 | * project.ext.react = [
15 | * // the name of the generated asset file containing your JS bundle
16 | * bundleAssetName: "index.android.bundle",
17 | *
18 | * // the entry file for bundle generation
19 | * entryFile: "index.android.js",
20 | *
21 | * // https://reactnative.dev/docs/performance#enable-the-ram-format
22 | * bundleCommand: "ram-bundle",
23 | *
24 | * // whether to bundle JS and assets in debug mode
25 | * bundleInDebug: false,
26 | *
27 | * // whether to bundle JS and assets in release mode
28 | * bundleInRelease: true,
29 | *
30 | * // whether to bundle JS and assets in another build variant (if configured).
31 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
32 | * // The configuration property can be in the following formats
33 | * // 'bundleIn${productFlavor}${buildType}'
34 | * // 'bundleIn${buildType}'
35 | * // bundleInFreeDebug: true,
36 | * // bundleInPaidRelease: true,
37 | * // bundleInBeta: true,
38 | *
39 | * // whether to disable dev mode in custom build variants (by default only disabled in release)
40 | * // for VisionCameraOcrExample: to disable dev mode in the staging build type (if configured)
41 | * devDisabledInStaging: true,
42 | * // The configuration property can be in the following formats
43 | * // 'devDisabledIn${productFlavor}${buildType}'
44 | * // 'devDisabledIn${buildType}'
45 | *
46 | * // the root of your project, i.e. where "package.json" lives
47 | * root: "../../",
48 | *
49 | * // where to put the JS bundle asset in debug mode
50 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
51 | *
52 | * // where to put the JS bundle asset in release mode
53 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
54 | *
55 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
56 | * // require('./image.png')), in debug mode
57 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
58 | *
59 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
60 | * // require('./image.png')), in release mode
61 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
62 | *
63 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
64 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
65 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle
66 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
67 | * // for VisionCameraOcrExample, you might want to remove it from here.
68 | * inputExcludes: ["android/**", "ios/**"],
69 | *
70 | * // override which node gets called and with what additional arguments
71 | * nodeExecutableAndArgs: ["node"],
72 | *
73 | * // supply additional arguments to the packager
74 | * extraPackagerArgs: []
75 | * ]
76 | */
77 |
78 | project.ext.react = [
79 | enableHermes: false, // clean and rebuild if changing
80 | entryFile: "index.tsx",
81 | ]
82 |
83 | apply from: "../../node_modules/react-native/react.gradle"
84 |
85 | /**
86 | * Set this to true to create two separate APKs instead of one:
87 | * - An APK that only works on ARM devices
88 | * - An APK that only works on x86 devices
89 | * The advantage is the size of the APK is reduced by about 4MB.
90 | * Upload all the APKs to the Play Store and people will download
91 | * the correct one based on the CPU architecture of their device.
92 | */
93 | def enableSeparateBuildPerCPUArchitecture = false
94 |
95 | /**
96 | * Run Proguard to shrink the Java bytecode in release builds.
97 | */
98 | def enableProguardInReleaseBuilds = false
99 |
100 | /**
101 | * The preferred build flavor of JavaScriptCore.
102 | *
103 | * For VisionCameraOcrExample, to use the international variant, you can use:
104 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
105 | *
106 | * The international variant includes ICU i18n library and necessary data
107 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108 | * give correct results when using with locales other than en-US. Note that
109 | * this variant is about 6MiB larger per architecture than default.
110 | */
111 | def jscFlavor = 'org.webkit:android-jsc:+'
112 |
113 | /**
114 | * Whether to enable the Hermes VM.
115 | *
116 | * This should be set on project.ext.react and mirrored here. If it is not set
117 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118 | * and the benefits of using Hermes will therefore be sharply reduced.
119 | */
120 | def enableHermes = project.ext.react.get("enableHermes", false);
121 |
122 | android {
123 | compileSdkVersion rootProject.ext.compileSdkVersion
124 |
125 | compileOptions {
126 | sourceCompatibility JavaVersion.VERSION_1_8
127 | targetCompatibility JavaVersion.VERSION_1_8
128 | }
129 |
130 | defaultConfig {
131 | applicationId "com.example.visioncameraocr"
132 | minSdkVersion rootProject.ext.minSdkVersion
133 | targetSdkVersion rootProject.ext.targetSdkVersion
134 | versionCode 1
135 | versionName "1.0"
136 | }
137 | splits {
138 | abi {
139 | reset()
140 | enable enableSeparateBuildPerCPUArchitecture
141 | universalApk false // If true, also generate a universal APK
142 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
143 | }
144 | }
145 | signingConfigs {
146 | debug {
147 | storeFile file('debug.keystore')
148 | storePassword 'android'
149 | keyAlias 'androiddebugkey'
150 | keyPassword 'android'
151 | }
152 | }
153 | buildTypes {
154 | debug {
155 | signingConfig signingConfigs.debug
156 | }
157 | release {
158 | // Caution! In production, you need to generate your own keystore file.
159 | // see https://reactnative.dev/docs/signed-apk-android.
160 | signingConfig signingConfigs.debug
161 | minifyEnabled enableProguardInReleaseBuilds
162 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
163 | }
164 | }
165 | // applicationVariants are e.g. debug, release
166 | applicationVariants.all { variant ->
167 | variant.outputs.each { output ->
168 | // For each separate APK per architecture, set a unique version code as described here:
169 | // https://developer.android.com/studio/build/configure-apk-splits.html
170 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
171 | def abi = output.getFilter(OutputFile.ABI)
172 | if (abi != null) { // null for the universal-debug, universal-release variants
173 | output.versionCodeOverride =
174 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
175 | }
176 |
177 | }
178 | }
179 | }
180 |
181 | dependencies {
182 | implementation fileTree(dir: "libs", include: ["*.jar"])
183 | //noinspection GradleDynamicVersion
184 | implementation "com.facebook.react:react-native:+" // From node_modules
185 |
186 |
187 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
188 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
189 | exclude group:'com.facebook.fbjni'
190 | }
191 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
192 | exclude group:'com.facebook.flipper'
193 | exclude group:'com.squareup.okhttp3', module:'okhttp'
194 | }
195 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
196 | exclude group:'com.facebook.flipper'
197 | }
198 |
199 | if (enableHermes) {
200 | def hermesPath = "../../node_modules/hermes-engine/android/";
201 | debugImplementation files(hermesPath + "hermes-debug.aar")
202 | releaseImplementation files(hermesPath + "hermes-release.aar")
203 | } else {
204 | implementation jscFlavor
205 | }
206 |
207 | implementation project(':visioncameraocr')
208 | }
209 |
210 | // Run this once to be able to run the application with BUCK
211 | // puts all compile dependencies into folder libs for BUCK to use
212 | task copyDownloadableDepsToLibs(type: Copy) {
213 | from configurations.compile
214 | into 'libs'
215 | }
216 |
217 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
218 |
--------------------------------------------------------------------------------
/example/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodgomesc/vision-camera-ocr/d459eceeda668accb3b2c9fccf871f5bbac5efa1/example/android/app/debug.keystore
--------------------------------------------------------------------------------
/example/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/java/com/example/visioncameraocr/ReactNativeFlipper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | *