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

35
LINES

< > BotCompany Repo | #1015117 // Modifying thingsOnScreenMap [dev.]

JavaX fragment (include)

1  
static Set<S> thingsOnScreenMap_md5s;
2  
3  
static File thingsOnScreenMap_cacheFile() {
4  
  ret newFile(javaxCacheDir(), "segments-on-screen.txt");
5  
}
6  
7  
static MultiMap<S, Rect> thingsOnScreenMap() {
8  
  lock thingsOnScreenMap_lock;
9  
  pcall {
10  
    S s = loadTextFile(thingsOnScreenMap_cacheFile());
11  
    if (s != null) {
12  
      long time = parseLong(first(lines(s)));
13  
      if (now() < time+10000)
14  
        ret thin
15  
  }
16  
  ret thingsOnScreenMap(shootScreenBW());
17  
}
18  
  
19  
static MultiMap<S, Rect> thingsOnScreenMap(BWImage bwScreenShot) {
20  
  new TreeSet<S> elements;
21  
  L<Rect> segments = autoSegment(bwScreenShot);
22  
  new MultiMap<S, Rect> map;
23  
  new HashSet<S> md5s;
24  
  for (Rect r : segments) {
25  
    RGBImage clip = bwScreenShot.clip(r).toRGB();
26  
    md5s.add(rgbMD5(clip));
27  
  }
28  
  thingsOnScreenMap_md5s = md5s;
29  
  ret md5sOnScreenToNames(md5s);
30  
  SS comments = thingsOnScreenDefinitions();
31  
  S text = comments.get(md5);
32  
    if (nempty(text)) map.put(text, r);
33  
  }
34  
  ret map;
35  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015117
Snippet name: Modifying thingsOnScreenMap [dev.]
Eternal ID of this version: #1015117/1
Text MD5: 76f7488548f09fbdbc573f2d6cfc0c73
Author: stefan
Category: javax / ocr
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-08 14:47:45
Source code size: 987 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 234 / 268
Referenced in: [show references]