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).

sclass ChessOCR_Pipeline {
  replace Segmenter with IF1<BufferedImage, L<Rect>>.
  
  // input
  transient BufferedImage inputImage;
  ChessPieceRecognizer pieceRecognizer;
  
  // internal
  SeenAndQueue<Segmenter> segmenters = new(r _runSegmenters);
  SeenAndQueue<Rect> possibleBoardPositions = new(r _processPositions);
  
  // output
  new ChessOCR_BoardsFound boardsFound;

  // input segmenters & board position proposals:
  
  void addSegmenter(Segmenter s) { segmenters.add(s); }
  void addPossiblePosition(Rect r) { possibleBoardPositions.add(r); }
  
  bool queuesEmpty() { ret segmenters.queueEmpty() && possibleBoardPositions.queueEmpty(); }
  bool idle() { ret segmenters.idle() && possibleBoardPositions.idle(); }
  
  // internal
  
  void _processPositions() {
    for (Rect r : possibleBoardPositions.queueIterator())
      boardsFound.add(setAll(pieceRecognizer.recognizeBoard(clipBufferedImage(inputImage, r)), rectInOriginalImage := r));
  }
  
  void _runSegmenters() {
    for (Segmenter seg : segmenters.queueIterator())
      possibleBoardPositions.addAll(seg.get(inputImage));
  }
  
  void cleanMeUp { // cancels the threads too
    cleanUpAll(possibleBoardPositions, segmenters);
  }
}

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: 285 / 792
Version history: 23 change(s)
Referenced in: [show references]