示例#1
0
 def addImages(self, image_path_list):
     item_list = []
     temp_dir = self.configuration_manager.TEMPORARY_FOLDER
     image_path_list = graphics.convertMultiImagesInList(image_path_list,
                                                         temp_dir)
     item_list_length = len(image_path_list)
     if not self.configuration_manager.deskew_images_after_addition and \
        not self.configuration_manager.unpaper_images_after_addition:
         for index in range(0, len(image_path_list)):
             if not self.__addImage(image_path_list[index], index == 0):
                 debug('Failed to load image "%s"' % image_path_list[index])
         return
     dialog = QueuedEventsProgressDialog(self.main_window)
     for index in range(0, item_list_length):
         image_path = image_path_list[index]
         item = AsyncItem(self.__imagePreProcessing,
                          (image_path,),
                          self.__imagePreProcessingFinishedCb,
                          (dialog,
                           index == item_list_length - 1,
                           index == 0))
         if item_list_length == 1:
             item_info = (_('Preparing image'), _(u'Please wait…'))
         else:
             item_info = (_('Preparing image %(current_index)s/%(total)s') % \
                          {'current_index': index + 1,
                           'total': item_list_length},
                          _(u'Please wait…'))
         item_list.append((item_info,item))
     dialog.setItemsList(item_list)
     dialog.run()
示例#2
0
 def deskewCurrentImage(self, widget):
     reviewer = self.__getCurrentReviewer()
     dialog = QueuedEventsProgressDialog(self.main_window)
     item = AsyncItem(self.__deskewImage,
                      (reviewer.path_to_image,),
                      self.__deskewCurrentImageFinishedCb,
                      (dialog, reviewer))
     item_info = (_('Deskewing image'), _(u'Please wait…'))
     dialog.setItemsList([(item_info, item)])
     dialog.run()
示例#3
0
 def recognizeCurrentPage(self):
     image_reviewer = self.__getCurrentReviewer()
     if image_reviewer.selectable_boxes_area.getAllAreas() and \
        self.__confirmOveritePossibilityByRecognition() != gtk.RESPONSE_YES:
             return
     page = image_reviewer.page
     dialog = QueuedEventsProgressDialog(self.main_window.window)
     item = AsyncItem(self.__performRecognitionForPage,
                      (page,),
                      self.__performRecognitionForPageFinishedCb,
                      (dialog, page, [page]))
     info = (_('Recognizing Page'), _(u'Please wait…'))
     dialog.setItemsList([(info, item)])
     dialog.run()
示例#4
0
 def recognizeDocument(self):
     pages = self.source_images_selector_widget.getAllPages()
     dialog = QueuedEventsProgressDialog(self.main_window.window)
     items = []
     i = 1
     total = len(pages)
     has_changes = False
     for page in pages:
         has_changes = has_changes or bool(page.data_boxes)
         item = AsyncItem(self.__performRecognitionForPage, (page, ),
                          self.__performRecognitionForPageFinishedCb,
                          (dialog, page, pages))
         info = (
             _('Recognizing Document'),
             _(u'Recognizing page %(page_number)s/%(total_pages)s. Please wait…'
               ) % {
                   'page_number': i,
                   'total_pages': total
               })
         items.append((info, item))
         i += 1
     if has_changes and \
        self.__confirmOveritePossibilityByRecognition() != gtk.RESPONSE_YES:
         return
     dialog.setItemsList(items)
     dialog.run()
示例#5
0
 def addImages(self, image_path_list):
     item_list = []
     item_list_length = len(image_path_list)
     if not self.configuration_manager.deskew_images_after_addition and \
        not self.configuration_manager.unpaper_images_after_addition:
         for index in range(0, len(image_path_list)):
             if not self.__addImage(image_path_list[index], index == 0):
                 debug('Failed to load image "%s"' % image_path_list[index])
         return
     dialog = QueuedEventsProgressDialog(self.main_window.window)
     for index in range(0, item_list_length):
         image_path = image_path_list[index]
         item = AsyncItem(
             self.__imagePreProcessing, (image_path, ),
             self.__imagePreProcessingFinishedCb,
             (dialog, index == item_list_length - 1, index == 0))
         if item_list_length == 1:
             item_info = (_('Preparing image'), _(u'Please wait…'))
         else:
             item_info = (_('Preparing image %(current_index)s/%(total)s') % \
                          {'current_index': index + 1,
                           'total': item_list_length},
                          _(u'Please wait…'))
         item_list.append((item_info, item))
     dialog.setItemsList(item_list)
     dialog.run()
