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

38
LINES

< > BotCompany Repo | #1022929 // Learn to find active tab [OK]

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

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

!7

cmodule LearnActiveTab > DynSingleFunctionWithPrintLog {
  LPair<RGBImage, Rect> scaledImages;
  
  void doIt {
    // load scaled down test images
    
    LPair<File, Rect> data = gatherMarkedThingInImages(listImageFiles(aiImageAlbumDir()), "Active tab");
    pnlStruct(data);
    
    int gridSize = 4;
    scaledImages = scaleDownTestImagesWithRect(gridSize, data);
    
    // make "random & vary" module
    
    RandomAndVary_Record<CloseToColorPredicate> rav = new(CloseToColorPredicate, 
      color := new RandomAndVary_RGBInt,
      maxDistance := new RandomAndVary_Double);
      
    // optimize
      
    CloseToColorPredicate e = pairA(racerOptimize(rav, func(CloseToColorPredicate e) -> double { scoreColorPredicateByRect(e, scaledImages) }, minRuntimeUnless100 := 10.0));
    
    print(e);
    showImage(renderColorPredicateOnTestImages(e, pairsA(scaledImages));
    
    // use centroid to detect rects
    
    for (Pair<RGBImage, Rect> p : scaledImages) {
      DoublePt pt = centroidForColorPredicate(e, p.a);
      if (pt == null) continue with print("No result");
      double dist = ptDistance(pt, centerOfRect(p.b));
      print(pt + " / " + centerOfRect(p.b));
      print("Error: " + percentRatio(dist, hypotenuse(p.a.getWidth(), p.a.getHeight())) + "%");
    }
  }
}

Author comment

Began life as a copy of #1022921

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022929
Snippet name: Learn to find active tab [OK]
Eternal ID of this version: #1022929/40
Text MD5: 605a02433189ff7d0d6ec42a3a3305f1
Transpilation MD5: a5d28a3cd605e6d021bbf4f72beb8359
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-17 06:51:52
Source code size: 1337 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 373 / 1106
Version history: 39 change(s)
Referenced in: [show references]