Try to guess bold and italic properties for unknown glyphs (from the previous glyph).
This commit is contained in:
parent
4dff247313
commit
1c6509efad
2 changed files with 7 additions and 3 deletions
|
|
@ -36,7 +36,7 @@ from ..glyphdb import GlyphDB, SPACE, NEWLINE
|
|||
|
||||
class OCREngine(QThread):
|
||||
SPACE_WIDTH = 15
|
||||
unknownGlyph = signal([Glyph])
|
||||
unknownGlyph = signal([Glyph, bool, bool])
|
||||
pageChanged = signal([Page])
|
||||
|
||||
def __init__(self, dirname, skip=0, limit=None, quit=False, output_format='text'):
|
||||
|
|
@ -47,6 +47,7 @@ class OCREngine(QThread):
|
|||
self.help_queue = Queue()
|
||||
self.quit = quit
|
||||
self.output_format = output_format
|
||||
self.last_style = (False, False, (255, 255, 255)) # FIXME get rid of hardcoded value
|
||||
|
||||
def save_glyphdb(self):
|
||||
self.glyphdb.save()
|
||||
|
|
@ -88,10 +89,11 @@ class OCREngine(QThread):
|
|||
except KeyError:
|
||||
text, bold, italic = self.ask_for_help(glyph)
|
||||
glyph_data = self.glyphdb.add_glyph(glyph, text, bold, italic)
|
||||
self.last_style = glyph_data.style
|
||||
return glyph_data
|
||||
|
||||
def ask_for_help(self, unknown_glyph):
|
||||
self.unknownGlyph.emit(unknown_glyph)
|
||||
self.unknownGlyph.emit(unknown_glyph, self.last_style.bold, self.last_style.italic)
|
||||
return self.receive_help()
|
||||
|
||||
def give_help(self, *args):
|
||||
|
|
|
|||
|
|
@ -103,8 +103,10 @@ class MainWindow(QMainWindow):
|
|||
self.restoreGeometry(settings.value("windowGeometry") or b'')
|
||||
self.restoreState(settings.value("windowState") or b'')
|
||||
|
||||
def unknownGlyph(self, glyph):
|
||||
def unknownGlyph(self, glyph, bold, italic):
|
||||
self.pageScene.highlightGlyph(glyph)
|
||||
self.glyphEdit.bold.setChecked(bold)
|
||||
self.glyphEdit.italic.setChecked(italic)
|
||||
self.glyphEdit.setEnabled(True)
|
||||
self.glyphEdit.text.clear()
|
||||
self.glyphEdit.text.setFocus()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue