You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[OpenALPR](https://github.com/openalpr/openalpr) integration for React Native. Provides a camera component that recognizes license plates in real-time. Supports both iOS and Android.
5
+
[OpenALPR](https://github.com/openalpr/openalpr) integration for React Native. Provides a camera component that recognizes license plates in real-time. Supports both iOS and Android.
@@ -17,20 +20,18 @@ Start by adding the package and linking it.
17
20
18
21
```sh
19
22
$ yarn add react-native-openalpr
20
-
$ react-native link react-native-openalpr
21
23
```
22
24
23
-
or if you are using npm:
25
+
### iOS Specific Setup
26
+
27
+
#### Install pods
24
28
25
29
```sh
26
-
$ npm i -S react-native-openalpr
27
-
$ react-native link react-native-openalpr
30
+
$ cd ios && pod install &&cd ...
28
31
```
29
-
Unfortunately, the `react-native link` command does not do everything it needs to do, so continue on to the project specific instructions below.
30
-
31
-
### iOS Specific Setup
32
32
33
33
#### Camera Permissions
34
+
34
35
- Add an entry for `NSCameraUsageDescription` in your `info.plist` explaining why your app will use the camera. If you forget to add this, your app will crash!
35
36
36
37
```xml
@@ -44,30 +45,18 @@ Unfortunately, the `react-native link` command does not do everything it needs t
44
45
</dict>
45
46
```
46
47
47
-
#### Linking
48
-
The project needs to be linked against four libraries: leptonica, opencv, tesseract, and openalpr.
49
-
- In Xcode, open your project (`.xcodeproj`).
50
-
- Go to `File -> Add Files` (or `Option + Command + A`)
51
-
- Click the `Options` button on the bottom and tick the `Copy items if needed` option.
52
-
- Add all four frameworks (leptonica, opencv, tesseract, openalpr) from the `node_modules/react-native-openalpr/ios/Frameworks`. This should cause the project to add a framework search path to the project's build settings (e.g. `$(PROJECT_DIR)/../node_modules/react-native-openalpr/ios/Frameworks`).
53
-
- Ensure that all four frameworks are included in the `Link Binary With Libraries` build phase by selecting your project in the tray on the left, selecting the `Build Phases` tab, then checking that each framework is included in the list of `Link Binary With Libraries`.
54
-
55
-
#### Resources
56
-
The alpr library requires a config file (`openalpr.conf`) and a data folder (`runtime_data`), both of which are included in the openalpr framework, but must be copied to the application resources:
57
-
- Select your project on the project navigator, then, on the main pane, go to `Targets` → `<Your Project>` → `Build Phases` → `Copy Bundle Resources`, and click on the `+`.
58
-
- Select `Add Other...`
59
-
- Browse *into* the `openalpr.framework` bundle, and command-select both `runtime_data` and `openalpr.conf`. Unselect `Copy items if needed` and select `Create folder references`.
60
-
61
48
#### Bitcode
62
-
Because the OpenCV binary framework release is compiled without bitcode, the other frameworks built by this script are also built without it, which ultimately means your Xcode project also cannot be built with bitcode enabled. [Per this message](http://stackoverflow.com/a/32728516/868173), it sounds like we want this feature disabled for OpenCV anyway.
49
+
50
+
Because the OpenCV binary framework release is compiled without bitcode, the other frameworks built by this script are also built without it, which ultimately means your Xcode project also cannot be built with bitcode enabled. [Per this message](http://stackoverflow.com/a/32728516/868173), it sounds like we want this feature disabled for OpenCV anyway.
63
51
64
52
To disable bitcode in your project:
65
53
66
-
- In `Build Settings` → `Build Options`, search for `Enable Bitcode` and set it to `No`.
54
+
- In `Build Settings` → `Build Options`, search for `Enable Bitcode` and set it to `No`.
67
55
68
-
## Android-specific Setup
56
+
###Android-specific Setup
69
57
70
58
#### Camera Permissions
59
+
71
60
- Add permissions for `CAMERA` and `FLASHLIGHT` and the related features (below) to `AndroidManifest.xml`. If you forget to add these permissions, your app will crash!
72
61
73
62
```xml
@@ -86,7 +75,8 @@ To disable bitcode in your project:
86
75
```
87
76
88
77
#### Add to Gradle
89
-
###### Your `android/settings.gradle` file should have following lines:
78
+
79
+
###### Your `android/settings.gradle` file should have following lines:
90
80
91
81
```java
92
82
@@ -99,35 +89,36 @@ project(':react-native-openalpr').projectDir = new File(rootProject.projectDir,
99
89
100
90
```
101
91
102
-
###### and `android/app/build.gradle` file should have the following under dependencies:
103
-
`compile project(':react-native-openalpr')`
92
+
###### and `android/app/build.gradle` file should have the following under dependencies:
93
+
94
+
`compile project(':react-native-openalpr')`
104
95
105
96
#### Linking
97
+
106
98
The library is linked automatically with leptonica, opencv, tesseract, and openalpr ([openalpr](https://github.com/SandroMachado/openalpr-android)).
107
99
To make it work, copy and paste the directory with the runtime needed data to your project at path `android/app/src/main/assets/runtime_data`.
108
100
109
101
The `runtime_data` file can be found in `/Example/android/app/src/main/assets/` in this repo. Open `runtime_data/openalpr.conf` file and replace `com.awesomeproject` with your package name
110
102
111
103
#### Add to an Activity
112
-
Open your activity, usually located in `android/app/src/main/java/[your package]/MainApplication.java`.
113
-
Add `import com.cardash.openalpr.CameraReactPackage;` to the imports at the top of the file.
114
-
Add `new CameraReactPackage()` to the list returned by the `getPackages()` method.
104
+
105
+
Open your activity, usually located in `android/app/src/main/java/[your package]/MainApplication.java`.
106
+
Add `import com.cardash.openalpr.CameraReactPackage;` to the imports at the top of the file.
107
+
Add `new CameraReactPackage()` to the list returned by the `getPackages()` method.
115
108
116
109
## Usage
117
110
118
111
OpenALPR exposes a camera component (based on [react-native-camera](https://github.com/lwansbrough/react-native-camera)) that is optimized to run OpenALPR image processing on a live camera stream. Among other parameters, the camera accepts a callback, `onPlateRecognized`, for when a plate is recognized.
The resolution at which video frames are captured and analyzed. For completeness, several options are provided. However, it is strongly recommended that you stick with one of the following for the best frame rates and accuracy:
2) From the `Example` directory, run `npm install`
249
+
2. From the `example` directory, run `yarn`
261
250
262
-
3) Copy the `android` folder from `/react-native-openalpr/android` to `/react-native-openalpr/Example/node_modules/react-native-openalpr/`
251
+
3. Copy the `android` folder from `/react-native-openalpr/android` to `/react-native-openalpr/Example/node_modules/react-native-openalpr/`
263
252
264
-
4) Open Android Studio and import the project `react-native-openalpr/Example/android` and wait until Android Studio indexes and links.
253
+
4. Open Android Studio and import the project `react-native-openalpr/Example/android` and wait until Android Studio indexes and links.
265
254
266
-
5) Run `npm start` from dir /react-native-openalpr/Example/
255
+
5. Run `npm start` from dir /react-native-openalpr/Example/
267
256
268
-
6) Open the path in your browser `http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false`
257
+
6. Open the path in your browser `http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false`
269
258
270
-
7) Create file the `/react-native-openalpr/Example/android/app/src/main/assets/index.android.bundle`. Copy and paste the data from browser window to the file you just created and save.
259
+
7. Create file the `/react-native-openalpr/Example/android/app/src/main/assets/index.android.bundle`. Copy and paste the data from browser window to the file you just created and save.
271
260
272
-
8) Return to Android Studio and run project on your development device.
261
+
8. Return to Android Studio and run project on your development device.
273
262
274
263
Note: If you are getting errors, double check that you have completed all of the steps above. If you are having issues running `npm start` on Mac OSX and are using homebrew, [this issue might help](https://github.com/facebook/react-native/issues/910).
275
264
276
265
## Credits
266
+
277
267
- OpenALPR built from [OpenALPR-iOS](https://github.com/twelve17/openalpr-ios)
278
268
- Project scaffold based on [react-native-camera](https://github.com/lwansbrough/react-native-camera)
0 commit comments