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

26
LINES

< > BotCompany Repo | #1024884 // ChessOCR_BoardsFound

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2207L/14K).

1  
sclass ChessOCR_BoardsFound {
2  
  sclass ByFEN {
3  
    double bestScore;
4  
    Rect bestPosition;
5  
    Set<Pair<Rect, Double>> boardPositions = synchroSet();
6  
  }
7  
  
8  
  Map<S, ByFEN> byFEN = synchroMap();
9  
  transient L onChange = synchroList(); // L<Runnable|voidfunc(S fen)>
10  
  transient L onImprovedScore = synchroList(); // L<Runnable|voidfunc(S fen, Rect)>
11  
  
12  
  void add(ChessOCR_RecognizedBoard b) {
13  
    if (b == null || b.fen == null) ret;
14  
    ByFEN bf = getOrCreate ByFEN(byFEN, b.fen);
15  
    bool change;
16  
    if (b.rectInOriginalImage != null)
17  
      if (bf.boardPositions.add(pair(b.rectInOriginalImage, b.score))) set change;
18  
    if (b.score > bf.bestScore) {
19  
      bf.bestScore = b.score;
20  
      bf.bestPosition = b.rectInOriginalImage;
21  
      pcallFAll(onImprovedScore, b.fen, bf.bestPosition);
22  
      set change;
23  
    }
24  
    if (change) pcallFAll(onChange, b.fen);
25  
  }
26  
}

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: #1024884
Snippet name: ChessOCR_BoardsFound
Eternal ID of this version: #1024884/10
Text MD5: fda927817f51851b36721f5ebdaad411
Transpilation MD5: 7e8e9d189962f1698d1e0782a16adcf9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-28 22:58:48
Source code size: 890 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 244 / 674
Version history: 9 change(s)
Referenced in: [show references]