def scan_single_page(self, scan_src, resolution, ocrlang, scanner_calibration, callback=dummy_progress_cb): """ Scan a new page and append it as the last page of the document Arguments: scan_src --- see pyinsane.abstract_th.Scanner ocrlang --- Language to specify to the OCR tool callback -- Progression indication callback (see util.dummy_progress_cb for the arguments to expected) """ callback(0, 100, ScannedPage.SCAN_STEP_SCAN) nb_pages = scan_src.get_nb_img() try: while True: scan_src.read() time.sleep(0) except EOFError: pass img = scan_src.get_img(nb_pages) try: os.makedirs(self.path) except OSError: pass page_nb = self.nb_pages page = ScannedPage(self, page_nb) page.make(img, ocrlang, resolution, scanner_calibration, callback)
def redo_ocr(self, ocrlang, callback=dummy_progress_cb): """ Run the OCR again on all the pages of the document Arguments """ nb_pages = self.nb_pages for i in range(0, nb_pages): callback(i, nb_pages, ScannedPage.SCAN_STEP_OCR, self) page = ScannedPage(self, i) page.redo_ocr(ocrlang)
def print_page_cb(self, print_op, print_context, page_nb): """ Called for printing operation by Gtk """ page = ScannedPage(self, page_nb) page.print_page_cb(print_op, print_context)