Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

28
LINES

< > BotCompany Repo | #1024815 // ChessOCR_TwoStageRecognizer (old version with rect stream)

JavaX fragment (include)

sclass ChessOCR_TwoStageRecognizer implements Steppable {
  // input
  BufferedImage inputImage;
  Iterator<Rect> rectStream;
  ChessPieceRecognizer pieceRecognizer;
  
  // internal
  new Set<Rect> rectsTried;

  // output
  new Best<Pair<Rect, S>> best; // rect + FEN

  *() {}
  *(ChessPieceRecognizer *pieceRecognizer, BufferedImage *inputImage, Iterator<Rect> *rectStream) {}
  
  public bool step() {
    if (!rectStream.hasNext()) false;
    ret true with tryRect(rectStream.next());
  }
  
  void tryRect(Rect r) {
    r = rectSetHeightToWidth(r); // square it
    if (!rectsTried.add(r)) ret; // seen
    BufferedImage board = clipBufferedImage(inputImage, r);
    S fen, double score = unpair chessOCR_recognizeBoard_FENAndScore(board, pieceRecognizer);
    best.put(pair(r, fen), score);
  }
}

Author comment

Began life as a copy of #1024813

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: #1024815
Snippet name: ChessOCR_TwoStageRecognizer (old version with rect stream)
Eternal ID of this version: #1024815/1
Text MD5: d8a4215d9c0f04f76b6f332dcb0d7493
Author: stefan
Category: javax / chess ocr
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-26 12:49:52
Source code size: 831 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 201 / 235
Referenced in: