Difference between revisions of "Raspberry PI Chessboard Camera"
Jump to navigation
Jump to search
Line 204: | Line 204: | ||
<uml> | <uml> | ||
hide circle | hide circle | ||
− | class ArenaQuit | + | package Exceptions <<Rectangle>> { |
− | Exception <|-- ArenaQuit | + | class ArenaQuit |
+ | Exception <|-- ArenaQuit | ||
− | class BadImage | + | class BadImage |
− | BadImage --|> Exception | + | BadImage --|> Exception |
− | class BadSegmentation | + | class BadSegmentation |
− | BadSegmentation --|> Exception | + | BadSegmentation --|> Exception |
− | class CannotBuildStateException | + | class CannotBuildStateException |
− | CannotBuildStateException --|> Exception | + | CannotBuildStateException --|> Exception |
− | class RejectedMove | + | class RejectedMove |
− | RejectedMove --|> Exception | + | RejectedMove --|> Exception |
− | class UserExit | + | class UserExit |
− | UserExit --|> Exception | + | UserExit --|> Exception |
+ | } | ||
− | class Args | + | package PlayChessWithAWebCam { |
+ | note top of Args: This class parses command line arguments and generates a usage. | ||
+ | class Args { | ||
+ | __init__(args) | ||
+ | } | ||
− | class BoardFinder { | + | class BoardFinder { |
− | + | getDominatorOffset() | |
− | + | updateImage(inFrame) | |
− | + | DetectBoardOrientation() | |
− | + | GetChessBoardCoordinates(rotation) | |
− | + | LineCrossingDetection() | |
− | + | GetFullImageBoard(rectCoordinates=None, rotations=None) | |
− | + | _getBlackMaxSide(colorImage) | |
− | + | rotateImage(image) | |
− | } | + | } |
− | class Cell { | + | class Cell { |
− | } | + | } |
− | class ChessCam { | + | class ChessCam { |
− | + | getNextMove() | |
− | + | getDominatorOffset() | |
+ | } | ||
+ | |||
+ | |||
+ | 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 | ||
+ | class State { | ||
+ | __init__(dominatorOffset) | ||
+ | moveCam(move) | ||
+ | _move(fromCell, toCell) | ||
+ | _eat(fromCell, toCell) | ||
+ | _castle(fromCell, toCell) | ||
+ | _tryToPromote(c) | ||
+ | _switchTurn() | ||
+ | _sameColor(c1, c2) | ||
+ | _emptyCell(c) | ||
+ | _validateMove(fromCell, toCell) | ||
+ | _initBoard() | ||
+ | _partMoves(move) | ||
+ | } | ||
+ | class StateDetector | ||
+ | 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 | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
GameEngine -- ChessCam | GameEngine -- ChessCam | ||
GameEngine -- State | GameEngine -- State |
Revision as of 06:02, 20 October 2019
Chessboard Move Recorder
Parts List
# | picture | part | example sources | documents | ~ price |
---|---|---|---|---|---|
1 | Chessboard | Wikipedia | 25 € | ||
2 | Chess pieces | Wikipedia | 25 € | ||
3 | Raspberry PI | Wikipedia | 45 € | ||
4 | Web Camera | Raspberry PI compatibility list (german) | 60 € | ||
5 | USB Powerbank | 15 € | |||
6 | 16 GByte Micro SD Card | 5 € |
Pictures
First Prototype
Second Prototype
Installation
see
- Raspberry_PI for Raspberry PI software installation
- Raspberry PI WebCam for the WebCam installation.
Projects
CV_Chess
Trying out the CV_Chess project from https://classes.engineering.wustl.edu/ese205/core/index.php?title=CV_Chess Fork of it at:
Installation
git clone https://github.com/WolfgangFahl/ESE205-CVChess/
./installOpenCV
./install
Test
./test
============================= test session starts ==============================
platform linux -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: /home/wf/source/python/ESE205-CVChess
collected 2 items
test_camera.py . [ 50%]
test_webcam.py . [100%]
============================== 2 passed in 3.87s ===============================
Preview
# see https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
#gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('Camera',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
start the above code - stop by pressing 'q'
python3 preview.py
Run
./run
Project details
The project was an effort of some 200 hours See also https://classes.engineering.wustl.edu/ese205/core/index.php?title=CV_Chess_Logs
Code Structure
Click classes to view source code
Issues
see also https://github.com/rjgoodloe/ESE205-CVChess/issues
The board detection algorithm does not make sure that squares are really squares.
play-chess-with-a-webcam
see github fork at
Written in python2 migrated to python3.
Code Structure
UCI compatible GUIs
XBoard
sudo apt-get install xboard polyglot stockfish
xboard -fUCI -fcp stockfish -sUCI -scp stockfish
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
Links
- https://en.wikipedia.org/wiki/Universal_Chess_Interface
- 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
Videos