{"action":"created","issue":{"url":"https://api.github.com/repos/jflesch/pyocr/issues/47","repository_url":"https://api.github.com/repos/jflesch/pyocr","labels_url":"https://api.github.com/repos/jflesch/pyocr/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/jflesch/pyocr/issues/47/comments","events_url":"https://api.github.com/repos/jflesch/pyocr/issues/47/events","html_url":"https://github.com/jflesch/pyocr/issues/47","id":189432920,"number":47,"title":"Tesseract C API : Digits-only (DigitBuilder)","user":{"login":"bennguvaye","id":7387195,"avatar_url":"https://avatars.githubusercontent.com/u/7387195?v=3","gravatar_id":"","url":"https://api.github.com/users/bennguvaye","html_url":"https://github.com/bennguvaye","followers_url":"https://api.github.com/users/bennguvaye/followers","following_url":"https://api.github.com/users/bennguvaye/following{/other_user}","gists_url":"https://api.github.com/users/bennguvaye/gists{/gist_id}","starred_url":"https://api.github.com/users/bennguvaye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bennguvaye/subscriptions","organizations_url":"https://api.github.com/users/bennguvaye/orgs","repos_url":"https://api.github.com/users/bennguvaye/repos","events_url":"https://api.github.com/users/bennguvaye/events{/privacy}","received_events_url":"https://api.github.com/users/bennguvaye/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-15T16:05:09Z","updated_at":"2016-11-16T14:32:52Z","closed_at":null,"body":"Hello,\r\nI'd like to use tesseract with a numerical input, but as it is this is only possible with the [tesseract command line tool](https://github.com/jflesch/pyocr/blob/master/src/pyocr/tesseract.py) and its `DigitBuilder`, since f36f249217a9f28b3a67824a9e35ff9f0cbe59be\r\n\r\nHowever, this looks easy enough to implement with the C API too, with a new function in [libtesseract/tesseract_raw.py](https://github.com/jflesch/pyocr/blob/master/src/pyocr/libtesseract/tesseract_raw.py) :\r\n```python\r\ndef set_numeric_only(handle) :\r\n    global g_libtesseract\r\n    assert(g_libtesseract)\r\n\r\n    g_libtesseract.TessBaseAPISetVariable(\r\n        ctypes.c_void_p(handle),\r\n        b\"classify_bln_numeric_mode\",\r\n        b\"1\"\r\n    )\r\n```\r\n\r\nThe most conservative way would be to use it in a new builder subclass in [libtesseract/_\\_init__.py](https://github.com/jflesch/pyocr/blob/master/src/pyocr/libtesseract/__init__.py) , in the same was as for [tesseract.py](https://github.com/jflesch/pyocr/blob/master/src/pyocr/tesseract.py).\r\n\r\nBut I think it might be better to move this to `image_to_string` both in \r\n[libtesseract/_\\_init__.py](https://github.com/jflesch/pyocr/blob/master/src/pyocr/libtesseract/__init__.py) and [tesseract.py](https://github.com/jflesch/pyocr/blob/master/src/pyocr/tesseract.py), with a new option, like it's done for choosing the language, since from what I understand builders should be more for choosing the format of the output.\r\n\r\nI am not too familiar with github, ctypes, or pyocr, so sorry if I'm misunderstanding the code or doing something wrong.\r\n\r\nThank you for your work on this package,\r\nRegards\r\n\r\nPS : It looks like the C API also offers possibilities for getting confidence scores for words, which might be interesting to get to a Builder."},"comment":{"url":"https://api.github.com/repos/jflesch/pyocr/issues/comments/260961637","html_url":"https://github.com/jflesch/pyocr/issues/47#issuecomment-260961637","issue_url":"https://api.github.com/repos/jflesch/pyocr/issues/47","id":260961637,"user":{"login":"bennguvaye","id":7387195,"avatar_url":"https://avatars.githubusercontent.com/u/7387195?v=3","gravatar_id":"","url":"https://api.github.com/users/bennguvaye","html_url":"https://github.com/bennguvaye","followers_url":"https://api.github.com/users/bennguvaye/followers","following_url":"https://api.github.com/users/bennguvaye/following{/other_user}","gists_url":"https://api.github.com/users/bennguvaye/gists{/gist_id}","starred_url":"https://api.github.com/users/bennguvaye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bennguvaye/subscriptions","organizations_url":"https://api.github.com/users/bennguvaye/orgs","repos_url":"https://api.github.com/users/bennguvaye/repos","events_url":"https://api.github.com/users/bennguvaye/events{/privacy}","received_events_url":"https://api.github.com/users/bennguvaye/received_events","type":"User","site_admin":false},"created_at":"2016-11-16T14:32:51Z","updated_at":"2016-11-16T14:32:51Z","body":"Hi,\r\n\r\nOk I'm giving it a shot. Since the `DigitBuilder` in tesseract.py is a subclass of `TextBuilder` but I need a `LineBoxBuilder` behaviour, this would mean several builders for consistency.\r\n\r\nDo you think it makes sense to instead put in a `num_mode` option for all builders\r\nin `__init__` which is then handled in `image_to_string` and raises a `NotImplementedError` if the tool (Cuneiform) can't handle it ?\r\n\r\nAlso I'm on debian stable (jessie) and the last libtesseract version is 3.03,\r\nwith no backport for 3.04. I have seen no problem with it but pyocr doesn't like it. So I'm making 3.03 valid and you'll revert the change if you think it's unneeded.\r\n\r\nCheers"}}
{"actor":{"display_login":"bennguvaye"}}