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

Y-coordinates Swapped in Generated Box File, Other Minor Issues #9

Open
nikkelj opened this issue Oct 29, 2013 · 4 comments
Open

Y-coordinates Swapped in Generated Box File, Other Minor Issues #9

nikkelj opened this issue Oct 29, 2013 · 4 comments

Comments

@nikkelj
Copy link
Contributor

nikkelj commented Oct 29, 2013

Hi again,

So I seem to have solved my issues now (again, kudos for building a nice system). In order to get this working in my configuration/fonts, I had to do the following in multipage_tif:

  1. subprocess.call was for some reason causing errors in running ImageMagick convert, so I switched the code to use os.system(cmd) instead (single string, not string array)

  2. I changed _save_tif() to save as a 300DPI tif. This may be unnecessary in many cases, but most FAQ's/postings I see recomment at least this.
    tif.save(self.indiv_page_prefix + str(page_number) + '.tif',dpi=(300,300))

  3. Most important: I do not know if it is something specific to my configuration that is causing this (I am using Tesseract 3.02, Python 2.7.5), but I had to swap char_y1 and char_y0 in the call to self._write_boxline inside _fill_pages() to get this to work. The y-coordinates were swapped opposite the defined convention otherwise.

  4. The code in _fill_pages() also ignores cases where fonts have a baseline offset. To remedy this, I collected the offsets from the font definition using:
    offset= self.font.getoffset(char)

and then adjusted char_x0/x1 and char_y0/y1 by offset[0] and offset[1] respectively.

  1. Depending on the metrics of the font chosen, you may also need to bias the newline y_position so that the lines do not overlap, and adjust the character-to-character spacings (adjust x_pos and y_pos to taste). May want to specify these as inputs or config file items so that folks know they may need to adjust them.

  2. I am finding that font.getsize(char) does not always return accurate boundaries from given font files, particularly for some punctuation. So, I am adding a custom offset hash to manually offset specific characters in a given font.

Hope that helps,

-Jon

@brouberol
Copy link
Contributor

Hi @nikkelj.

Thank you so much for your contributions.
Would you mind sending a proper pull request, so that I could integrate them into the master branch.
By doing that, you would basically enable 3.02 support :)

Cheers

@nikkelj
Copy link
Contributor Author

nikkelj commented Oct 29, 2013

Certainly, will do so tonight.

-Jon

On Tue, Oct 29, 2013 at 5:00 AM, Balthazar Rouberol <
[email protected]> wrote:

Hi @nikkelj https://github.com/nikkelj.

Thank you so much for your contributions.
Would you mind sending a proper pull request, so that I could integrate
them into the master branch.
By doing that, you would basically enable 3.02 support :)

Cheers


Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-27293712
.

Jonathan Nikkel
Mobile: 970-310-8710
Email: [email protected]

@tfmorris
Copy link

tfmorris commented Dec 9, 2013

@nikkelj Ping! :-)

Sounds like this might actually be multiple pull requests, but sounds like 3 is the critical one for 3.02 support.

@nikkelj
Copy link
Contributor Author

nikkelj commented Dec 12, 2013

Sorry, forgot about this for a while, pull request is up now

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

3 participants