Difference between revisions of "Raspberry PI Chessboard Camera"

From BITPlan Wiki
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 54: Line 54:
 
* {{Link|target=Raspberry PI WebCam}} for the WebCam installation.
 
* {{Link|target=Raspberry PI WebCam}} for the WebCam installation.
  
= Projects =
+
{{:WebCamBasedChess}}
{{Link|target=CV_Chess}}
 
  
== play-chess-with-a-webcam ==
 
* http://blogdugas.net/blog/2015/05/18/play-chess-with-a-webcam
 
see github fork at
 
* https://github.com/WolfgangFahl/play-chess-with-a-webcam
 
 
Written in python2 migrated to python3.7.
 
see https://unix.stackexchange.com/a/410851/38701 for selection your python version on Ubuntu
 
 
=== Code Structure ===
 
<uml>
 
hide circle
 
package Exceptions <<Rectangle>> {
 
  class ArenaQuit
 
  Exception <|-- ArenaQuit
 
 
  class BadImage
 
  BadImage --|> Exception
 
 
  class BadSegmentation
 
  BadSegmentation --|> Exception
 
 
  class CannotBuildStateException
 
  CannotBuildStateException --|> Exception
 
 
  class RejectedMove
 
  RejectedMove --|> Exception
 
 
  class UserExit
 
  UserExit --|> Exception
 
}
 
 
package PlayChessWithAWebCam {
 
  note top of Args: This class parses command line arguments and generates a usage.
 
  class Args {
 
    __init__(args)
 
  }
 
 
  class BoardFinder {
 
    getDominatorOffset()
 
    updateImage(inFrame)
 
    DetectBoardOrientation()
 
    GetChessBoardCoordinates(rotation)
 
    LineCrossingDetection()
 
    GetFullImageBoard(rectCoordinates=None, rotations=None)
 
    _getBlackMaxSide(colorImage)
 
    rotateImage(image)
 
  }
 
  class Cell {
 
  }
 
  note top of ChessCam: Chess Camera get next move by analyzing movements.
 
class ChessCam {
 
  prepare(args)
 
  __init__()
 
  playChessWithCam(args)
 
  getNextMove()
 
  getDominatorOffset()
 
  detectMovement()
 
  playChessWithCamMoves()
 
}
 
 
 
 
  note top of GameEngine: This class is used to change the game state using StateClass.\nIt also communicates moves with the chess ai facade \\nand an observer to detect if a move have been played by an ai.
 
  class GameEngine {
 
    play()
 
    mainLoop()
 
  }
 
  class InputManager
 
  class MovementDetector
 
  note top of State: This class is used to remember the pieces positions and the current player's color which player needs to play).
 
class State {
 
  _move(fromCell,toCell)
 
  _validateMove(fromCell,toCell)
 
  _sameColor(c1,c2)
 
  _switchTurn()
 
  moveCam(move)
 
  _tryToPromote(c)
 
  _castle(fromCell,toCell)
 
  _eat(fromCell,toCell)
 
  _initBoard()
 
  __init__(dominatorOffset)
 
  _emptyCell(c)
 
  _partMoves(move)
 
}
 
 
  class StateDetector {
 
    _divideInCells()
 
    detectState(colorImage)
 
    _findIntersects()
 
  }
 
 
  note top of Uci: This class interacts with stdin and stdout with Arena in the UCI convention in order to communicate chess moves.
 
  class Uci {
 
    sendMove(move)
 
    getResponse()
 
    _setPosition(tokens)
 
  }
 
 
  class Video {
 
    __init__()
 
    record(prefix,printHints=True)
 
    open(filePath)
 
    drawLines(image,lines)
 
    houghTransform(image)
 
    checkFilePath(filePath,raiseException=True)
 
    sumIntensity(image)
 
    readFrame(show=False)
 
    getSubRect(image,rect)
 
    timeStamp()
 
    play()
 
    setup(cap)
 
    showImage(image,title,keyCheck=True,keyWait=5)
 
    checkCap()
 
    capture(device)
 
    createBlank(width,height,rgb_color)
 
    close()
 
    readImage(filePath)
 
    still(prefix,format="jpg",printHints=True)
 
  }
 
 
}
 
GameEngine -- ChessCam
 
GameEngine -- State
 
GameEngine -- Uci
 
Uci -- ArenaQuit
 
ChessCam -- BoardFinder
 
ChessCam -- MovementDetector
 
ChessCam -- InputManager
 
ChessCam -- UserExit
 
BoardFinder -- Video
 
MovementDetector -- StateDetector
 
MovementDetector -- BadImage
 
StateDetector - Cell
 
note top of State: This class is used to remember the pieces positions and the current player's color which player needs to play.
 
State -- RejectedMove
 
InputManager - Args
 
</uml>
 
 
= UCI compatible GUIs =
 
== XBoard ==
 
<source lang='bash'>
 
