-
Notifications
You must be signed in to change notification settings - Fork 37
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
Comments
Hi @nikkelj. Thank you so much for your contributions. Cheers |
Certainly, will do so tonight. -Jon On Tue, Oct 29, 2013 at 5:00 AM, Balthazar Rouberol <
Jonathan Nikkel |
@nikkelj Ping! :-) Sounds like this might actually be multiple pull requests, but sounds like 3 is the critical one for 3.02 support. |
Sorry, forgot about this for a while, pull request is up now |
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:
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)
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))
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.
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.
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.
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
The text was updated successfully, but these errors were encountered: