Difference between revisions of "PlayChessWithAWebCam/BoardFinder"

From BITPlan Wiki
Jump to navigation Jump to search
Line 11: Line 11:
 
<source lang='python'>
 
<source lang='python'>
 
finder = BoardFinder(image,video=video)
 
finder = BoardFinder(image,video=video)
 +
</source>
 +
=== finding the chessboard corners ===
 +
The find method starts the board finding. The Boardfinder will try out different patterns from 7x7 down to 3x3. Since a successfull find is much quicker than an unsuccessful one and since searching a small image is much faster than a big one the width of the searchImages can be specified. The default is 640 pixels. For the 13 tests images the search is even succesful when the searchWidth is only 360 pixels. The difference in speed is approximately a factor of 1.5.
 +
<source lang='python'>
 +
found=finder.find(limit=1,searchWidth=360)
 
</source>
 
</source>
  

Revision as of 07:34, 1 December 2019

Source Code

see class BoardFinder in module boardfinder tests are in the: test_BoardFinder module

Algorithm

Finding the chessboard

OpenCV has a function findChessboardCorners which is usually used for camera calibration and not really intended for the use case of "real chessboards".

Still it is very helpful and used as a basis for the BoardFinder.

Initializing the BoardFinder

The board finder is initialized with an image. Optionally you can specify the Video instance to be used.

finder = BoardFinder(image,video=video)

finding the chessboard corners

The find method starts the board finding. The Boardfinder will try out different patterns from 7x7 down to 3x3. Since a successfull find is much quicker than an unsuccessful one and since searching a small image is much faster than a big one the width of the searchImages can be specified. The default is 640 pixels. For the 13 tests images the search is even succesful when the searchWidth is only 360 pixels. The difference in speed is approximately a factor of 1.5.

found=finder.find(limit=1,searchWidth=360)

Examples

see testMedia source folder

ChessBoard001.jpgImage001-corners-7x7.jpg ChessBoard002.jpgImage002-corners-5x5.jpg ChessBoard003.jpgImage003-corners-4x5.jpg ChessBoard004.jpgImage004-corners-7x7.jpg ChessBoard005.jpgImage005-corners-5x5.jpg ChessBoard006.jpgImage006-corners-5x5.jpg ChessBoard007.jpgImage007-corners-5x5.jpg ChessBoard008.jpgImage008-corners-7x7.jpg ChessBoard009.jpgImage009-corners-7x7.jpg ChessBoard010.jpgImage010-corners-6x7.jpg ChessBoard011.jpgImage011-corners-7x7.jpg ChessBoard012.jpgImage012-corners-4x6.jpg ChessBoard013.jpgImage013-corners-5x7.jpg