def test_imgage_processor():
    '''Test image processor (multiple tests)'''

    expected_board = BlindBoard.get_starting_board()
    expected_board.remove_piece_at(chess.E2)
    expected_board.set_piece_at(chess.E4, Piece(PAWN, WHITE))

    # retrieve all the images paths and sort
    images = collect_test_images('tests/pictures/game000')
    debug("Calibrating image processor...")
    processor = ImageProcessor(images[0], images[1])

    for img, expected_board in zip(images[2:], expected_boards()):
        debug("Processing `{}`...".format(os.path.basename(img)))
        processor.process(img)
        board = processor.get_blindboard()
        yield compare_blindboards, expected_board, board, img
Example #2
0
    def _calibration(self):
        # TODO: this is messy - we need to handle calibration failure!
        empty_img = os.path.join(self.game_folder, 'empty.jpg')
        start_img = self._get_img_name()

        print("Prepare the empty chessboard and press Enter")
        input()
        self.capture_engine.capture(empty_img)
        print("Prepare the chessboard in starting position " "and press Enter")
        input()
        self.capture_engine.capture(start_img)

        if self.do_live_analysis:
            log.info("Calibrating image processor...")
            self.image_processor = ImageProcessor(empty_img,
                                                  start_img,
                                                  trace=True)
            log.info("Calibration completed")
        else:
            log.info('Delaying image processor calibration')