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

40
LINES

< > BotCompany Repo | #1024760 // Optimize magicCombineFactor of Chess Piece Recognizer [OK]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (11729L/65K).

!7

cmodule TrainChessRecognizer > DynSingleFunctionWithPrintLog {
  transient new ChessOCR_SquareImagesCollector squareImagesCollector;

  start-thread {
    //temp dm_tempDisableAllButtons();
    squareImagesCollector.loadImagesFromAGIBlue();
  }
  
  void doIt {
    LPair<S, BufferedImage> images = squareImagesCollector.allImages();
    new ChessPieceRecognizer pieceRecognizer;
    pieceRecognizer.load();
    new Best<Double> best;
    for (double exp = -6; exp <= -2; exp += 0.02) {
      double factor = pow(10, exp);
      print("Factor: " + factor);
      best.put(factor, scoreForFactor(images, pieceRecognizer, factor));
    }
    print(best);
  }
  
  double scoreForFactor(LPair<S, BufferedImage> images, ChessPieceRecognizer pieceRecognizer, double factor) {
    try {
      pieceRecognizer.magicCombineFactor = factor;
      
      new Scorer scorer;
      for (unpair S piece, BufferedImage img : images) {
        scorer.add(eqic(pairA(pieceRecognizer.recognize(img)), piece));
      }
  
      print(scorer);
      ret scorer.score();
    } catch print e {
      print("RECOGNIZER TOTAL FAIL");
      ret 0;
    }
  }
}

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: #1024760
Snippet name: Optimize magicCombineFactor of Chess Piece Recognizer [OK]
Eternal ID of this version: #1024760/21
Text MD5: 66e90be6750cc9c59621719ec64d0335
Transpilation MD5: d53ca1db7c160334f97860fe9a005cdd
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-24 22:01:10
Source code size: 1178 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 257 / 643
Version history: 20 change(s)
Referenced in: [show references]