Page 1 of 1

Problem passing Base64 Encoded Image to Tesseract

Posted: Thu Nov 19, 2020 12:00 am
by ecann
Hello this is the normal tesseract api sample I use and it works

Code: Select all

do "Tesseract.recognize('https://i.ibb.co/6NK7gmV/mtncode.png','eng',{ logger: m => console.log(m)}).then(({ data:{ text }}) => {  liveCode.creditLoad(text)});" in widget "Browser"
The above code provides be with the processed text from the image for used.

With the codes below I want to export a snapshot from livecode and pass it to the tesseract api. I encoded the image and passed it to the image parameter of the tesseract api but it didnt work.


Code: Select all

export snapshot from rect (the rect of graphic "credit") of this card to tImageVariable as PNG
put base64Encode(tImageVariable) into gImageVariable

 do  "Tesseract.recognize("  & quote & "data:image/png;base64," & gImageVariable & quote  & ",'eng',{ logger: m => console.log(m)}).then(({ data:{ text }}) => { document.write(text)});" in widget "Browser"
This is the error I get below in the image

Re: Problem passing Base64 Encoded Image to Tesseract

Posted: Thu Nov 19, 2020 12:13 am
by ecann
I tried another regular expression on the script but it is still not working

Code: Select all

 do  "Tesseract.recognize("  & quote & "/^data:image\/png;base64,/" &   gImageVariable  & quote  & ",'eng',{ logger: m => console.log(m)}).then(({ data:{ text }}) => { document.write(text)});" in widget "Browser"