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