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

Example/Usage With Cordova-Plugin-Camera

SonnyCampbell opened this issue · comments

I'm trying to get the OpenALPR.scan function to take the output of cordova-plugin-camera, but can't seem to get it working correctly. In the below code, this.testInfo = "Three"; is never hit, but it is also not being set to any error message. Do I need to transform the data from this.camera.getPicture somehow to pass it into the cordova.plugins.OpenALPR.scan() function?

CaptureReg(event) {

    //this.regNumber = "test reg";
    this.testInfo = "One";
    this.camera.getPicture(this.options).then((imageData) => {
      this.testInfo = "Two";
      cordova.plugins.OpenALPR.scan(imageData, function (data) {

          //Results      
          //this.testInfo = data;
          this.testInfo = "Three";
          console.log(data);

      }, function (error) {

        this.testInfo = error.code + ': ' + error.message;
        console.log(error.code + ': ' + error.message)
      });

      // imageData is either a base64 encoded string or a file URI
      // If it's base64:
      this.base64Image = 'data:image/jpeg;base64,' + imageData;
      
      console.log(this.base64Image);
     }, (err) => {
      // Handle error
      this.testInfo = err;
      console.log(err)
     });
    }

@iMicknl I also raised this issue. I managed to get around the errors by following the error messages and moving/modifying files in the platform folders, but it ended up only getting me to this point, and it could never actually get cordova.plugins.OpenALPR.scan() to run correctly.

I modified the OpenALPR.js file and it seems to reach the scan function ok, but when it tries to do the exec() it never reaches the OpenALPR.java file. I edited the OpenALPR.java file to automatically call the success function whenever it reached the execute function, but it seems like it never hit that point. I'm not familiar with the plumbing of cordova plugins so there might be something I missed, but that was as far as I could figure out.

It would really be a massive help if you could take a look into these issues for me, and I'm happy to work with you on them if you need it. I'm just not really sure where to start.

scan: function(filepath, success, error) { exec( success, error, 'OpenALPR', 'scan', [filepath] ) }

I can reproduce this using Android 7..1.1, however I don't have a fix available yet. @melvinversluijs and I just updated the iOS package for a 2.0.0 release of the plugin, but we are still struggling with the Android counterpart.

Did you make any progress? A possible solution could be downgrading to a lower SDK version.

@SonnyCampbell,
In our case the problem was caused by an iOS only function of the Camera module. This function was compiled into Android aswel which made it crash. Wrapping the function in a if platform === 'ios' block fixed the issue.

Could you provide a bit more of your code (Like the camera options). So I can help you debug this issue?

Kind regards,
Melvin

Closing issue due to inactivity and the release of version 2.0. If you are still facing this issue with v2.0, let us know and we will reopen.