def run(self): """Wait indefinitely for the first anno added to the queue. Then wait at least _delay_, then process the rest of the queued annotations.""" delay = 0.5 # seconds while True: updateSet = set([]) annotation = self.annoQueue.get(True) self.annoQueue.task_done() updateSet.add(annotation) time.sleep(delay) try: while True: annotation = self.annoQueue.get_nowait() self.annoQueue.task_done() updateSet.add(annotation) except Empty: pass for annotation in updateSet: if len(annotation.Strokes) > 0: mscResponse = recognizeEquation(flipStrokes(annotation.Strokes)) eqnAnno = EquationAnnotation.fromMyScriptResponse(mscResponse) annotation.setEqual(eqnAnno) with self.board.Lock: self.board.UpdateAnnotation(annotation, annotation.Strokes)
def printBoardStrokes(board): flippedStrokes = flipStrokes(board.Strokes) equation = recognizeEquation(flippedStrokes) print "Equation: '%s'" % (equation) handwriting = recognizeHandwriting(flippedStrokes) print "Handwriting: %s" % (handwriting)