def configurerecognizerwithimage(boardsize, filename): recognizer = Recognizer(boardsize) recognizer.setconfig(config['recognizer']) display = Display() display.initdisplay() img = cv2.imread('BoardRecognizer/tests/' + filename + '.png') recognizer.initrefdata('BoardRecognizer/tests/' + filename + '.yml') pieces = recognizer.getboardstate(img) print ''.join(pieces) checkPieces = [] for row in recognizer.refBoard: for tile in row: checkPieces.append(tile) for i in range(32): if pieces[i] == checkPieces[i]: checkPieces[i] = ' ' print 'Recognized:' + ' '.join(pieces) print 'Reference: ' + ' '.join(checkPieces) while True: display.showframe(img) annotateboard(recognizer.board, recognizer.pieceRecognizer.means, pieces) display.showboard(recognizer.board) key = cv2.waitKey(0) if key > 0: break display.enddisplay()
def testrecognizer(boardsize, filename): print("Testing my eyesight") recognizer = Recognizer(boardsize) recognizer.setconfig(config['recognizer']) display = Display() # Load the test movie recognizer.initcapture('BoardRecognizer/tests/' + filename + '.avi') display.initdisplay() while True: frame = recognizer.getframe() print recognizer.getboardstate(frame) display.showframe(frame) recognizer.endcapture() display.enddisplay() config['recognizer'] = recognizer.getconfig()