Skip to content

Commit

Permalink
Release/2.0.0 (#29)
Browse files Browse the repository at this point in the history
## 2.0.0 - 2018-03-21
### Added
- Support for Base64 encoded image data
- Possibility to pass options to the scanner, like country and amount
- Better Ionic 3 support with `@ionic-native/openalpr`
- Updated documentation with examples

### Changed
- Add extra parameter for passing options in scan() (breaking change)
  • Loading branch information
iMicknl committed Mar 21, 2018
1 parent de159e4 commit 40406d5
Show file tree
Hide file tree
Showing 86 changed files with 16,627 additions and 12,650 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.0.0 - 2018-03-21
### Added
- Support for Base64 encoded image data
- Possibility to pass options to the scanner, like country and amount
- Better Ionic 3 support with `@ionic-native/openalpr`
- Updated documentation with examples

### Changed
- Add extra parameter for passing options in scan() (breaking change)

## 1.0.0 - 2016-11-19
### Added
- Initial release.
Expand Down
70 changes: 60 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,82 @@
# Cordova OpenALPR plugin
This Cordova plugin adds support for the OpenALPR (Automatic License Plate Recognition) library, which provides support for retrieving the license plate from a picture.
This Cordova plugin adds support for the [OpenALPR (Automatic License Plate Recognition) library](https://github.com/openalpr/openalpr) which provides support for retrieving the license plate from a picture. You can pass an image using Base64 or the file path to the OpenALPR plugin.

## Supported platforms
The current master branch supports the following platforms:
- iOS (>= 8)
- Android (>= SDK 21)

## Installation
This plugin requires Cordova 5.0+ and can be installed from the [Cordova Plugin Registry](https://cordova.apache.org/plugins/).
This plugin requires Cordova 5.0+ and can be installed from the [Cordova Plugin Registry](https://cordova.apache.org/plugins/). If you use Ionic 3, you should also install the `@ionic-native` binding.

`cordova plugin add cordova-plugin-openalpr`

## How to use
This plugin defines a global `cordova.plugins.OpenALPR` object, which provides an API for scanning license plates. It is possible to use the output of [cordova-plugin-camera](https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-camera/) and pass it to the scan function of this plugin.
`npm install @ionic-native/openalpr`

### Example
```
cordova.plugins.OpenALPR.scan(filepath, function (data) {
//Results
console.log(data);
## Examples

### Ionic 1 / PhoneGap
This plugin defines a global `cordova.plugins.OpenALPR` object which provides an API for scanning license plates. It is possible to use the output of [cordova-plugin-camera](https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-camera/) and pass it to the scan function of this plugin.

```javascript
cordova.plugins.OpenALPR.scan(filepath, { country: 'eu', amount: 3 }, function (results) {
console.log(results);
}, function (error) {
console.log(error.code + ': ' + error.message)
});
```

### Ionic 3
This plugin has a `@ionic-native/openalpr` binding available, which makes it easy to include it in your Ionic 3 project. You can use the output of `@ionic-native/camera` and pass it to the scan function of this plugin. *At the moment the binding isn't published in the `@ionic-native` repository yet, so you can import the binding using `cordova-plugin-openalpr/native`.*

There is also an [Ionic 3 example project](https://github.com/melvinversluijs/ionic3-sample) available which shows the possible implementation of cordova-plugin-openalpr.

```typescript
import { Camera, CameraOptions } from '@ionic-native/camera';
import { OpenALPR, OpenALPROptions, OpenALPRResult } from 'cordova-plugin-openalpr/native';
constructor(private camera: Camera, private openALPR: OpenALPR) {
}
const cameraOptions: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: this.camera.PictureSourceType.CAMERA
}
const scanOptions: OpenALPROptions = {
country: this.openalpr.Country.EU,
amount: 3
}
this.camera.getPicture(cameraOptions).then((imageData) => {
this.openALPR.scan(imageData)
.then((result: [OpenALPRResult]) => console.log(result.number))
.catch((error: Error) => console.error(error));
});
```

This plugin is only supported on iOS / Android, however in order to speed up development you can make use of [mocking and browser development](https://github.com/ionic-team/ionic-native#mocking-and-browser-development).

## Known Issues
### opencv2/highgui/highgui.hpp' file not found when compiling iOS app
This Cordova plugin uses custom framework files for iOS which make use of symlinks on MacOS. Symlinks can break when the plugin is either downloaded on Windows and then moved to an MacOS machine or when the plugin is pulled from the Cordova plugin repo / npm without the symlinks being present in the archive [as described in this Cordova bug](https://issues.apache.org/jira/browse/CB-6092). You can solve this by [using a hook](https://docs.microsoft.com/en-us/visualstudio/cross-platform/tools-for-cordova/tips-workarounds/ios-plugin-symlink-fix-readme?view=toolsforcordova-2015) which fixes the issue before compiling. If you don't want to use a hook, you can also manually fix the files as described [here](https://github.com/iMicknl/cordova-plugin-openalpr/issues/12) or clone the repository from Github and add it to your project.

### Android: PictureSourceType.PHOTOLIBRARY isn't supported (yet)
In Android apps, passing the file uri from PictureSourceType.PHOTOLIBRARY isn't supported yet. This is because the photolibrary returns a different kind of path than the camera does. The cordova-plugin-filepath might provide a workaround for now but this has not been tested yet.

## Notes
- This project includes prebuilt OpenALPR libraries for iOS and Android, because the compilation of the OpenALPR framework requires a lot of effort and dependencies.
- This project is not used in production anymyore and won't be maintained actively. We can't guarantee that we can respond quickly to issues / pull requests, however we will keep an eye on the repository.

## License
MIT, but keep in mind that OpenALPR itself is licensed under AGPL-3.0.

## Credits
- License plate scanning based on [OpenALPR](https://github.com/openalpr/openalpr).
- iOS platform support based on [OpenALPR iOS](https://github.com/twelve17/openalpr-ios).
- Android platform support based on [OpenALPR Java bindings](https://github.com/openalpr/openalpr/tree/master/src/bindings/java)
- Android platform support based on [OpenALPR Java bindings](https://github.com/openalpr/openalpr/tree/master/src/bindings/java)
- iOS Base64 implementation by [@baukeroo](https://github.com/baukeroo)
57 changes: 57 additions & 0 deletions native/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { IonicNativePlugin } from '@ionic-native/core';
export interface OpenALPROptions {
/** Country used for scanning the license plate */
country?: string;
/** Amount of results returned */
amount?: number;
}
export interface OpenALPRResult {
/** LicensePlate */
number: string;
/** Probability */
confidence: number;
}
/**
* @name OpenALPR
* @description
* This Cordova plugin adds support for the OpenALPR (Automatic License Plate Recognition) library, which provides support for retrieving the license plate from a picture.
*
* @usage
* ```typescript
* import { OpenALPR, OpenALPROptions, OpenALPRResult } from '@ionic-native/openalpr';
*
*
* constructor(private openALPR: OpenALPR) { }
*
* const scanOptions: OpenALPROptions = {
* country: this.openALPR.Country.EU,
* amount: 3
* }
*
* // To get imageData, you can use the @ionic-native/camera module for example. It works with DestinationType.FILE_URI and DATA_URL
*
* this.openALPR.scan(imageData, scanOptions)
* .then((res: [OpenALPRResult]) => console.log(res))
* .catch((error: Error) => console.error(error));
*
* ```
*/
export declare class OpenALPR extends IonicNativePlugin {
Country: {
AU: string;
BR: string;
BR2: string;
EU: string;
IN: string;
KR2: string;
US: string;
VN2: string;
};
/**
* This function does something
* @param imageData {any} Base64 encoding of the image data or the image file URI
* @param options {OpenALPROptions} Options to pass to the OpenALPR scanner
* @return {Promise<any>} Returns a promise that resolves when something happens
*/
scan(imageData: any, options?: OpenALPROptions): Promise<any>;
}
93 changes: 93 additions & 0 deletions native/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions native/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions native/index.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"__symbolic":"module","version":3,"metadata":{"OpenALPROptions":{"__symbolic":"interface"},"OpenALPRResult":{"__symbolic":"interface"},"OpenALPR":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"@ionic-native/core","name":"IonicNativePlugin"},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Plugin"},"arguments":[{"pluginName":"OpenALPR","plugin":"cordova-plugin-openalpr","pluginRef":"cordova.plugins.OpenALPR","repo":"https://github.com/iMicknl/cordova-plugin-openalpr","platforms":["Android","iOS"]}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"scan":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}]}}}},{"__symbolic":"module","version":1,"metadata":{"OpenALPROptions":{"__symbolic":"interface"},"OpenALPRResult":{"__symbolic":"interface"},"OpenALPR":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"@ionic-native/core","name":"IonicNativePlugin"},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Plugin"},"arguments":[{"pluginName":"OpenALPR","plugin":"cordova-plugin-openalpr","pluginRef":"cordova.plugins.OpenALPR","repo":"https://github.com/iMicknl/cordova-plugin-openalpr","platforms":["Android","iOS"]}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"scan":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}]}}}}]
16 changes: 16 additions & 0 deletions native/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@ionic-native/openalpr",
"version": "4.5.2",
"description": "Ionic Native - Native plugins for ionic apps",
"module": "index.js",
"typings": "index.d.ts",
"author": "ionic",
"license": "MIT",
"peerDependencies": {
"@ionic-native/core": "^4.2.0"
},
"repository": {
"type": "git",
"url": "https://github.com/ionic-team/ionic-native.git"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-openalpr",
"version": "1.0.0",
"version": "2.0.0",
"description": "This Cordova plugin adds support for the OpenALPR (Automatic License Plate Recognition) library, which provides support for retrieving the license plate from a picture.",
"cordova": {
"id": "cordova-plugin-openalpr",
Expand Down Expand Up @@ -29,4 +29,4 @@
"url": "https://github.com/iMicknl/cordova-plugin-openalpr/issues"
},
"homepage": "https://github.com/iMicknl/cordova-plugin-openalpr#readme"
}
}
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-openalpr" version="1.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0"
<plugin id="cordova-plugin-openalpr" version="2.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">
<name>OpenALPR</name>
<description>OpenALPR Cordova Plugin</description>
Expand Down
Loading

0 comments on commit 40406d5

Please sign in to comment.