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.
MIT License
33 stars 23 forks source link

Always returning empty array #46

Closed HighSoftWare96 closed 5 years ago

HighSoftWare96 commented 5 years ago

Hi, I'm trying to use this plugin with Ionic 4. The issue is that the plugin returns always an empty array as result. I pass a base64 image to the scan method.

myMethod() {
      this.camera.getPicture({
        encodingType: this.camera.EncodingType.JPEG,
        mediaType: this.camera.MediaType.PICTURE,
        destinationType: this.camera.DestinationType.DATA_URL,
        allowEdit: false
      }).then((base64) => {
        this.processOpenALPR('data:image/jpeg;base64,' + base64);
      }).catch((error) => {
        alert('Unable to get picture from camera. See log.');
        console.error(error);
      });
}

  processOpenALPR(base64: string) {
    this.openAlpr.scan(base64, {
      country: this.openAlpr.Country.EU,
      amount: 3
    }).then((res: OpenALPRResult[]) => {
      console.log(res);
    }).catch(error => {
      alert('Error using OpenALPR. See log.');
      console.error(error);
    });
  }

This is my environment:

Ionic:

   Ionic CLI                     : 5.2.6 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.8.0
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.0.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.0.0
   Cordova Plugins   : cordova-plugin-ionic 5.4.4, cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 14 other plugins)

Utility:

   cordova-res : 0.6.0
   native-run  : 0.2.8

System:

   NodeJS : v10.16.0 (/usr/local/bin/node)
   npm    : 6.9.0
   OS     : macOS Mojave
   Xcode  : Xcode 10.3 Build version 10G8

I'm using the 2.1.0 version of the pugin.

iMicknl commented 5 years ago

Are you building for iOS or Android? (or both)

I am not sure if you need to prepend data:image/jpeg;base64, to the camera result when you are using DestinationType.DATA_URL. In the Ionic 4 example we are not doing this. Could you try it without? If it works without, we could have a look in solving this in the code also.

@melvinversluijs your thoughts?

HighSoftWare96 commented 5 years ago

I'm using Android. I think you're right: the problem is the prefix for the base64 image, there shouldn't be. Without it the plugin makes the previsions. Thanks!