Download Jar. Libraryless. Click here for Pure Java version (8556L/59K).
sclass ChessOCR_SquareImagesCollector { new Set<S> imageMD5s; L<ChessOCR_PieceImage> allImages = syncList(); VF2<S, Rect> onBoardFound; // image name, board rects void loadImagesFromAGIBlue { for (S name, fen : unpair agiBlue_chess_trainingImagesWithPositions()) { SS map = pairsToCIMap(agiBlue_lookupMultipleKeys(agiBlue_chessBoardRecognitionTrainingImagesSliceID(), name, ll("Input image", "Segmenter used", "Chess board found", "Board location"))); if (!isYes(map.get("Chess board found"))) continue with print("Chess board not found, skipping"); BufferedImage img = loadImage2(parseImageSnippetURL(map.get("input image"))); Rect r = safeUnstructRect(map.get("Board location")); if (r == null) continue with print("No board? Skipping"); print("Board: " + r.w + "*" + r.h); callF(onBoardFound, name, r); if (abs(r.w-r.h) > 3) continue with print("Board not square, skipping"); BufferedImage board = clipBufferedImage(img, r); LS position = chess_parseFEN(fen); printStruct(+position); LL<BufferedImage> squareImages = map2 cloneBufferedImage(bufferedImageMNGrid(board, 8, 8)); for row to 8: { S fenLine = position.get(row); L<BufferedImage> images = squareImages.get(row); for col to 8: if (imageMD5s.add(imageMD5(images.get(col)))) allImages.add(new ChessOCR_PieceImage( chess_xyToSquare(col, row), chess_parseFENSymbol(fenLine.charAt(col)), images.get(col))); } } print("Have " + n2(allImages, "chess square image")); } LPair<S, BufferedImage> allImages() { ret map(cloneList(allImages), i -> pair(i.piece, i.img)); } }
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1024771 |
| Snippet name: | ChessOCR_SquareImagesCollector - extract chess piece images from training screenshots on agi.blue |
| Eternal ID of this version: | #1024771/11 |
| Text MD5: | 18a134722eaa674889b3fdeb0d98f934 |
| Transpilation MD5: | 2fc227ee68f084671763871762157c58 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code (desktop) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-08-29 13:44:41 |
| Source code size: | 1800 bytes / 42 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 735 / 2018 |
| Version history: | 10 change(s) |
| Referenced in: | [show references] |