Code Monkey home page Code Monkey logo

chess-piece-object-detection-using-opencv's Introduction

Chess Piece Detection | OpenCV matchTemplate()

python opencv numpy jupyter

This project involves loading multiple images of chess boards and utilizing the matchTemplate method of OpenCV to detect the pieces present on each board. As a result of this process, the output includes a comprehensive list of the detected chess piece names.

Piece Name Short Name Piece Name Short Name
King (White) King (White) K King (black) King (black) k
Queen (white) Queen (White) Q Queen (black) Queen (black) q
Rook (White) Rook (White) R Rook (black) Rook (black) r
Bishop (white) Bishop (White) B Bishop (black) Bishop (black) b
Knight (White) Knight (White) N Knight (black) Knight (black) n
Pawn (White) Pawn (White) P Pawn (black) Pawn (black) p

Requirements

  • Python 3.x
  • OpenCV
  • Numpy

Usage

To get started, first clone the repository and install the necessary dependencies by running the following command:

pip install opencv-python numpy

Next, place the chess board image files in the test/ directory and the chess piece image files in the chess_piece/ directory.

There are two ways to execute the program:

Method 1: Running in Terminal

To run the script in the terminal, use the following command:

python main.py

Method 2: Running in Jupyter Lab

To run the script in Jupyter Lab, open the main.ipynb notebook and execute the code.

Configuration

The following configurations can be adjusted according to the user's preference:

  • SHOW_IMAGE: If set to True, the image with detected pieces will be displayed. Default is True.
  • EXPORT_IMAGE: If set to True, the image with detected pieces will be saved to the dist/ directory. Default is True.
  • chessPieceThreshold: The threshold values for each chess piece can be adjusted according to the image quality. The default values are provided in the script.
  • CHESS_BOARD_OUTPUT_DIR: The directory where the output images will be saved. Default is dist/.

License

This project is licensed under the MIT License.

chess-piece-object-detection-using-opencv's People

Contributors

arashyeganeh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.