Rename OCREngine to Document and move it to pixelocr.document.
This commit is contained in:
parent
4e35d56696
commit
f771722d0b
3 changed files with 20 additions and 20 deletions
|
|
@ -18,13 +18,13 @@ import itertools
|
|||
from glob import glob
|
||||
from os import path
|
||||
|
||||
from .. import formatting
|
||||
from ..image import Image
|
||||
from ..page import Page, Space
|
||||
from ..glyphdb import GlyphDB, SPACE, NEWLINE
|
||||
from . import formatting
|
||||
from .image import Image
|
||||
from .page import Page, Space
|
||||
from .glyphdb import GlyphDB, SPACE, NEWLINE
|
||||
|
||||
|
||||
class OCREngine(object):
|
||||
class Document(object):
|
||||
SPACE_WIDTH = 15
|
||||
|
||||
def __init__(self, dirname, ui, skip=0, limit=None, output_format='text'):
|
||||
|
|
@ -37,9 +37,9 @@ from PyQt4.QtGui import (
|
|||
QApplication,
|
||||
)
|
||||
|
||||
from ..document import Document
|
||||
from .guiproxy import GUIProxy
|
||||
from .window import MainWindow
|
||||
from .ocrengine import OCREngine
|
||||
|
||||
|
||||
parser = ArgumentParser(description='PixelOCR')
|
||||
|
|
@ -58,13 +58,13 @@ def load_entry_point(group, name):
|
|||
|
||||
|
||||
class WorkerThread(QThread):
|
||||
def __init__(self, ocr, quit=False):
|
||||
def __init__(self, document, quit=False):
|
||||
super().__init__()
|
||||
self.ocr = ocr
|
||||
self.document = document
|
||||
self.quit = quit
|
||||
|
||||
def run(self):
|
||||
self.ocr.recognize()
|
||||
self.document.recognize()
|
||||
if self.quit:
|
||||
qApp.quit()
|
||||
|
||||
|
|
@ -77,20 +77,20 @@ def main():
|
|||
|
||||
args = parser.parse_args()
|
||||
gui_proxy = GUIProxy()
|
||||
ocr = OCREngine(
|
||||
document = Document(
|
||||
args.filename,
|
||||
ui=gui_proxy,
|
||||
skip=args.skip,
|
||||
limit=args.limit,
|
||||
output_format=load_entry_point('pixelocr.formatting', args.output_format).load()(),
|
||||
)
|
||||
app.aboutToQuit.connect(ocr.save_glyphdb)
|
||||
ocr_thread = WorkerThread(ocr, quit=args.quit)
|
||||
app.aboutToQuit.connect(document.save_glyphdb)
|
||||
worker_thread = WorkerThread(document, quit=args.quit)
|
||||
|
||||
win = MainWindow(ocr)
|
||||
win = MainWindow(document)
|
||||
win.glyphEntered.connect(gui_proxy.give_help)
|
||||
win.show()
|
||||
ocr_thread.start()
|
||||
worker_thread.start()
|
||||
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
sys.exit(app.exec_())
|
||||
|
|
|
|||
|
|
@ -42,11 +42,11 @@ class MainWindow(QMainWindow):
|
|||
dbedit = None
|
||||
glyphEntered = signal([str, bool, bool])
|
||||
|
||||
def __init__(self, ocr):
|
||||
def __init__(self, document):
|
||||
super().__init__()
|
||||
self.setDocumentTitle(None)
|
||||
|
||||
self.ocr = ocr
|
||||
self.document = document
|
||||
|
||||
centralWidget = QWidget(self)
|
||||
self.setCentralWidget(centralWidget)
|
||||
|
|
@ -54,14 +54,14 @@ class MainWindow(QMainWindow):
|
|||
self.page = PageView(self.pageScene, centralWidget)
|
||||
self.glyphEdit = GlyphEdit(centralWidget)
|
||||
self.glyphEdit.setEnabled(False)
|
||||
self.glyphDBEdit = GlyphDBEdit(self.ocr.glyphdb)
|
||||
self.glyphDBEdit = GlyphDBEdit(self.document.glyphdb)
|
||||
|
||||
self.glyphEdit.glyphEntered.connect(self.unknownGlyphEntered)
|
||||
self.glyphEdit.glyphEntered.connect(self.pageScene.clearHighlight)
|
||||
self.glyphEdit.glyphEntered.connect(self.glyphDBEdit.updateData)
|
||||
ocr.ui.pageChanged.connect(self.pageScene.setPage)
|
||||
ocr.ui.pageChanged.connect(self.showPageTitle)
|
||||
ocr.ui.unknownGlyph.connect(self.unknownGlyph)
|
||||
document.ui.pageChanged.connect(self.pageScene.setPage)
|
||||
document.ui.pageChanged.connect(self.showPageTitle)
|
||||
document.ui.unknownGlyph.connect(self.unknownGlyph)
|
||||
self.page.setFocusProxy(self.glyphEdit)
|
||||
|
||||
layout = QVBoxLayout(centralWidget)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue