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

setImage is re-run unnecessarily when rotateAuto is enabled #892

Closed
Balearica opened this issue Feb 23, 2024 · 0 comments · Fixed by #895
Closed

setImage is re-run unnecessarily when rotateAuto is enabled #892

Balearica opened this issue Feb 23, 2024 · 0 comments · Fixed by #895

Comments

@Balearica
Copy link
Member

Detecting page angle currently requires that automatic page segmentation is enabled. Therefore, if rotateAuto is set to true but the current PSM does not support detecting the page angle, page segmentation is run with PSM set to 3 (AUTO), the page angle is retrieved, and then page segmentation is run a second time with PSM set to whatever is requested by the user.

If PSM is set to 3 by the user already, then page segmentation should only be run once (if no rotation is detected). However, due to a bug in the implementation of this feature, page segmentation is currently being run twice, even in this case.

https://github.com/naptha/tesseract.js/blob/master/src/worker-script/index.js#L402-L407

Specifically, this code does not account for the fact that the PSM object stores the PSM values as strings, but api.GetPageSegMode returns an integer. Therefore, the check that occurs is ['3'].includes(3) which resolves to false.

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

Successfully merging a pull request may close this issue.

1 participant