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

38
LINES

< > BotCompany Repo | #1024886 // ChessOCR_Pipeline - multi-threaded

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

Libraryless. Click here for Pure Java version (8304L/55K).

1  
sclass ChessOCR_Pipeline {
2  
  replace Segmenter with IF1<BufferedImage, L<Rect>>.
3  
  
4  
  // input
5  
  transient BufferedImage inputImage;
6  
  ChessPieceRecognizer pieceRecognizer;
7  
  
8  
  // internal
9  
  SeenAndQueue<Segmenter> segmenters = new(r _runSegmenters);
10  
  SeenAndQueue<Rect> possibleBoardPositions = new(r _processPositions);
11  
  
12  
  // output
13  
  new ChessOCR_BoardsFound boardsFound;
14  
15  
  // input segmenters & board position proposals:
16  
  
17  
  void addSegmenter(Segmenter s) { segmenters.add(s); }
18  
  void addPossiblePosition(Rect r) { possibleBoardPositions.add(r); }
19  
  
20  
  bool queuesEmpty() { ret segmenters.queueEmpty() && possibleBoardPositions.queueEmpty(); }
21  
  bool idle() { ret segmenters.idle() && possibleBoardPositions.idle(); }
22  
  
23  
  // internal
24  
  
25  
  void _processPositions() {
26  
    for (Rect r : possibleBoardPositions.queueIterator())
27  
      boardsFound.add(setAll(pieceRecognizer.recognizeBoard(clipBufferedImage(inputImage, r)), rectInOriginalImage := r));
28  
  }
29  
  
30  
  void _runSegmenters() {
31  
    for (Segmenter seg : segmenters.queueIterator())
32  
      possibleBoardPositions.addAll(seg.get(inputImage));
33  
  }
34  
  
35  
  void cleanMeUp { // cancels the threads too
36  
    cleanUpAll(possibleBoardPositions, segmenters);
37  
  }
38  
}

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: #1024886
Snippet name: ChessOCR_Pipeline - multi-threaded
Eternal ID of this version: #1024886/24
Text MD5: dd3fec6addd5ae190e3ecceb147f19d6
Transpilation MD5: 15c757b31add200618ed45b4567a629b
Author: stefan
Category: javax / image recognition
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-28 22:49:30
Source code size: 1250 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 286 / 793
Version history: 23 change(s)
Referenced in: [show references]