Converts im to file, applies tesseract, and fetches resulting text. If cleanup=True, delete scratch files after operation.
(im, cleanup = cleanup_scratch_flag, bool_digits=False)
| 26 | errors.check_for_errors() |
| 27 | |
| 28 | def image_to_string(im, cleanup = cleanup_scratch_flag, bool_digits=False): |
| 29 | """Converts im to file, applies tesseract, and fetches resulting text. |
| 30 | If cleanup=True, delete scratch files after operation.""" |
| 31 | try: |
| 32 | util.image_to_scratch(im, scratch_image_name) |
| 33 | call_tesseract(scratch_image_name, scratch_text_name_root, bool_digits) |
| 34 | text = util.retrieve_text(scratch_text_name_root) |
| 35 | finally: |
| 36 | if cleanup: |
| 37 | util.perform_cleanup(scratch_image_name, scratch_text_name_root) |
| 38 | return text |
| 39 | |
| 40 | def image_file_to_string(filename, cleanup = cleanup_scratch_flag, graceful_errors=True, bool_digits=False): |
| 41 | """Applies tesseract to filename; or, if image is incompatible and graceful_errors=True, |
no test coverage detected