Ask Your Question

How to create a chess-board

asked 2014-02-07 04:26:39 -0500

Agribot gravatar image

Hi I'm a newby starting to understand openCV and it's use to create and display graphics on the screen of my laptop.

I'd like to use opencv to draw a chess-board (not the checker pattern often used to calibrate, that's not a chess board) and to display that.

Then I'd like to create small images for each of the chess pieces and then then place each on the chess board.

create a chess board display it create each piece select a position on the board place the piece at that position display that

Can you point me towards some example opencv solution in C or C++ code that could show me how that can be done ?

I'm using Microsoft Visual Studio 2010 Express for C++ version


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-02-07 07:58:41 -0500

Haris gravatar image

updated 2014-02-07 10:52:36 -0500

Check this example

    int blockSize=75;
    int imageSize=blockSize*8;
    Mat chessBoard(imageSize,imageSize,CV_8UC3,Scalar::all(0));
    unsigned char color=0;

     for(int i=0;i<imageSize;i=i+blockSize){
       for(int j=0;j<imageSize;j=j+blockSize){
       Mat ROI=chessBoard(Rect(i,j,blockSize,blockSize));
    imshow("Chess board", chessBoard);

image description

edit flag offensive delete link more



+1. now go and procedurally generate the figures ;)

berak gravatar imageberak ( 2014-02-07 08:10:54 -0500 )edit

Question Tools


Asked: 2014-02-07 04:26:39 -0500

Seen: 9,497 times

Last updated: Feb 07 '14