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

1  
!7
2  
3  
cmodule LearnActiveTab > DynSingleFunctionWithPrintLog {
4  
  LPair<RGBImage, Rect> scaledImages;
5  
  
6  
  void doIt {
7  
    // load scaled down test images
8  
    
9  
    LPair<File, Rect> data = gatherMarkedThingInImages(listImageFiles(aiImageAlbumDir()), "Active tab");
10  
    pnlStruct(data);
11  
    
12  
    int gridSize = 4;
13  
    scaledImages = scaleDownTestImagesWithRect(gridSize, data);
14  
    
15  
    // make "random & vary" module
16  
    
17  
    RandomAndVary_Record<CloseToColorPredicate> rav = new(CloseToColorPredicate, 
18  
      color := new RandomAndVary_RGBInt,
19  
      maxDistance := new RandomAndVary_Double);
20  
      
21  
    // optimize
22  
      
23  
    CloseToColorPredicate e = pairA(racerOptimize(rav, func(CloseToColorPredicate e) -> double { scoreColorPredicateByRect(e, scaledImages) }, minRuntimeUnless100 := 10.0));
24  
    
25  
    print(e);
26  
    showImage(renderColorPredicateOnTestImages(e, pairsA(scaledImages));
27  
    
28  
    // use centroid to detect rects
29  
    
30  
    for (Pair<RGBImage, Rect> p : scaledImages) {
31  
      DoublePt pt = centroidForColorPredicate(e, p.a);
32  
      if (pt == null) continue with print("No result");
33  
      double dist = ptDistance(pt, centerOfRect(p.b));
34  
      print(pt + " / " + centerOfRect(p.b));
35  
      print("Error: " + percentRatio(dist, hypotenuse(p.a.getWidth(), p.a.getHeight())) + "%");
36  
    }
37  
  }
38  
}

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: 265 / 974
Version history: 39 change(s)
Referenced in: [show references]