|
1 | 1 | # What this tutorial is about
|
2 |
| - How to use OpenCV for data processing togeether with React Native |
| 2 | +This tutorial is how to use React Native together with OpenCV for image processing. This example uses native Java and Objective-C bindings for OpenCV. In this example we use the device's camera to take a photo and detect whether the taken photo is clear or blurred. |
| 3 | + |
| 4 | +# Demo |
| 5 | + |
| 6 | +The examples below show the situation right after taking a photo. The first one shows what happens if we take a blurry photo and the second one is the situation after we took a clear photo and are able to proceed with it to do whatever we want. |
| 7 | + |
| 8 | + |
| 9 | + |
3 | 10 |
|
4 | 11 | # Prerequisites
|
5 | 12 |
|
|
9 | 16 | # How to run the project
|
10 | 17 |
|
11 | 18 | 1. Clone the repository.
|
12 |
| -2. Run `./downloadAndInsertOpenCV.sh`. |
13 |
| -3. Download manually the Android pack from https://opencv.org/releases.html (version 3.4.1). |
14 |
| -4. Unzip the package. |
15 |
| -5. Import OpenCV to Android Studio, From File -> New -> Import Module, choose sdk/java folder in the unzipped opencv archive. |
16 |
| -6. Update build.gradle under imported OpenCV module to update 4 fields to match your project build.gradle a) compileSdkVersion b) buildToolsVersion c) minSdkVersion and d) targetSdkVersion. |
17 |
| -7. Add module dependency by Application -> Module Settings, and select the Dependencies tab. Click + icon at bottom, choose Module Dependency and select the imported OpenCV module. For Android Studio v1.2.2, to access to Module Settings : in the project view, right-click the dependent module -> Open Module Settings. |
18 |
| -8. `react-native run-ios` or `react-native run-android`. |
| 19 | +2. `cd cloned/repository/path` |
| 20 | +3. `npm i` or `yarn` |
| 21 | +4. `react-native link` |
| 22 | +5. Run `./downloadAndInsertOpenCV.sh`. |
| 23 | +6. Download manually the Android pack from https://opencv.org/releases.html (version 3.4.1). |
| 24 | +7. Unzip the package. |
| 25 | +8. Import OpenCV to Android Studio, From File -> New -> Import Module, choose sdk/java folder in the unzipped opencv archive. |
| 26 | +9. Update build.gradle under imported OpenCV module to update 4 fields to match your project's `build.gradle`<br/> |
| 27 | + |
| 28 | +a) compileSdkVersion<br/> |
| 29 | +b) buildToolsVersion<br/> |
| 30 | +c) minSdkVersion<br/> |
| 31 | +d) targetSdkVersion. |
| 32 | + |
| 33 | +10. Add module dependency by Application -> Module Settings, and select the Dependencies tab. Click + icon at bottom, choose Module Dependency and select the imported OpenCV module. For Android Studio v1.2.2, to access to Module Settings : in the project view, right-click the dependent module -> Open Module Settings. |
| 34 | +11. `react-native run-ios` or `react-native run-android`. |
| 35 | + |
| 36 | +## Additional notes |
| 37 | +In case of any `downloadAndInsertOpenCV.sh ` script related errors, please, check the paths inside this file and change them if they do not match yours. |
| 38 | +If this script does not run at all since it has no permissions, run `chmod 777 downloadAndInsertOpenCV.sh`. |
| 39 | + |
| 40 | +If you do not have `React Native` installed, type `npm i -g react-native-cli` in the terminal. |
19 | 41 |
|
20 | 42 | ## License
|
21 | 43 |
|
|
0 commit comments