Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browser example does not work #54

Open
under-score opened this issue Aug 19, 2021 · 5 comments
Open

browser example does not work #54

under-score opened this issue Aug 19, 2021 · 5 comments

Comments

@under-score
Copy link

interesting project as I need the x,y location of the textareas but unfortunately I get

    Uncaught TypeError: Cannot read property '5' of null
    at parseOcradResultsFile (ocrad.js:96142)
    at postprocess (ocrad.js:96223)
    at OCRAD (ocrad.js:96242)
    at OCRImage (location.html:20)
    at HTMLImageElement.onload (location.html:43)
@Fonsori
Copy link

Fonsori commented Oct 17, 2021

Have you managed to find a solution to that? That error only shows when setting the "verbose" flag to true right?
Looks like setting {raw: true} works the same but returns pure text with no object access to .letters and the like.

Actually I may of found a working edit to ocrad.js, a one line insert that stops a for loop. Must test it further though

@under-score
Copy link
Author

sorry, don't know the answer

@rajivraman
Copy link

I also came across the same issue. Any luck with a solution?

@rajivraman
Copy link

For anyone that runs across the problem, the issue is that the out.txt file generated by verbose mode is missing the tail end of its content. So parseOcradResultsFile() fails while processing it. The trick is to ensure that the underlying filesystem flushes all file streams before attempting to read out.txt. The easiest way I've found to do this is to first expose the flushing method to the API:

API.delete_file            = function(filename){ return FS.unlink(filename) };
API.quitFS                 = function() { return FS.quit() }; // NEW

Then call it from this block of code in _simple():

if(opt.raw){
    API.quitFS(); // NEW
    ret = API.read_text('/out.txt');
    API.delete_file('/out.txt');

@sdkfz181tiger
Copy link

Wow!!
It works very well!!
Thank you sooooo much!!
I added 2 lines berow!!
96057: API.quitFS(); // NEW
96084: API.quitFS = function() { return FS.quit() }; // NEW

horihiro added a commit to horihiro/ocrad.js that referenced this issue Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants