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

46
LINES

< > BotCompany Repo | #1005386 // Raw Image Search in Screenshot [works]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Transpiled version (3030L) is out of date.

1  
!752
2  
3  
lib 1003153 // magic.jar
4  
5  
import prophecy.common.image.ImageSurface;
6  
import prophecy.common.image.RGBImage;
7  
import prophecy.common.image.BWImage;
8  
9  
sclass FoundImg {
10  
  Rectangle r;
11  
  S imageID;
12  
  float sim; // similarity in 0 to 1
13  
  
14  
  *() {}
15  
  *(Rectangle *r, S *imageID, float *sim) {}
16  
}
17  
18  
static new L<FoundImg> found;
19  
20  
static float correctness = 0.99f;
21  
22  
p {
23  
  BWImage big = shootScreenBW();
24  
  S patID = "#1004153";  // Search Button
25  
  BWImage pat = loadBWImage(patID);
26  
  
27  
  long start = now();
28  
  
29  
  int wp = pat.getWidth(), hp = pat.getHeight();
30  
  int w = big.getWidth(), h = big.getHeight();
31  
  float maxError = (1f-correctness)*wp*hp;
32  
  for (int y = 0; y < h-hp; y++)
33  
    for (int x = 0; x < w-wp; x++) {
34  
      float diff = bwImageSectionsSimilarity(big, pat, x, y, maxError);
35  
      if (diff <= maxError) {
36  
        float sim = 1-diff/(wp*hp);
37  
        print("Found at " + x + "/" + y + " [sim: " + formatDouble(sim, 4) + "]");
38  
        Rectangle r = new Rectangle(x, y, wp, hp);
39  
        found.add(new FoundImg(r, patID, sim));
40  
        quickShowZoomedImage(big.clip(r).toRGB());
41  
        //x += wp-1;
42  
      }
43  
    }
44  
    
45  
  done(start);
46  
}

Author comment

Began life as a copy of #1004155

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005386
Snippet name: Raw Image Search in Screenshot [works]
Eternal ID of this version: #1005386/1
Text MD5: ab181e2be1c1408433072aaae38aada3
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-13 20:38:07
Source code size: 1186 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 575 / 681
Referenced in: [show references]