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

Rectangles not working, pure white image interpreted as tildes #936

Closed
markschwartzkopf opened this issue Jul 21, 2024 · 3 comments
Closed

Comments

@markschwartzkopf
Copy link

Tesseract.js version (version number for npm/GitHub release, or specific commit for repo)
5.1.0

Describe the bug
I have processed an image to monochromatic black and white with no noise. I then tell tesseract.js to OCR the top half. Tesseract.js OCRs the bottom half, and interprets blocks of pure white as tildes

To Reproduce
Steps to reproduce the behavior:
(async () => {
const worker = await createWorker('eng', 1, {
/* logger: (m) => nodecg.log.info(m) */
});
worker
.recognize(__dirname + '/OBS.png', { rectangle: { top: 0, left: 0, width: 350, height: 39 } })
.then((result) => {
fs.writeFileSync(__dirname + '/ocr.json', JSON.stringify(result));
console.log(result.data.text);
console.log('Confidence: ' + result.data.confidence);
});
})();

Please attach any input image required to replicate this behavior.

Expected behavior
I expect this run on the attached image to result in "WWWWWWWWWW", or at least "Mark", not "~~ Mark"
Hopefully I'm doing something wrong and this is not actually a bug?

Device Version:

  • Windows 10
  • Node 18.19.0

Additional context
Add any other
OBS
context about the problem here.

@markschwartzkopf
Copy link
Author

markschwartzkopf commented Jul 21, 2024

ocr.json

From the block coordinates in this .json, it appears that the tildes it is finding are in the pure white space to the left of "Mark"

@Balearica
Copy link
Member

@markschwartzkopf I believe this is a quirk inherited from the main Tesseract program--you need to subtract 1 from the image width when specifying the rectangle. In this case, if you set width to 349 rather than 350 your image is recognized correctly.

WWWWWWWWWW

@Balearica
Copy link
Member

Closing as resolved.

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

2 participants