[Chess PDF to FEN] Detect FEN Automatically from PDF Files and Annotates It

Sort:
Jamarshon

Given a PDF file, it will detect the chessboards automatically and add annotations containing the detected chessboard position so that you can quickly click on it and be directed to the computer analysis without having to setup the position yourself.

 

Chess PDF to FEN is presented as a simple web app at http://chesspdftofen.com:31677/ or as an open source Python module that you can install with pip. The Python module chesspdftofen runs completely locally so it can leverage your own computer resources to do the annotations. This means you are free to process as many files and even do it offline if you wish. It provides an alternative that does not have resource limits or require purchasing.

This is an example video of a possible output. The previous description on Reddit is here.

Disclaimer: It may not work on some book themes or PDF files that are blurry, too small, or boards that are not axis-aligned with the page. Also, the web app may have issues when there is high amounts of traffic so try to visit it another time if an error occurs.

meetarnav

Neat. I think given that there are such ideas now especially with ChessVision.ai (rubvish subscription model), the winner will be an app for iOS that (1) scans pdf for images and generates fen on lichess etc. (2) also scans games and moves.

These two objectives can be combined by just converting the whole PDF into a PGN file with text as comments, separated by page numbers or chapters. That would be the icing on the cake!

mllave1

Is this still working? I'm getting this error.
boards = segment_boards(page_im)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mllave\AppData\Local\anaconda3\Lib\site-packages\chesspdftofen\segment_boards.py", line 173, in segment_boards
filtered_contours, filtered_rects = get_contours(th2)
^^^^^^^^^^^^^^^^^
File "C:\Users\mllave\AppData\Local\anaconda3\Lib\site-packages\chesspdftofen\segment_boards.py", line 50, in get_contours
contours.sort(key=lambda cnt: cv2.contourArea(cnt), reverse=True)
^^^^^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'sort'
Any clue?