-
Notifications
You must be signed in to change notification settings - Fork 6
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
Primitive text direction feature detector #5
base: master
Are you sure you want to change the base?
Conversation
DEBUG = True | ||
|
||
# Minimum number of detected text lines. | ||
# If numer of lines recognized are below this value - the result is undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
Generally looks nice. Thank you for all your hard work |
Algorithm is pretty straightforward and slow: | ||
|
||
1. increase shread contrast | ||
2. rotate image from -45 to +45 angles and compute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
degrees.
|
||
for i, value in enumerate(values): | ||
|
||
if value > MAGIC_SECTIONS_THRESHOLD: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You only include into histograms for pixel[0]<MAGIC_COLOR_THRESHOLD (10) values 255-pixel[0]. So the minimum value in histogram would be 245, where it's not 0. I suggest replacing this check with "if value != 0:" or just "if value:" to make the code easier to follow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that is pretty dirty. Planned to remove that code and add image binarization in the beginning...
Guys, take a look into the latest version. :-) |
# If number of lines recognized are below this value - the result is undefined | ||
MIN_LINES_FOR_RESULT = 3 | ||
|
||
# Magic values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous request still holds: please describe what is each of these "magic" values
By the way, in case of just a single line of text, your approach seems to mistake letters for separate lines, i.e. the answer is wrong by 90º. |
Guys, I've fixed code accoring your comments. |
|
||
# All pixels above this value (after converting to grayscale mode) | ||
# will be discarded (i.e. equal 255) | ||
MAGIC_COLOR_THRESHOLD = 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove MAGIC_ from here and other constants.
v.1.1 of text direction feature detector :)