iMicknl / cordova-plugin-openalpr

This Cordova plugin adds support for the OpenALPR (Automatic License Plate Recognition) library, which provides support for retrieving the license plate from a picture.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working on arm64-v8a, x86 or x86_64 Android devices.

RZR666 opened this issue · comments

commented

Hi,

I receive no error or response using Ionic 4, anyone else had an issue?

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (.nvm/versions/node/v10.4.0/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.2.0
   @angular-devkit/build-angular : 0.13.8
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.3.8
   @ionic/angular-toolkit        : 1.4.1

Cordova:

   cordova (Cordova CLI) : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms     : android 6.4.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 12 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Library/Android/sdk)
   NodeJS            : v10.4.0 (/.nvm/versions/node/v10.4.0/bin/node)
   npm               : 6.5.0
   OS                : macOS Mojave
public getText(imageData): Promise<any> {

    return new Promise<any>((resolve, reject) => {

      console.log("hit");

      this.openalpr.scan(imageData, this.openAlprOptions)
        .catch((err) => {

          console.error('not hit');
          reject(err)

        })
        .then((result) => 
        {
          console.log("not it");
          console.log(result);
          resolve(result);
        }
        );
    });
  }
  • What kind of license plates are you trying to scan, could you please include an example?
  • Are you using the @ionic-native/openalpr binding?
  • What is imageData? Could you share a snippet of the initialisation of imageData?

Please have a look at the Ionic 4 sample project, does this work with your image.

commented

Hi mate,

I'm trying to scan a UK Plate, https://we.tl/t-N6Srt5N4S0

I am using the Ionic Native yes.

imageData example is below, which is base64, using the camera and cropperJS to toDataURL().

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAEBAyADAREAAhEBAxEB/8QAHwAAAQMEAwEAAAAAAAAAAAAABQMEBgIHCQoBCAsA/8QAXxAAAQMCBAMFBAYGBggDBAITAQIDEQQhBQYSMQAHQQgTIlFhCRRxgTKRobHB8AoVI0LR8RYzNFKy4RckNWJyc3SzGDZDGSUmgsInN3WTGihFU5LD0kZHVGODhKK00//EABwBAAMBAQEBAQEAAAAAAAAAAAIDBAEFAAYHCP/EAEoRAAEDAwIEAwcCBQMDAwIBDQECESEAAzFBUQQSYXGBkaEFEyKxwdHwMuEUIzNC8QZSchU0smKCwiRzJUNEUwc1Y4OiFheEkuL/2gAMAwEAAhEDEQA/AMhOYu2FlF3H15gwegocTepVuLeCzCqWUqQr3dJBDi1A6WylCVNJVqnVtBdv3/4Rdv3gJXEEvys+rsC0y57Fq7CeG90tKGckcx7gjJ1bxGuKQw/t1ZWGHVH66wesfWmqSnD6Ipp+875xaUghxTyU6VBR1K0JAgkiRfi8GjiedSuYQeUAuXCjJ1xg9G1NM4h+UID9xl8k4jIbOMVbbPPbfwbGMbo6Nz3NtnB2V1QpGS4CkOtKQG3KppAaDgUYA1OIICrxB4+o4ZF62U8xCnDdA86fL7VzOJQUWjyvzkOAXGRD4y7/AHFWxwX2hWJUTqqjL+WMODLdUtpdQ6+pFQpQVoDhdTd0BGkFUSUhIm1h42yq4sC4QLZHxgFsCIbfr0gZr9kW1i2v35JJgP0diS4zMiXFSTLXbiy9i2bqqsz9gjlRUam3qWooagqpGNCAmEqcKlMobSQpQ7shSgZGpQIitov8PaX7tTIMKbKZGCR2nrincQE8xBcpwOud....

I have based this on the Ionic 4 sample, so it should be the same but I'm getting no result and no error.

commented

Ok, so I removed everything, and added the android version used in your Sample and I have a different error... is this because there's no lib for arm64?

04-12 09:38:15.195 22007 22116 W System.err: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/uk.co.psattendant-QixE7lNhSE1_mp10sRDNFw==/base.apk"],nativeLibraryDirectories=[/data/app/uk.co.psattendant-QixE7lNhSE1_mp10sRDNFw==/lib/arm64, /data/app/uk.co.psattendant-QixE7lNhSE1_mp10sRDNFw==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libopenalprjni.so" 04-12 09:38:15.196 22007 22116 W System.err: at java.lang.Runtime.loadLibrary0(Runtime.java:1011) 04-12 09:38:15.196 22007 22116 W System.err: at java.lang.System.loadLibrary(System.java:1657) 04-12 09:38:15.196 22007 22116 W System.err: at com.openalpr.jni.Alpr.<clinit>(Alpr.java:9) 04-12 09:38:15.196 22007 22116 W System.err: at org.apache.cordova.openalpr.OpenALPR.initAlpr(OpenALPR.java:170) 04-12 09:38:15.196 22007 22116 W System.err: at org.apache.cordova.openalpr.OpenALPR.scan(OpenALPR.java:114) 04-12 09:38:15.197 22007 22116 W System.err: at org.apache.cordova.openalpr.OpenALPR.execute(OpenALPR.java:44) 04-12 09:38:15.197 22007 22116 W System.err: at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98) 04-12 09:38:15.197 22007 22116 W System.err: at org.apache.cordova.PluginManager.exec(PluginManager.java:132) 04-12 09:38:15.197 22007 22116 W System.err: at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59) 04-12 09:38:15.197 22007 22116 W System.err: at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41) 04-12 09:38:15.197 22007 22116 W System.err: at android.os.MessageQueue.nativePollOnce(Native Method) 04-12 09:38:15.197 22007 22116 W System.err: at android.os.MessageQueue.next(MessageQueue.java:325) 04-12 09:38:15.198 22007 22116 W System.err: at android.os.Looper.loop(Looper.java:142) 04-12 09:38:15.198 22007 22116 W System.err: at android.os.HandlerThread.run(HandlerThread.java:65)

Hi @RZR666,

We've only built the library for armeabi-v7a since most Android devices seem to support this. However the default Android Studio recommended images seem to be x86. While creating an emulator using Android Studio you can choose the 'Other Images' tab to select an armeai-v7a image.

I've also tried the image you've included using our ionic-4-sample application and this one did not seem to work. I'm guessing this is because it is a cutout on a white background, which the OpenALPR library probably is not trained for. When I used a Google Image of an UK license (one on an actual car) it did work.

If you are not sure if the plugin is being triggered you could always try to use the Android Studio debugger. Adding a breakpoint to the start of the org.apache.cordova/OpenALPR file should help you out a bit.

Cheers, Melvin

commented

Cheers mate.

This was running on an actual device, I've since tried another phone and it worked great so I guess it's limited to certain devices.

Great to hear @RZR666. I will close this issue. If you made modifications to enable support on arm64, could you do a pull request to contribute back?

commented

Hi,

If I get it working I will update.

It's not working on most Android phones at present, I've found all the libs at another repo below,

https://github.com/BabbleCar/cordova-plugin-scanplate

But it looks like libopenalprjni.so needs compiling for each architechture.

Faced this issue, managed to fix it so it runs off my phone, not emulator.

Emulators are (most of the time) x86. This plugin is specifically build around armeabi-v7a.
90%+ of android phones support armeabi-v7a.

The fix I found is putting the following configuration in your app build.grade, inside the android block

ndk { abiFilters "armeabi-v7a" }

This will force the host device to run the apk only for this architecture and not look for any other libraries anywhere else.