Problem passing Base64 Encoded Image to Tesseract

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
ecann
Posts: 312
Joined: Wed Oct 26, 2016 12:26 pm

Problem passing Base64 Encoded Image to Tesseract

Post by ecann » Thu Nov 19, 2020 12:00 am

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
Attachments
errrorMess.PNG

ecann
Posts: 312
Joined: Wed Oct 26, 2016 12:26 pm

Re: Problem passing Base64 Encoded Image to Tesseract

Post by ecann » Thu Nov 19, 2020 12:13 am

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"

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”