示例#6
0
 def recognizeDocument(self):
     pages = self.pages_icon_view.getAllPages()
     dialog = QueuedEventsProgressDialog(self.main_window)
     items = []
     i = 1
     total = len(pages)
     has_changes = False
     for page in pages:
         has_changes = has_changes or bool(page.data_boxes)
         item = AsyncItem(self.__performRecognitionForPage,
                          (page,),
                          self.__performRecognitionForPageFinishedCb,
                          (dialog, page, pages))
         info = (_('Recognizing Document'),
                 _(u'Recognizing page %(page_number)s/%(total_pages)s. Please wait…') % {'page_number': i,
                                                                                         'total_pages': total})
         items.append((info, item))
         i += 1
     if has_changes and \
        self.__confirmOveritePossibilityByRecognition() != Gtk.ResponseType.YES:
             return
     dialog.setItemsList(items)
     dialog.run()
示例#7
0
 def deskewCurrentImage(self, widget):
     reviewer = self.__getCurrentReviewer()
     dialog = QueuedEventsProgressDialog(self.main_window.window)
     item = AsyncItem(self.__deskewImage, (reviewer.path_to_image, ),
                      self.__deskewCurrentImageFinishedCb,
                      (dialog, reviewer))
     item_info = (_('Deskewing image'), _(u'Please wait…'))
     dialog.setItemsList([(item_info, item)])
     dialog.run()
示例#8
0
 def recognizeCurrentPage(self):
     image_reviewer = self.__getCurrentReviewer()
     if image_reviewer.selectable_boxes_area.getAllAreas() and \
        self.__confirmOveritePossibilityByRecognition() != gtk.RESPONSE_YES:
         return
     page = image_reviewer.page
     dialog = QueuedEventsProgressDialog(self.main_window.window)
     item = AsyncItem(self.__performRecognitionForPage, (page, ),
                      self.__performRecognitionForPageFinishedCb,
                      (dialog, page, [page]))
     info = (_('Recognizing Page'), _(u'Please wait…'))
     dialog.setItemsList([(info, item)])
     dialog.run()
示例#9
0
    def addImages(self, image_path_list):
        paths = []
        for path in image_path_list:
            if os.path.exists(path):
                paths.append(path)
            else:
                warning('Could not load image "%s": does not exist' % path)

        if not paths:
            return

        image_path_list = paths
        item_list = []
        temp_dir = self.configuration_manager.TEMPORARY_FOLDER
        image_path_list = graphics.convertMultiImagesInList(image_path_list,
                                                            temp_dir)
        item_list_length = len(image_path_list)
        if not self.configuration_manager.deskew_images_after_addition and \
           not self.configuration_manager.unpaper_images_after_addition:
            for index in range(0, len(image_path_list)):
                if not self.__addImage(image_path_list[index], index == 0):
                    debug('Failed to load image "%s"' % image_path_list[index])
            return
        dialog = QueuedEventsProgressDialog(self.main_window)
        for index in range(0, item_list_length):
            image_path = image_path_list[index]
            item = AsyncItem(self.__imagePreProcessing,
                             (image_path,),
                             self.__imagePreProcessingFinishedCb,
                             (dialog,
                              index == item_list_length - 1,
                              index == 0))
            if item_list_length == 1:
                item_info = (_('Preparing image'), _(u'Please wait…'))
            else:
                item_info = (_('Preparing image %(current_index)s/%(total)s') % \
                             {'current_index': index + 1,
                              'total': item_list_length},
                             _(u'Please wait…'))
            item_list.append((item_info,item))
        dialog.setItemsList(item_list)
        dialog.run()