Difference between revisions of "Raspberry PI Chessboard Camera"

From BITPlan Wiki
Jump to navigation Jump to search
Line 114: Line 114:
 
[[File:CV_Chess_Identified.png|400px]]
 
[[File:CV_Chess_Identified.png|400px]]
 
== Code Structure ==
 
== Code Structure ==
 +
Click classes to view source code
 
<uml>
 
<uml>
 
   hide circle
 
   hide circle
Line 120: Line 121:
 
     feedToAI()
 
     feedToAI()
 
   }
 
   }
   class Board {
+
   class Board [[https://github.com/WolfgangFahl/ESE205-CVChess/blob/master/Board.py]] {
 
     draw(image)
 
     draw(image)
 
     assignState()
 
     assignState()
 
     determineChanges(previous,current)
 
     determineChanges(previous,current)
 
   }
 
   }
   class Game {
+
   class Game [[https://github.com/WolfgangFahl/ESE205-CVChess/blob/master/Game.py]] {
 
     setUp()
 
     setUp()
 
     analyzeBoard()
 
     analyzeBoard()
Line 134: Line 135:
 
     updateCurrent()
 
     updateCurrent()
 
   }
 
   }
   class Camera {
+
   class Camera [[https://github.com/WolfgangFahl/ESE205-CVChess/blob/master/Camera.py]] {
 
     takePicture()
 
     takePicture()
 
   }
 
   }
   class Square {
+
   class Square [[https://github.com/WolfgangFahl/ESE205-CVChess/blob/master/Square.py]]{
 
     draw(image,color,thickness)
 
     draw(image,color,thickness)
 
     drawROI(image,color,thickness)
 
     drawROI(image,color,thickness)
Line 143: Line 144:
 
     classify(image)
 
     classify(image)
 
   }
 
   }
   class Line {
+
   class Line [[https://github.com/WolfgangFahl/ESE205-CVChess/blob/master/Line.py]] {
 
     find_intersection(other)
 
     find_intersection(other)
 
   }
 
   }
   class Application {
+
   class Application [[https://github.com/WolfgangFahl/ESE205-CVChess/blob/master/OOPGUI.py]]{
 
     StartGamePage(tk.Frame)
 
     StartGamePage(tk.Frame)
 
     InitializeBoardPage(tk.Frame)
 
     InitializeBoardPage(tk.Frame)

Revision as of 13:36, 16 October 2019

Chessboard Move Recorder

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

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

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

Installation

see

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

Chesspic2019-10-15 1627.png

Run

./run

CV ChessStep1.png CV ChessStep2.png CV ChessStep3.png CV ChessStep4.png CV ChessStep5.png CV ChessStep6.png CV ChessStep7.png CV Chess Identified.png

Code Structure

Click classes to view source code

UCI compatible GUIs

XBoard

sudo apt-get install xboard polyglot stockfish
xboard -fUCI -fcp stockfish -sUCI -scp stockfish

Links

Videos