Support optionally using leptonica to deskew
unpaper doesn't seem to be good at deskewing. It fails on test case with a lot of italics. I think it also struggles on pages with a lot of whitespace. Leptonica continues to shine here. However, this is only a first crack at Leptonica. The leptonica module should be redone to use cffi (more extensible). Also considering the possibility of making all Lept calls in a forked process to insulate the calling process from C code crashes and the messy redirect of stdout/stderr to read Leptonica's errors. I don't think the redirect is a huge problem as long as multiprocesses rather than multithreads are used. The ruffus child process that is handling a page is single threaded and will not be affected by the redirection. It just feels dirty. The main reason to consider a child process is crash isolation.
This commit is contained in:
+8
-1
@@ -185,6 +185,9 @@ advanced.add_argument(
|
||||
'--tesseract-timeout', default=180.0, type=float, metavar='SECONDS',
|
||||
help='give up on OCR after the timeout, but copy the preprocessed page '
|
||||
'into the final output')
|
||||
advanced.add_argument(
|
||||
'--deskewer', choices=['leptonica', 'unpaper'], default='leptonica',
|
||||
help='choose deskew provider')
|
||||
|
||||
debugging = parser.add_argument_group(
|
||||
"Debugging",
|
||||
@@ -493,7 +496,11 @@ def preprocess_deskew(
|
||||
pageinfo = get_pageinfo(input_file, pdfinfo, pdfinfo_lock)
|
||||
dpi = int(pageinfo['xres'])
|
||||
|
||||
unpaper.deskew(input_file, output_file, dpi, log)
|
||||
if options.deskewer == 'unpaper':
|
||||
unpaper.deskew(input_file, output_file, dpi, log)
|
||||
else:
|
||||
from . import leptonica
|
||||
leptonica.deskew(input_file, output_file, dpi)
|
||||
|
||||
|
||||
@transform(
|
||||
|
||||
Reference in New Issue
Block a user