sudo apt-get install xboard polyglot stockfish
 
xboard -fUCI -fcp stockfish -sUCI -scp stockfish
 
</source>
 
[[File:XBoard2019-10-19.png|400px]]
 
 
= Open Source Projects =
 
* https://classes.engineering.wustl.edu/ese205/core/index.php?title=CV_Chess
 
* https://github.com/swenae/chesscam
 
* https://github.com/Rr9/ChessStory
 
* https://github.com/FabioBCI/pyChess
 
* http://www.romanmueller.de/chesscamera
 
* https://github.com/TheKrystek/ChessCam
 
* https://gitlab.fing.edu.uy/aricca/chessTrack
 
 
= Commercial =
 
* http://webcamchess.fr/
 
 
= Links =
 
* https://en.wikipedia.org/wiki/Universal_Chess_Interface
 
* https://en.wikipedia.org/wiki/Chess_symbols_in_Unicode
 
* https://buildmedia.readthedocs.org/media/pdf/python-chess/
 
* https://en.chessbase.com/post/how-to-build-your-own-usb-electronic-che-board
 
* https://www.raspberrypi.org/magpi/chess-board-raspberry-pi/
 
* https://codereview.stackexchange.com/questions/220915/python-chess-game
 
* https://hobbylark.com/board-games/Top-5-Free-Chess-GUIs-for-UCI-Engines
 
* https://www.chessprogramming.org
 
* https://www.chessprogramming.org/UCI
 
* https://www.chessprogramming.org/Piece_Recognition
 
* https://stackoverflow.com/questions/27520991/opencv-best-way-to-detect-corners-on-chessboard
 
* https://stackoverflow.com/questions/5906170/detecting-chess-moves-from-successive-image-differences-using-opencv-tools
 
* http://www.nandanbanerjee.com/index.php?option=com_content&view=article&id=71:buttercup-chess-robot&catid=78&Itemid=470
 
* https://chess.stackexchange.com/questions/4695/tools-for-automated-notation-webcam-movie-to-pgn/4751#4751
 
* http://cs.uef.fi/~franti/chesscam/
 
* https://www.fide.com/contacts
 
* https://www.kickstarter.com/projects/infivention/square-off-worlds-smartest-chess-board-relaunched
 
* https://www.heise.de/make/projekte/ChessCamera-Schachcomputer-mit-Bilderkennung-2170835.html
 
* http://usbchessboard.yolasite.com/
 
* https://en.chessbase.com/post/you-built-what-a-giant-robotic-chess-set
 
* https://ieeexplore.ieee.org/abstract/document/6727033
 
* http://wiki.ros.org/tuw_checkerboard
 
* http://js1k.com/2010-first/demo/750
 
 
= Videos =
 
<youtube>jpTSOkZURWk</youtube>
 
<youtube>qbpO1hS_rPE</youtube>
 
<youtube>WYtYjKqd0_w</youtube>
 
<youtube>APkoE1UDKj0</youtube>
 
<youtube>B0iC4IBW2IM</youtube>
 
<youtube>_tnWQCPmdgw</youtube>
 
<youtube>kONz-gURM88</youtube>
 
<youtube>UpU4G4itgOQ</youtube>
 
<youtube>AQLOj-TylGg</youtube>
 
<youtube>RkvNJ3yiIrk</youtube>
 
 
[[Category:Raspberry]]
 
[[Category:Raspberry]]
 
[[Category:Chess]]
 
[[Category:Chess]]

Latest revision as of 07:25, 28 October 2019

Chessboard Move Recorder

see e.g. https://chess.stackexchange.com/questions/4695/tools-for-automated-notation-webcam-movie-to-pgn/26643#26643

Motivation

see MagneticSensorChessBoard1987

Parts List

# picture part example sources documents ~ price
1 Brett-Bundesliga_200x200.jpg Chessboard

Schachversand Ullrich

Wikipedia 25 €
2 Bundesliga57f787924d743_200x200.jpg Chess pieces

Schachversand Ullrich

Wikipedia 25 €
3 Raspberry Pi 3 Model B.png Raspberry PI

Amazon

Wikipedia 45 €
4 LogitechC615.jpeg Web Camera

Amazon

Raspberry PI compatibility list (german) 60 €
5 71KECb7RmVL. SX679 .jpg USB Powerbank

Amazon

15 €
6 613RrJEZYPL. SL1000 .jpg 16 GByte Micro SD Card

Amazon

5 €

Pictures

First Prototype

SAM 9947.JPG SAM 9949.JPG SAM 9951.JPG Chess34563.jpg

Second Prototype

SAM 9955.JPG SAM 9962.JPG

Installation

see

Projects

  1. PlayChessWithAWebCam
  2. CV_Chess

UCI compatible GUIs

XBoard

see XBoard

Open Source Projects

Commercial

Links

Research

see also

Stackexchange

Videos