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)

1  
sclass ChessOCR_TwoStageRecognizer implements Steppable {
2  
  // input
3  
  BufferedImage inputImage;
4  
  Iterator<Rect> rectStream;
5  
  ChessPieceRecognizer pieceRecognizer;
6  
  
7  
  // internal
8  
  new Set<Rect> rectsTried;
9  
10  
  // output
11  
  new Best<Pair<Rect, S>> best; // rect + FEN
12  
13  
  *() {}
14  
  *(ChessPieceRecognizer *pieceRecognizer, BufferedImage *inputImage, Iterator<Rect> *rectStream) {}
15  
  
16  
  public bool step() {
17  
    if (!rectStream.hasNext()) false;
18  
    ret true with tryRect(rectStream.next());
19  
  }
20  
  
21  
  void tryRect(Rect r) {
22  
    r = rectSetHeightToWidth(r); // square it
23  
    if (!rectsTried.add(r)) ret; // seen
24  
    BufferedImage board = clipBufferedImage(inputImage, r);
25  
    S fen, double score = unpair chessOCR_recognizeBoard_FENAndScore(board, pieceRecognizer);
26  
    best.put(pair(r, fen), score);
27  
  }
28  
}

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: 202 / 236
Referenced in: [show references]