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

Big text not recognised #871

Closed
IonicaBizau opened this issue Jan 12, 2024 · 3 comments
Closed

Big text not recognised #871

IonicaBizau opened this issue Jan 12, 2024 · 3 comments

Comments

@IonicaBizau
Copy link

IonicaBizau commented Jan 12, 2024

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

Describe the bug
I have this image taken by DroidCam which I would like to analyze, but the big text is not identified correctly.

image

To Reproduce
I uploaded the original image here.

Expected behavior
I would expect to identify the time and then the small text (amount of kW).

Additional context
I tried using rectangle to exclude the top side, but that didn't make a difference.

const { createWorker } = require("tesseract.js");

const FRAME_URL = "frame.jpg";

(async () => {
  const worker = await createWorker('eng');
  const ret = await worker.recognize(FRAME_URL, {
      rectangle: {
          top: 11,
          left: 102,
          width: 481,
          height: 352
      },
  });
  console.log(ret.data.text);
  await worker.terminate();
})();

Original frame.jpg

frame

@Balearica
Copy link
Collaborator

The fact that the boxes, which are supposed to be drawn around lines/words, have no relation to the word in your image indicates the issue is with the image processing step rather than recognition. This can be confirmed by running the image processing example, which is linked here.

Below is the processed, binary image, which is what recognition is actually run on.
download (22)

Your instinct that this can be resolved by cropping the image appears to be correct--cropping to only include the text results in the time 11:39 being properly identified. It is easy to see why when looking at the binarized image, which is below.

display_image_crop1
download (26)

The reason why setting rectangle did not produce these results is because this argument does not impact image processing. That argument merely tells Tesseract to only run recognition on a specific region. Therefore, to fix issues with image processing by cropping, you would need to crop the image prior to passing it to Tesseract.js.

@IonicaBizau
Copy link
Author

Thank you very much! I used sharp to modify the image before passing it to tesseract and I got better results. Thanks for this amazing library!

@IonicaBizau
Copy link
Author

@Balearica I am wondering why such an image (attached below) cannot be processed... There is no text at all coming in the response. Do you have any ideas?

current-power

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