Screen Capture using X11 or any other library and use it in OpenCV

asked 2018-11-25 06:04:15 -0600

updated 2018-11-25 06:48:52 -0600

I am working on a project [ Creating an AI for playing chess ] in which I have to capture the whole screen or a particular window in real time. I saw a question in stack exchange about taking fast screenshots using X11 and using it in OpenCV QUESTION to display those screen shots. Unknowingly I started the project and now I am having a problem using at method to access pixels of the image captured.

Here's what I have to do:

  1. Capture the image of the screen [ Image of a chess board ]
  2. Break it into equal parts and detect the position of the chess pieces.
  3. Store these positions and puttext on the image captured and display it on the screen. [For detection purpose I have the images of the chess pieces which I cropped from the chess board. Each one of the chess piece have a size of 4747 pixels. Similarly the chessboard has a size of 474788 ]

Is there any way I can detect these chess pieces?

Links of the source files [ C++ ] : maya.cpp pieces.cpp pieces.h

example of pieces I want to detect : image description image description

The chessboard Image : image description

This chessboard is on the screen and I know the exact position of this board as I have set its position to Point(50,150) and what I did is iterating thru each squares with the help of their positions. I want my program to keep updates of the chess pieces and display it on the screen in real time.

Thanks in advance!

edit retag flag offensive close merge delete


it's unclear now, what works and what not.

what are you trying to detect the pieces ? (or is that the question, now ?)

could you restrict the code to some minimal example of the problem, and put it into your question ? (NOT on dropbox, where it'll probably vanish in the near future)

an example image or 2 would also be helpful here.

berak gravatar imageberak ( 2018-11-25 06:16:59 -0600 )edit

Done... Se the updated question

brightprogrammer gravatar imagebrightprogrammer ( 2018-11-25 06:49:10 -0600 )edit