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
32 stars 23 forks source link

dataURI instead of filePath #15

Closed czery closed 7 years ago

czery commented 7 years ago

Hi there,

I am wondering if you tried and managed to pass a dataURI (base64) or a byte array to the OpenALPR.scan() function instead of a file path. I saw in the ALPR.java that it should be possible in general but could not manage to get it working.

What I have tried is following:

It seems to compile well but when I execute this I never get a positive result from OpenALPR. Do you have any idea how to get this working? I think this might be a useful functionality for the plugin as well as you can skip the file writing before recognizing.

Cheers czery

melvinversluijs commented 7 years ago

Hi @czery ,

We never tried to pass a dataURI to the OpenALPR.scan() method before but it is indeed an useful improvement for the plugin.

So I implemented the changes your proposed and they seem to be working fine, it also gives back the expected result. This makes me wonder where our implementations differ.

I commented out the following lines of code:

  1. imagePath = imagePath.replace("file://", "");
  2. boolean imageExists = new File(imagePath).isFile();
  3. The entire line if (imageExists) { and its corresponding else { ... } block.

Furthermore I added the line byte[] decoded = Base64.decode(imagePath, Base64.DEFAULT); just before the try { ... } catch(e) { ... } block and replaced results = alpr.recognize(imagePath); with results = alpr.recognize(decoded); within this block.

Are you watching the android log while executing your application? You can watch the log of your emulator or connected debugging device by using the following command in your terminal adb logcat.

I have also tried to implement this for iOS but I have had no luck so far, I will try this a bit more at a later date. New releases of the plugin are expected to be released after my graduation (since im quite busy at the moment). This will probably be somewhere in July or August.

Hope this helps.

Cheers, Melvin

czery commented 7 years ago

Hi @m3lv1n ,

thanks for trying this out and for the hint with the adb logcat command. I managed to get this working now. Not sure why it did not work in the first place.... Good thing to improve performance on recognizing as you can skip the file writing.

Cheers and good luck for your graduation czery