Warning: session_start(): open(/var/lib/php/sessions/sess_a8j3s34k85n0jvr4bieivu78f3, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass ChessOCR_SquareImagesCollector {
new Set imageMD5s;
L allImages = syncList();
VF2 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 squareImages = map2 cloneBufferedImage(bufferedImageMNGrid(board, 8, 8));
for row to 8: {
S fenLine = position.get(row);
L 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 allImages() {
ret map(cloneList(allImages), i -> pair(i.piece, i.img));
}
}