NeutrinosPlatform / cordova-plugin-mobile-ocr

A cordova plugin that can accept image URI or Base64 data and returns the text present in the image as string without need for network. You can also try :- https://github.com/NeutrinosPlatform/cordova-plugin-ml-text
MIT License
49 stars 30 forks source link

Does not work with base64 image #25

Closed dany-nonstop closed 4 years ago

dany-nonstop commented 5 years ago

My code is pretty straightforward, in a ionic4 project I uses a single pixel image to test that the plugin is running correctly. And I got this error:

main loop exception

, with no context / detail explanation for me to debug.

  src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';
  content = 'abc';

  constructor(private ocr: OCR) {
    this.ocr.recText(OCRSourceType.BASE64, this.src)
      .then((res: any) => {console.log(JSON.stringify(res)); this.content = JSON.stringify(res);})
      .catch((error: any) => {console.error(error); this.content = JSON.stringify(error); });
  }

ps. I got the single pixel base64 from google search, it's a transparent png.

let me know if any additional information is required for your debugging. actually I tried other base64 images and got the same error so far.

ChrisTomAlx commented 5 years ago

Hey @github-yd Thanks for raising an issue here,

Try changing src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=='; to src = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';

Cheers, Chris Neutrinos

pdrhlik commented 4 years ago

Hi @ChrisTomAlx,

I was having the same problem but your suggestion fixed it. I followed an example on the Ionic OCR plugin page but it's obviously wrong.

You can safely close this issue.

Thanks a lot for the help!

Cheers, Patrik

ChrisTomAlx commented 4 years ago

Hey @pdrhlik

Thanks for updating me on this.. Will close the issue.

Cheers, Chris Neutrinos