Difference between revisions of "PlayChessWithAWebCam"

From BITPlan Wiki
Jump to navigation Jump to search
Line 36: Line 36:
 
[[File:detectedProbabilisticHough2019-10-21.png|300px]]
 
[[File:detectedProbabilisticHough2019-10-21.png|300px]]
 
[[File:detectedHough2019-10-21.png|300px]]
 
[[File:detectedHough2019-10-21.png|300px]]
= histogramm =
+
= histogramm / colorcluster=
 +
[[File:chessBoard006.jpg|400px]]
 
<source lang='bash'>
 
<source lang='bash'>
 
python3 opencvtutorial/histogramm.py testMedia/chessBoard006.jpg
 
python3 opencvtutorial/histogramm.py testMedia/chessBoard006.jpg
 
</source>
 
</source>
[[File:chessBoard006.jpg|400px]]
 
 
[[File:hsvhistogramm2019-10-21.jpg|400px]]
 
[[File:hsvhistogramm2019-10-21.jpg|400px]]
 +
<source lang='bash' highlight="1">
 +
python3 opencvtutorial/colorcluster.py testMedia/chessBoard006.jpg
 +
Clusterization took 2.8 s for 1 channels
 +
Clusterization took 4.5 s for 2 channels
 +
Clusterization took 6.7 s for 3 channels
 +
</source>
 +
[[File:colorCluster2019-10-21.jpg|400px]]
 +
 
= Installation =
 
= Installation =
 
Prerequisites: python3.7 (install script will check and try automatic installation in Ubuntu/MacOS)
 
Prerequisites: python3.7 (install script will check and try automatic installation in Ubuntu/MacOS)

Revision as of 16:34, 21 October 2019

OsProject
edit
id  PlayChessWithAWebCam
state  
owner  Wolfgang Fahl
title  Play Chess With A WebCam
url  https://github.com/WolfgangFahl/play-chess-with-a-webcam
version  0.0.1
description  
date  2019/10/21
since  
until  

Motivation

See MagneticSensorChessBoard1987 for the initial project of 1987. Time has moved on and the goals of the 1987 project can be achieved with less hardware and software in a more convenient manner these days.

State of Project

As of 2019-10-21 version 0.0.1 has not been release yet. The state of the project is development/alpha.

There is already a lof of stuff to try out and to participate in this open source project.

The scripts:

  • still
  • record

are already useful for taking pictures and movie recordings of your chess match. The detection of the board and moves is not fully operational yet.


If you'd like to experiment a bit you can run the tests which will show some debug output. Also in the opencvtutoral directory you'll find:

  • colorcluster.py
  • histogramm.py
  • hough_lines.py

hough lines

python3 opencvtutorial/hough_lines.py testMedia/chessBoard002.jpg

ChessBoard002.jpg DetectedProbabilisticHough2019-10-21.png DetectedHough2019-10-21.png

histogramm / colorcluster

ChessBoard006.jpg

python3 opencvtutorial/histogramm.py testMedia/chessBoard006.jpg

Hsvhistogramm2019-10-21.jpg

python3 opencvtutorial/colorcluster.py testMedia/chessBoard006.jpg
Clusterization took 2.8 s for 1 channels
Clusterization took 4.5 s for 2 channels
Clusterization took 6.7 s for 3 channels

ColorCluster2019-10-21.jpg

Installation

Prerequisites: python3.7 (install script will check and try automatic installation in Ubuntu/MacOS)

git clone https://github.com/WolfgangFahl/play-chess-with-a-webcam
cd play-chess-with-a-webcam
scripts/install

Testing

scripts/test
============================= test session starts =============================
platform darwin -- Python 3.7.4, pytest-5.2.1, py-1.8.0, pluggy-0.12.0
rootdir: /Users/wf/source/python/play-chess-with-a-webcam
plugins: cov-2.8.1
collected 11 items                                                            

src/test_Board.py .                                                     [  9%]
src/test_ChessCam.py .                                                  [ 18%]
src/test_OpenCV_version.py .                                            [ 27%]
src/test_Video.py ...                                                   [ 54%]
src/test_findBoard.py .....                                             [100%]

---------- coverage: platform darwin, python 3.7.4-final-0 -----------
Name                         Stmts   Miss  Cover
------------------------------------------------
src/Args.py                     10      7    30%
src/Board.py                    33      3    91%
src/BoardFinder.py             186     12    94%
src/Cell.py                     10      4    60%
src/ChessCam.py                 86     59    31%
src/InputManager.py             57     37    35%
src/MovementDetector.py         55     40    27%
src/StateDetector.py            92     75    18%
src/Video.py                   133     48    64%
src/mathUtils.py                49     25    49%
src/test_Board.py               23      3    87%
src/test_ChessCam.py             4      0   100%
src/test_OpenCV_version.py       6      0   100%
src/test_Video.py               28      0   100%
src/test_findBoard.py           49      0   100%
------------------------------------------------
TOTAL                          821    313    62%


============================= 11 passed in 25.18s =============================

Hardware

see e.g Raspberry_PI_Chessboard_Camera

Source Code

play-chess-with-a-webcam

see github fork at

Written in python2 migrated to python3.7. see https://unix.stackexchange.com/a/410851/38701 for selection your python version on Ubuntu

Code Structure